From 6174df0a725f07f18da43e8d2a10f937efd47799 Mon Sep 17 00:00:00 2001 From: Dydzio Date: Mon, 16 Jul 2018 22:05:42 +0200 Subject: [PATCH] Revert only launcher saving to settings.json from PR441 --- launcher/mainwindow_moc.cpp | 2 +- lib/CConfigHandler.cpp | 18 +++++++----------- lib/CConfigHandler.h | 3 +-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/launcher/mainwindow_moc.cpp b/launcher/mainwindow_moc.cpp index fe2cb90a7..a07774ed2 100644 --- a/launcher/mainwindow_moc.cpp +++ b/launcher/mainwindow_moc.cpp @@ -36,7 +36,7 @@ void MainWindow::load() QDir::addSearchPath("icons", pathToQString(string / "launcher" / "icons")); QDir::addSearchPath("icons", pathToQString(VCMIDirs::get().userDataPath() / "launcher" / "icons")); - settings.init(true); + settings.init(); } MainWindow::MainWindow(QWidget * parent) diff --git a/lib/CConfigHandler.cpp b/lib/CConfigHandler.cpp index f63d0b119..ab84b0085 100644 --- a/lib/CConfigHandler.cpp +++ b/lib/CConfigHandler.cpp @@ -51,12 +51,11 @@ SettingsStorage::NodeAccessor SettingsStorage::NodeAccessor: SettingsStorage::SettingsStorage(): write(NodeAccessor(*this, std::vector() )), - listen(NodeAccessor(*this, std::vector() )), - autoSaveConfig(false) + listen(NodeAccessor(*this, std::vector() )) { } -void SettingsStorage::init(bool autoSave) +void SettingsStorage::init() { std::string confName = "config/settings.json"; @@ -68,7 +67,6 @@ void SettingsStorage::init(bool autoSave) JsonUtils::maximize(config, "vcmi:settings"); JsonUtils::validate(config, "vcmi:settings", "settings"); - autoSaveConfig = autoSave; } void SettingsStorage::invalidateNode(const std::vector &changedPath) @@ -76,14 +74,12 @@ void SettingsStorage::invalidateNode(const std::vector &changedPath for(SettingsListener * listener : listeners) listener->nodeInvalidated(changedPath); - if(autoSaveConfig) - { - JsonNode savedConf = config; - JsonUtils::minimize(savedConf, "vcmi:settings"); + JsonNode savedConf = config; + savedConf.Struct().erase("session"); + JsonUtils::minimize(savedConf, "vcmi:settings"); - FileStream file(*CResourceHandler::get()->getResourceName(ResourceID("config/settings.json")), std::ofstream::out | std::ofstream::trunc); - file << savedConf.toJson(); - } + FileStream file(*CResourceHandler::get()->getResourceName(ResourceID("config/settings.json")), std::ofstream::out | std::ofstream::trunc); + file << savedConf.toJson(); } JsonNode & SettingsStorage::getNode(std::vector path) diff --git a/lib/CConfigHandler.h b/lib/CConfigHandler.h index 392e8594d..dad7e66ba 100644 --- a/lib/CConfigHandler.h +++ b/lib/CConfigHandler.h @@ -32,7 +32,6 @@ class DLL_LINKAGE SettingsStorage std::set listeners; JsonNode config; - bool autoSaveConfig; JsonNode & getNode(std::vector path); @@ -43,7 +42,7 @@ class DLL_LINKAGE SettingsStorage public: // Initialize config structure SettingsStorage(); - void init(bool autoSave=false); + void init(); // Get write access to config node at path const NodeAccessor write;