diff --git a/src/blackcore/application.cpp b/src/blackcore/application.cpp index d747e94d7..8ee118122 100644 --- a/src/blackcore/application.cpp +++ b/src/blackcore/application.cpp @@ -523,9 +523,9 @@ namespace BlackCore return !this->getUnsavedSettingsKeys().isEmpty(); } - void CApplication::setSettingsAutoSave(bool autoSave) + void CApplication::saveSettingsOnShutdown(bool saveSettings) { - m_autoSaveSettings = autoSave; + m_saveSettingsOnShutdown = saveSettings; } QStringList CApplication::getUnsavedSettingsKeys() const @@ -948,18 +948,11 @@ namespace BlackCore m_shutdown = true; // save settings (but only when application was really alive) - CStatusMessage m; - if (m_parsed) + if (m_parsed && m_saveSettingsOnShutdown) { - if (this->supportsContexts() && m_autoSaveSettings) - { - // this will eventually also call saveToStore - m = this->getIContextApplication()->saveSettings(); - } - else - { - m = CSettingsCache::instance()->saveToStore(); - } + const CStatusMessage m = this->supportsContexts() ? + this->getIContextApplication()->saveSettings() : + CSettingsCache::instance()->saveToStore(); CLogMessage(getLogCategories()).preformatted(m); } diff --git a/src/blackcore/application.h b/src/blackcore/application.h index b9c527dd0..d075cdc19 100644 --- a/src/blackcore/application.h +++ b/src/blackcore/application.h @@ -221,8 +221,8 @@ namespace BlackCore //! Unsaved settings bool hasUnsavedSettings() const; - //! Automatically and always save settings - void setSettingsAutoSave(bool autoSave); + //! Save settings on shutdown + void saveSettingsOnShutdown(bool saveSettings); //! All unsaved settings QStringList getUnsavedSettingsKeys() const; @@ -598,25 +598,25 @@ namespace BlackCore //! Write meta information into the application directory so other swift versions can display them void tagApplicationDataDirectory(); - QNetworkAccessManager *m_accessManager = nullptr; //!< single network access manager - BlackMisc::CApplicationInfo m_applicationInfo; //!< Application if specified - QScopedPointer m_coreFacade; //!< core facade if any - QScopedPointer m_setupReader; //!< setup reader - QScopedPointer m_webDataServices; //!< web data services - QScopedPointer m_networkWatchDog; //!< checking DB/internet access - QScopedPointer m_fileLogger; //!< file logger - CCookieManager m_cookieManager; //!< single cookie manager for our access manager - const QString m_applicationName; //!< application name - QReadWriteLock m_accessManagerLock; //!< lock to make access manager access threadsafe - CCoreFacadeConfig m_coreFacadeConfig; //!< Core facade config if any - CWebReaderFlags::WebReader m_webReadersUsed; //!< Readers to be used - Db::CDatabaseReaderConfigList m_dbReaderConfig; //!< Load or used caching? - std::atomic m_shutdown { false }; //!< is being shutdown? - bool m_useContexts = false; //!< use contexts - bool m_useWebData = false; //!< use web data - bool m_signalStartup = true; //!< signal startup automatically - bool m_devEnv = false; //!< dev. environment - bool m_autoSaveSettings = true; //!< automatically saving all settings + QNetworkAccessManager *m_accessManager = nullptr; //!< single network access manager + BlackMisc::CApplicationInfo m_applicationInfo; //!< Application if specified + QScopedPointer m_coreFacade; //!< core facade if any + QScopedPointer m_setupReader; //!< setup reader + QScopedPointer m_webDataServices; //!< web data services + QScopedPointer m_networkWatchDog; //!< checking DB/internet access + QScopedPointer m_fileLogger; //!< file logger + CCookieManager m_cookieManager; //!< single cookie manager for our access manager + const QString m_applicationName; //!< application name + QReadWriteLock m_accessManagerLock; //!< lock to make access manager access threadsafe + CCoreFacadeConfig m_coreFacadeConfig; //!< Core facade config if any + CWebReaderFlags::WebReader m_webReadersUsed; //!< Readers to be used + Db::CDatabaseReaderConfigList m_dbReaderConfig; //!< Load or used caching? + std::atomic m_shutdown { false }; //!< is being shutdown? + bool m_useContexts = false; //!< use contexts + bool m_useWebData = false; //!< use web data + bool m_signalStartup = true; //!< signal startup automatically + bool m_devEnv = false; //!< dev. environment + bool m_saveSettingsOnShutdown = true; //!< saving all settings on shutdown // -------------- crashpad ----------------- BlackMisc::CStatusMessageList initCrashHandler(); diff --git a/src/blackgui/guiapplication.h b/src/blackgui/guiapplication.h index 8fc3742a3..607c96f0b 100644 --- a/src/blackgui/guiapplication.h +++ b/src/blackgui/guiapplication.h @@ -189,6 +189,7 @@ namespace BlackGui virtual bool parseAndSynchronizeSetup(int timeoutMs = BlackMisc::Network::CNetworkUtils::getLongTimeoutMs()) override; //! Show close dialog + //! \remark will modify CApplication::saveSettingsOnShutdown QDialog::DialogCode showCloseDialog(QMainWindow *mainWindow, QCloseEvent *closeEvent); //! Trigger new version check diff --git a/src/swiftdata/swiftdata.cpp b/src/swiftdata/swiftdata.cpp index 4315a527d..5416467ed 100644 --- a/src/swiftdata/swiftdata.cpp +++ b/src/swiftdata/swiftdata.cpp @@ -73,7 +73,7 @@ void CSwiftData::closeEvent(QCloseEvent *event) { if (sGui) { - // save settings + // save settings? if (sGui->showCloseDialog(this, event) == QDialog::Rejected) { return; } } this->performGracefulShutdown();