Skip to content

Commit 488fa49

Browse files
committed
Fixes from PR review
1 parent 942b816 commit 488fa49

File tree

5 files changed

+31
-17
lines changed

5 files changed

+31
-17
lines changed

plugins/SkyCultureMaker/src/SkyCultureMaker.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,11 @@ void SkyCultureMaker::init()
154154
{
155155
QPixmap iconScmDisabled(":/SkyCultureMaker/bt_SCM_Off.png");
156156
QPixmap iconScmEnabled(":/SkyCultureMaker/bt_SCM_On.png");
157-
qDebug() << "SkyCultureMaker: " << (iconScmDisabled.isNull() ? "Failed to load image: bt_SCM_Off.png"
157+
qDebug() << "SkyCultureMaker: "
158+
<< (iconScmDisabled.isNull() ? "Failed to load image: bt_SCM_Off.png"
158159
: "Loaded image: bt_SCM_Off.png");
159-
qDebug() << "SkyCultureMaker: " << (iconScmEnabled.isNull() ? "Failed to load image: bt_SCM_On.png"
160+
qDebug() << "SkyCultureMaker: "
161+
<< (iconScmEnabled.isNull() ? "Failed to load image: bt_SCM_On.png"
160162
: "Loaded image: bt_SCM_On.png");
161163

162164
StelGui *gui = dynamic_cast<StelGui *>(app.getGui());
@@ -535,6 +537,12 @@ void SkyCultureMaker::openConstellationDialog(const QString &constellationId)
535537
{
536538
// Load the necessary data
537539
scm::ScmSkyCulture *skyCulture = getCurrentSkyCulture();
540+
if (skyCulture == nullptr)
541+
{
542+
qDebug() << "SkyCultureMaker: Current Sky Culture is not initialized.";
543+
return;
544+
}
545+
538546
scm::ScmConstellation *constellation = skyCulture->getConstellation(constellationId);
539547
if (constellation != nullptr)
540548
{

plugins/SkyCultureMaker/src/gui/ScmConstellationDialog.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,14 @@ void ScmConstellationDialog::bindSelectedStar()
293293
}
294294

295295
ScmConstellationImageAnchor *anchor = imageItem->getSelectedAnchor();
296-
bool success = anchor->trySetStarHip(stelObj->getID());
296+
if (anchor == nullptr)
297+
{
298+
ui->infoLbl->setText("WARNING: No anchor is selected.");
299+
qDebug() << "SkyCultureMaker: No anchor is selected";
300+
return;
301+
}
302+
303+
bool success = anchor->trySetStarHip(stelObj->getID());
297304
if (success == false)
298305
{
299306
ui->infoLbl->setText("WARNING: The selected object must contain a HIP number.");
@@ -316,7 +323,8 @@ void ScmConstellationDialog::tabChanged(int index)
316323
bool ScmConstellationDialog::canConstellationBeSaved() const
317324
{
318325
// shouldnt happen
319-
if (maker->getCurrentSkyCulture() == nullptr)
326+
scm::ScmSkyCulture *currentSkyCulture = maker->getCurrentSkyCulture();
327+
if (currentSkyCulture == nullptr)
320328
{
321329
ui->infoLbl->setText("WARNING: Could not save: Sky Culture is not set");
322330
qDebug() << "SkyCultureMaker: Could not save: Sky Culture is not set";
@@ -340,7 +348,7 @@ bool ScmConstellationDialog::canConstellationBeSaved() const
340348
}
341349

342350
// Not editing a constellation, but the ID already exists
343-
if (constellationBeingEdited == nullptr && maker->getCurrentSkyCulture()->getConstellation(finalId) != nullptr)
351+
if (constellationBeingEdited == nullptr && currentSkyCulture->getConstellation(finalId) != nullptr)
344352
{
345353
ui->infoLbl->setText("WARNING: Could not save: Constellation with this ID already exists");
346354
qDebug() << "SkyCultureMaker: Could not save: Constellation with this ID already exists, id = "
@@ -349,7 +357,7 @@ bool ScmConstellationDialog::canConstellationBeSaved() const
349357
}
350358
// Editing a constellation, but the ID already exists and is not the same as the one being edited
351359
else if (constellationBeingEdited != nullptr && constellationBeingEdited->getId() != finalId &&
352-
maker->getCurrentSkyCulture()->getConstellation(finalId) != nullptr)
360+
currentSkyCulture->getConstellation(finalId) != nullptr)
353361
{
354362
ui->infoLbl->setText("WARNING: Could not save: Constellation with this ID already exists");
355363
qDebug() << "SkyCultureMaker: Could not save: Constellation with this ID already exists, id = "

plugins/SkyCultureMaker/src/gui/ScmConstellationImage.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2222
*/
2323

24-
#ifndef ScmConstellationImage_H
25-
#define ScmConstellationImage_H
24+
#ifndef SCM_CONSTELLATION_IMAGE_H
25+
#define SCM_CONSTELLATION_IMAGE_H
2626

2727
#include "ScmConstellationArtwork.hpp"
2828
#include "ScmConstellationImageAnchor.hpp"
@@ -129,4 +129,4 @@ class ScmConstellationImage : public QGraphicsPixmapItem
129129
scm::ScmConstellationArtwork artwork;
130130
};
131131

132-
#endif // ScmConstellationImage_H
132+
#endif // SCM_CONSTELLATION_IMAGE_H

plugins/SkyCultureMaker/src/gui/ScmConstellationImageAnchor.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2222
*/
2323

24-
#ifndef ScmConstellationImageAnchor_H
25-
#define ScmConstellationImageAnchor_H
24+
#ifndef SCM_CONSTELLATION_IMAGE_ANCHOR_H
25+
#define SCM_CONSTELLATION_IMAGE_ANCHOR_H
2626

2727
#include "StarMgr.hpp"
2828
#include "VecMath.hpp"
@@ -156,4 +156,4 @@ class ScmConstellationImageAnchor : public QGraphicsEllipseItem
156156
QRectF movementBound;
157157
};
158158

159-
#endif // ScmConstellationImageAnchor_H
159+
#endif // SCM_CONSTELLATION_IMAGE_ANCHOR_H

plugins/SkyCultureMaker/src/gui/ScmSkyCultureDialog.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,10 @@ void ScmSkyCultureDialog::createDialogContent()
104104
ui->SaveSkyCultureBtn->setEnabled(false);
105105
ui->RemoveConstellationBtn->setEnabled(false);
106106
ui->EditConstellationBtn->setEnabled(false);
107-
ui->EditConstellationBtn->setToolTip("Warning: Editing a constellation resets the artwork.");
108107
connect(ui->SaveSkyCultureBtn, &QPushButton::clicked, this, &ScmSkyCultureDialog::saveSkyCulture);
109108
connect(ui->AddConstellationBtn, &QPushButton::clicked, this, &ScmSkyCultureDialog::constellationDialog);
110109

111-
connect(ui->EditConstellationBtn, &QPushButton::clicked, this,
112-
&ScmSkyCultureDialog::editSelectedConstellation);
110+
connect(ui->EditConstellationBtn, &QPushButton::clicked, this, &ScmSkyCultureDialog::editSelectedConstellation);
113111
connect(ui->constellationsList, &QListWidget::itemSelectionChanged, this,
114112
&ScmSkyCultureDialog::updateEditConstellationButton);
115113

@@ -180,7 +178,7 @@ void ScmSkyCultureDialog::editSelectedConstellation()
180178
auto selectedItems = ui->constellationsList->selectedItems();
181179
if (!selectedItems.isEmpty() && constellations != nullptr)
182180
{
183-
QListWidgetItem *item = selectedItems.first();
181+
QListWidgetItem *item = selectedItems.first();
184182
QString constellationName = item->text();
185183

186184
// Get Id by comparing to the display name
@@ -195,7 +193,7 @@ void ScmSkyCultureDialog::editSelectedConstellation()
195193
break;
196194
}
197195
}
198-
196+
199197
maker->openConstellationDialog(selectedConstellationId);
200198
}
201199
}

0 commit comments

Comments
 (0)