Skip to content

Commit

Permalink
Fix a problem with initialisation sequence (Fix #3550)
Browse files Browse the repository at this point in the history
- for auto-location from Network at startup,
  we cannot use LandscapeMgr to set ZeroColor landscape
  as it was not yet initialized.
- Added a late initialisation of that in StelApp. Not pretty,
  but I don't see another place for this.
  • Loading branch information
gzotti committed Dec 13, 2023
1 parent 33e0092 commit 4a328a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/core/StelApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,14 @@ void StelApp::init(QSettings* conf)
LandscapeMgr* landscape = new LandscapeMgr();
landscape->init();
getModuleMgr().registerModule(landscape);
// Only now we can switch to auto-landscape. (GH:#3550)
if (landscape->getFlagLandscapeAutoSelection() && (confSettings->value("init_location/location", "auto").toString() == "auto"))
{
StelLocation loc=core->getCurrentLocation();
QColor color=planetLocationMgr->getColorForCoordinates(loc.getLongitude(), loc.getLatitude());
QString landscapeAutoName=QString("ZeroColor(%1)").arg(Vec3f(color).toStr());
emit core->targetLocationChanged(loc, landscapeAutoName); // inform others about our next location. E.g., let LandscapeMgr load a new landscape.
}

SplashScreen::showMessage(q_("Initializing grid lines..."));
GridLinesMgr* gridLines = new GridLinesMgr();
Expand Down
4 changes: 2 additions & 2 deletions src/core/StelLocationMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1171,9 +1171,9 @@ void StelLocationMgr::changeLocationFromNetworkLookup()
// Ensure that ipTimeZone is a valid IANA timezone name!
QTimeZone ipTZ(ipTimeZone.toUtf8());
core->setCurrentTimeZone( !ipTZ.isValid() || ipTimeZone.isEmpty() ? "LMST" : ipTimeZone);
LandscapeMgr *lMgr=GETSTELMODULE(LandscapeMgr);
LandscapeMgr *lMgr=GETSTELMODULE_SILENT(LandscapeMgr); // This may fail during StelApp:init() (GH:#3550)
QString landscapeAutoName;
if (lMgr->getFlagLandscapeAutoSelection())
if (lMgr && lMgr->getFlagLandscapeAutoSelection())
{
QColor color=getColorForCoordinates(loc.getLongitude(), loc.getLatitude());
landscapeAutoName=QString("ZeroColor(%1)").arg(Vec3f(color).toStr());
Expand Down

0 comments on commit 4a328a8

Please sign in to comment.