From 99e7104b3cd93df01b2b894aaa4515e9c496c17c Mon Sep 17 00:00:00 2001 From: Mr-X-GTA <110748953+Mr-X-GTA@users.noreply.github.com> Date: Sat, 21 Sep 2024 10:17:31 +0200 Subject: [PATCH] fix(settings): fix crash (#3705) --- src/core/settings.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 40d457d4..45519c69 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -53,11 +53,15 @@ namespace big { from_json(m_options, *this); } - catch (const nlohmann::detail::type_error& e) + catch (const std::exception& e) { - LOG(WARNING) << e.what(); + file.close(); - return false; + LOG(WARNING) << "Detected incompatible settings, writing default config: " << e.what(); + + write_default_config(); + + return load(); } if (should_save) @@ -101,6 +105,12 @@ namespace big { current_settings[key] = e.value(); + should_save = true; + } + else if (current_settings[key].size() < e.value().size()) + { + current_settings[key] = e.value(); + should_save = true; } }