api: Fix various crashes on bad settings data. (#186)

getSetting now returns a straight nlohmann::json instead of an optional.
If the data isn't present, it will return a json null.

All accesses to the settings will first check that the data has the
expected type.
This commit is contained in:
Robin Lambertz
2021-03-06 12:40:29 +01:00
committed by GitHub
parent 32cfaac1e2
commit 4f98149fa7
6 changed files with 11 additions and 11 deletions

View File

@@ -20,8 +20,8 @@ namespace hex {
View::subscribeEvent(Events::SettingsChanged, [](auto) {
auto theme = ContentRegistry::Settings::getSetting("hex.builtin.setting.interface", "hex.builtin.setting.interface.color");
if (theme.has_value()) {
switch (static_cast<int>(theme.value())) {
if (theme.is_number()) {
switch (static_cast<int>(theme)) {
default:
case 0: /* Dark theme */
imnodes::StyleColorsDark();