* load local settings before core facade is created
* or load it in the next step, in case there are no contexts
This commit is contained in:
Klaus Basan
2018-05-29 00:40:13 +02:00
parent 4021822753
commit c7f77c6892
2 changed files with 32 additions and 16 deletions

View File

@@ -351,9 +351,7 @@ namespace BlackCore
if (this->isSet(m_cmdClearCache)) if (this->isSet(m_cmdClearCache))
{ {
const QStringList files(CApplication::clearCaches()); const QStringList files(CApplication::clearCaches());
msgs.push_back( msgs.push_back(CLogMessage(this).debug() << "Cleared cache, " << files.size() << " files");
CLogMessage(this).debug() << "Cleared cache, " << files.size() << " files"
);
} }
// crashpad dump // crashpad dump
@@ -383,20 +381,12 @@ namespace BlackCore
msgs.push_back(this->startHookIn()); msgs.push_back(this->startHookIn());
if (msgs.isFailure()) { break; } if (msgs.isFailure()) { break; }
// trigger loading and saving of settings in appropriate scenarios // Settings if not already initialized
if (m_coreFacadeConfig.getModeApplication() != CCoreFacadeConfig::Remote) msgs.push_back(this->initLocalSettings());
{ if (msgs.isFailure()) { break; }
// facade running here locally
msgs.push_back(CSettingsCache::instance()->loadFromStore());
if (msgs.isFailure()) { break; }
// Settings are distributed via DBus. So only one application is responsible for saving. `enableLocalSave()` means // we have settings, so enable crash handler.
// "this is the application responsible for saving". If swiftgui requests a setting to be saved, it is sent to swiftcore and saved by swiftcore. msgs.push_back(this->initCrashHandler());
CSettingsCache::instance()->enableLocalSave();
// From this moment on, we have settings, so enable crash handler.
msgs.push_back(this->initCrashHandler());
}
} }
while (false); while (false);
@@ -524,6 +514,25 @@ namespace BlackCore
return false; 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 bool CApplication::hasUnsavedSettings() const
{ {
return !this->getUnsavedSettingsKeys().isEmpty(); return !this->getUnsavedSettingsKeys().isEmpty();
@@ -811,7 +820,10 @@ namespace BlackCore
m_useContexts = true; m_useContexts = true;
m_coreFacadeConfig = coreConfig; 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 not yet initialized, init web data services
if (!m_useWebData) if (!m_useWebData)
{ {

View File

@@ -592,6 +592,9 @@ namespace BlackCore
//! Dev.environment, return value will be used for m_devEnv //! Dev.environment, return value will be used for m_devEnv
bool initIsRunningInDeveloperEnvironment() const; bool initIsRunningInDeveloperEnvironment() const;
//! Init the local settings
BlackMisc::CStatusMessage initLocalSettings();
//! Async. start when setup is loaded //! Async. start when setup is loaded
BlackMisc::CStatusMessageList asyncWebAndContextStart(); BlackMisc::CStatusMessageList asyncWebAndContextStart();
@@ -624,6 +627,7 @@ namespace BlackCore
bool m_signalStartup = true; //!< signal startup automatically bool m_signalStartup = true; //!< signal startup automatically
bool m_devFlag = false; //!< dev. environment bool m_devFlag = false; //!< dev. environment
bool m_saveSettingsOnShutdown = true; //!< saving all settings on shutdown bool m_saveSettingsOnShutdown = true; //!< saving all settings on shutdown
bool m_localSettingsLoaded = false; //!< local settings loaded?
// -------------- crashpad ----------------- // -------------- crashpad -----------------
BlackMisc::CStatusMessageList initCrashHandler(); BlackMisc::CStatusMessageList initCrashHandler();