Check key existance before getting it from JSON (#1632)

This commit is contained in:
vldmr11080 2020-03-19 09:21:10 +01:00 committed by GitHub
parent 81710ff3b0
commit 57f763b0b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -207,6 +207,8 @@ void start_initial_powertoys()
try
{
general_settings = load_general_settings();
if (general_settings.HasKey(L"enabled"))
{
json::JsonObject enabled = general_settings.GetNamedObject(L"enabled");
for (const auto& enabled_element : enabled)
{
@ -218,11 +220,9 @@ void start_initial_powertoys()
}
only_enable_some_powertoys = true;
}
}
catch (...)
{
// Couldn't read the general settings correctly.
// Load all powertoys.
// TODO: notify user about invalid json config
only_enable_some_powertoys = false;
}