diff --git a/src/blackcore/application.cpp b/src/blackcore/application.cpp index b40572a3d..52d95878b 100644 --- a/src/blackcore/application.cpp +++ b/src/blackcore/application.cpp @@ -351,9 +351,7 @@ namespace BlackCore if (this->isSet(m_cmdClearCache)) { const QStringList files(CApplication::clearCaches()); - msgs.push_back( - CLogMessage(this).debug() << "Cleared cache, " << files.size() << " files" - ); + msgs.push_back(CLogMessage(this).debug() << "Cleared cache, " << files.size() << " files"); } // crashpad dump @@ -383,20 +381,12 @@ namespace BlackCore msgs.push_back(this->startHookIn()); if (msgs.isFailure()) { break; } - // trigger loading and saving of settings in appropriate scenarios - if (m_coreFacadeConfig.getModeApplication() != CCoreFacadeConfig::Remote) - { - // facade running here locally - msgs.push_back(CSettingsCache::instance()->loadFromStore()); - if (msgs.isFailure()) { break; } + // Settings if not already initialized + msgs.push_back(this->initLocalSettings()); + if (msgs.isFailure()) { break; } - // Settings are distributed via DBus. So only one application is responsible for saving. `enableLocalSave()` means - // "this is the application responsible for saving". If swiftgui requests a setting to be saved, it is sent to swiftcore and saved by swiftcore. - CSettingsCache::instance()->enableLocalSave(); - - // From this moment on, we have settings, so enable crash handler. - msgs.push_back(this->initCrashHandler()); - } + // we have settings, so enable crash handler. + msgs.push_back(this->initCrashHandler()); } while (false); @@ -524,6 +514,25 @@ namespace BlackCore return false; } + CStatusMessage CApplication::initLocalSettings() + { + if (m_localSettingsLoaded) { return CStatusMessage(); } + m_localSettingsLoaded = true; + + // trigger loading and saving of settings in appropriate scenarios + if (m_coreFacadeConfig.getModeApplication() != CCoreFacadeConfig::Remote) + { + // facade running here locally + const CStatusMessage msg = CSettingsCache::instance()->loadFromStore(); + if (msg.isFailure()) { return msg; } + + // Settings are distributed via DBus. So only one application is responsible for saving. `enableLocalSave()` means + // "this is the application responsible for saving". If swiftgui requests a setting to be saved, it is sent to swiftcore and saved by swiftcore. + CSettingsCache::instance()->enableLocalSave(); + } + return CStatusMessage(); + } + bool CApplication::hasUnsavedSettings() const { return !this->getUnsavedSettingsKeys().isEmpty(); @@ -811,7 +820,10 @@ namespace BlackCore m_useContexts = true; m_coreFacadeConfig = coreConfig; + const CStatusMessage msg = this->initLocalSettings(); + if (msg.isFailure()) { return msg; } + // now we can use settings // if not yet initialized, init web data services if (!m_useWebData) { diff --git a/src/blackcore/application.h b/src/blackcore/application.h index ce0531bbb..c47907589 100644 --- a/src/blackcore/application.h +++ b/src/blackcore/application.h @@ -592,6 +592,9 @@ namespace BlackCore //! Dev.environment, return value will be used for m_devEnv bool initIsRunningInDeveloperEnvironment() const; + //! Init the local settings + BlackMisc::CStatusMessage initLocalSettings(); + //! Async. start when setup is loaded BlackMisc::CStatusMessageList asyncWebAndContextStart(); @@ -624,6 +627,7 @@ namespace BlackCore bool m_signalStartup = true; //!< signal startup automatically bool m_devFlag = false; //!< dev. environment bool m_saveSettingsOnShutdown = true; //!< saving all settings on shutdown + bool m_localSettingsLoaded = false; //!< local settings loaded? // -------------- crashpad ----------------- BlackMisc::CStatusMessageList initCrashHandler();