diff --git a/lib/libimhex/source/api/content_registry.cpp b/lib/libimhex/source/api/content_registry.cpp index a922e18c2..8b323fd3e 100644 --- a/lib/libimhex/source/api/content_registry.cpp +++ b/lib/libimhex/source/api/content_registry.cpp @@ -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]; } diff --git a/plugins/builtin/source/content/views/view_settings.cpp b/plugins/builtin/source/content/views/view_settings.cpp index cadf415ce..4e0092b32 100644 --- a/plugins/builtin/source/content/views/view_settings.cpp +++ b/plugins/builtin/source/content/views/view_settings.cpp @@ -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(); } } }