Skip to content

Commit

Permalink
Avoid saving and reading wrong indexes for telescopes, CCD and eyepie…
Browse files Browse the repository at this point in the history
…ces (fix #3537, fix #3545)
  • Loading branch information
alex-w committed Dec 11, 2023
1 parent 5154b04 commit 17c27b8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions plugins/Oculars/src/Oculars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ void Oculars::deinit()
settings->setValue("telescope_count", telescopes.count());
settings->setValue("ccd_count", ccds.count());
settings->setValue("lens_count", lenses.count());
settings->setValue("ocular_index", selectedOcularIndex);
settings->setValue("telescope_index", selectedTelescopeIndex);
settings->setValue("ccd_index", selectedCCDIndex);
settings->setValue("ocular_index", qMax(0, selectedOcularIndex));
settings->setValue("telescope_index", qMax(0, selectedTelescopeIndex));
settings->setValue("ccd_index", qMax(0, selectedCCDIndex));
settings->setValue("lens_index", selectedLensIndex);

StelCore *core = StelApp::getInstance().getCore();
Expand Down Expand Up @@ -505,7 +505,7 @@ void Oculars::init()
}
else
{
selectedOcularIndex = settings->value("ocular_index", 0).toInt();
selectedOcularIndex = qMax(0, settings->value("ocular_index", 0).toInt());
}

int ccdCount = settings->value("ccd_count", 0).toInt();
Expand All @@ -527,9 +527,9 @@ void Oculars::init()
qWarning() << "The Oculars ini file appears to be corrupt; delete it.";
ready = false;
}
selectedCCDIndex = settings->value("ccd_index", 0).toInt();
selectedCCDIndex = qMax(0, settings->value("ccd_index", 0).toInt());

int telescopeCount = settings->value("telescope_count", 0).toInt();
int telescopeCount = qMax(0, settings->value("telescope_count", 0).toInt());
int actualTelescopeCount = telescopeCount;
for (int index = 0; index < telescopeCount; index++)
{
Expand Down

0 comments on commit 17c27b8

Please sign in to comment.