mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-01-24 13:39:02 -06:00
fix: Crash when loading invalid theme file
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user