From 0c8a2fc7487e278d3b0c3f7fb25d1026677344ff Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Sun, 17 Aug 2014 09:42:22 +0100 Subject: [PATCH] Fixed settings init again. The fix in 09135350a92e775b69f17046ccbcfb3515da0736 just overwrote the existing settings file every time. --- src/gui/app.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/gui/app.cpp b/src/gui/app.cpp index cf2d3e63..883e63a5 100644 --- a/src/gui/app.cpp +++ b/src/gui/app.cpp @@ -120,8 +120,8 @@ namespace loot { string initError; //Load settings. - if (!fs::exists(g_path_settings) || !AreSettingsValid(_settings)) { - BOOST_LOG_TRIVIAL(error) << "Settings file invalid, or doesn't exist, generating new file."; + if (!fs::exists(g_path_settings)) { + BOOST_LOG_TRIVIAL(error) << "Settings file doesn't exist, generating new file."; try { fs::create_directory(g_path_settings.parent_path()); GenerateDefaultSettingsFile(g_path_settings); @@ -130,8 +130,7 @@ namespace loot { initError = "Error: Could not create local app data LOOT folder."; } } - - BOOST_LOG_TRIVIAL(info) << "Settings file found, parsing..."; + BOOST_LOG_TRIVIAL(info) << "Parsing settings file."; try { loot::ifstream in(g_path_settings); _settings = YAML::Load(in); @@ -140,6 +139,18 @@ namespace loot { catch (YAML::ParserException& e) { initError = (format(translate("Error: Settings parsing failed. %1%")) % e.what()).str(); } + if (!AreSettingsValid(_settings)) { + BOOST_LOG_TRIVIAL(error) << "Settings file invalid, generating new file."; + GenerateDefaultSettingsFile(g_path_settings); + try { + loot::ifstream in(g_path_settings); + _settings = YAML::Load(in); + in.close(); + } + catch (YAML::ParserException& e) { + initError = (format(translate("Error: Settings parsing failed. %1%")) % e.what()).str(); + } + } //Set up logging. boost::log::add_file_log(