1
0
mirror of synced 2025-01-18 00:56:49 +01:00

fix: Settings values being uninitialized by default

This commit is contained in:
WerWolv 2024-03-25 20:41:05 +01:00
parent b31ae6e690
commit ce1d581c3f
2 changed files with 5 additions and 2 deletions

View File

@ -51,6 +51,9 @@ namespace hex {
if (!settings[unlocalizedCategory].contains(unlocalizedName))
settings[unlocalizedCategory][unlocalizedName] = defaultValue;
if (settings[unlocalizedCategory][unlocalizedName].is_null())
settings[unlocalizedCategory][unlocalizedName] = defaultValue;
return settings[unlocalizedCategory][unlocalizedName];
}

View File

@ -31,11 +31,11 @@ namespace hex::plugin::builtin {
for (const auto &[unlocalizedSubCategory, entries] : subCategories) {
for (const auto &[unlocalizedName, widget] : entries) {
try {
widget->load(ContentRegistry::Settings::impl::getSetting(unlocalizedCategory, unlocalizedName, widget->store()));
auto defaultValue = widget->store();
widget->load(ContentRegistry::Settings::impl::getSetting(unlocalizedCategory, unlocalizedName, defaultValue));
widget->onChanged();
} catch (const std::exception &e) {
log::error("Failed to load setting [{} / {}]: {}", unlocalizedCategory.get(), unlocalizedName.get(), e.what());
widget->store();
}
}
}