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

fix: Crash when loading invalid theme file

This commit is contained in:
WerWolv 2023-11-16 09:32:32 +01:00
parent 22eee94436
commit f00daf171b

View File

@ -29,11 +29,16 @@ namespace hex {
}
void ThemeManager::addTheme(const std::string &content) {
auto theme = nlohmann::json::parse(content);
if (theme.contains("name") && theme.contains("colors")) {
s_themes[theme["name"].get<std::string>()] = theme;
} else {
hex::log::error("Invalid theme file");
try {
auto theme = nlohmann::json::parse(content);
if (theme.contains("name") && theme.contains("colors")) {
s_themes[theme["name"].get<std::string>()] = theme;
} else {
hex::log::error("Invalid theme file");
}
} catch (const nlohmann::json::parse_error &e) {
hex::log::error("Invalid theme file: {}", e.what());
}
}