mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-18 06:29:44 +08:00
Fix settings issue where settings.json would get reset on runner startup (#4524)
* Added flag to avoid saving before modules is initialized * Added comment
This commit is contained in:
parent
d17fc86fa4
commit
55272e5ea2
@ -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()
|
||||
|
@ -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();
|
||||
|
@ -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 ||
|
||||
|
Loading…
Reference in New Issue
Block a user