diff --git a/src/runner/general_settings.cpp b/src/runner/general_settings.cpp index 5ec9054667..a1f4ce357a 100644 --- a/src/runner/general_settings.cpp +++ b/src/runner/general_settings.cpp @@ -114,7 +114,7 @@ GeneralSettings get_general_settings() return settings; } -void apply_general_settings(const json::JsonObject& general_configs) +void apply_general_settings(const json::JsonObject& general_configs, bool save) { run_as_elevated = general_configs.GetNamedBoolean(L"run_elevated", false); @@ -195,9 +195,12 @@ void apply_general_settings(const json::JsonObject& general_configs) settings_theme = general_configs.GetNamedString(L"theme"); } - GeneralSettings save_settings = get_general_settings(); - PTSettingsHelper::save_general_settings(save_settings.to_json()); - Trace::SettingsChanged(save_settings); + if (save) + { + GeneralSettings save_settings = get_general_settings(); + PTSettingsHelper::save_general_settings(save_settings.to_json()); + Trace::SettingsChanged(save_settings); + } } void start_initial_powertoys() diff --git a/src/runner/general_settings.h b/src/runner/general_settings.h index d72b970d51..c0f3ecfc1e 100644 --- a/src/runner/general_settings.h +++ b/src/runner/general_settings.h @@ -21,5 +21,5 @@ struct GeneralSettings json::JsonObject load_general_settings(); GeneralSettings get_general_settings(); -void apply_general_settings(const json::JsonObject& general_configs); +void apply_general_settings(const json::JsonObject& general_configs, bool save = true); void start_initial_powertoys(); diff --git a/src/runner/main.cpp b/src/runner/main.cpp index bd6ef5000e..0d612e7b1e 100644 --- a/src/runner/main.cpp +++ b/src/runner/main.cpp @@ -376,7 +376,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine modules(); auto general_settings = load_general_settings(); - apply_general_settings(general_settings); + + // Apply the general settings but don't save it as the modules() variable has not been loaded yet + apply_general_settings(general_settings, false); int rvalue = 0; const bool elevated = is_process_elevated(); if ((elevated ||