Improve error handling of config nodes

These conditions are most likely only gonna be met during development
This commit is contained in:
Megamouse 2020-07-28 23:11:27 +02:00
parent ef3e8d26ce
commit 1c6003acd5
2 changed files with 28 additions and 3 deletions

View file

@ -500,12 +500,24 @@ QStringList emu_settings::GetSettingOptions(emu_settings_type type) const
std::string emu_settings::GetSettingDefault(emu_settings_type type) const
{
return cfg_adapter::get_node(m_defaultSettings, settings_location[type]).Scalar();
if (auto node = cfg_adapter::get_node(m_defaultSettings, settings_location[type]); node && node.IsScalar())
{
return node.Scalar();
}
cfg_log.fatal("GetSettingDefault(type=%d) could not retrieve the requested node", static_cast<int>(type));
return "";
}
std::string emu_settings::GetSetting(emu_settings_type type) const
{
return cfg_adapter::get_node(m_currentSettings, settings_location[type]).Scalar();
if (auto node = cfg_adapter::get_node(m_currentSettings, settings_location[type]); node && node.IsScalar())
{
return node.Scalar();
}
cfg_log.fatal("GetSetting(type=%d) could not retrieve the requested node", static_cast<int>(type));
return "";
}
void emu_settings::SetSetting(emu_settings_type type, const std::string& val)