From 0d2ea6223b06ceb9151df0e57ee9a69772529226 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 16 Jun 2021 17:28:16 +0100 Subject: [PATCH] Don't throw in a release build if the "keep" namespace is missing. Fixes https://gitlab.com/kicad/code/kicad/issues/8618 --- common/settings/settings_manager.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/common/settings/settings_manager.cpp b/common/settings/settings_manager.cpp index a2a2dd9d75..c34f2a8839 100644 --- a/common/settings/settings_manager.cpp +++ b/common/settings/settings_manager.cpp @@ -332,21 +332,24 @@ void SETTINGS_MANAGER::SaveColorSettings( COLOR_SETTINGS* aSettings, const std:: if( !aSettings->Store() ) { wxLogTrace( traceSettings, "Color scheme %s not modified; skipping save", - aSettings->GetFilename(), aNamespace ); + aNamespace ); return; } wxASSERT( aSettings->Contains( aNamespace ) ); - wxLogTrace( traceSettings, "Saving color scheme %s, preserving %s", aSettings->GetFilename(), + wxLogTrace( traceSettings, "Saving color scheme %s, preserving %s", + aSettings->GetFilename(), aNamespace ); - nlohmann::json backup = aSettings->At( aNamespace ); + OPT backup = aSettings->GetJson( aNamespace ); wxString path = GetColorSettingsPath(); aSettings->LoadFromFile( path ); - ( *aSettings->Internals() )[aNamespace].update( backup ); + if( backup ) + ( *aSettings->Internals() )[aNamespace].update( *backup ); + aSettings->Load(); aSettings->SaveToFile( path, true );