mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Config: Handle unknown system strings better
Currently, a simple typo in the system name will trigger an assert message that complains about a "programming error". This is not user friendly and misleading. So this changes GetSystemFromName to return an std::optional, which allows for callers to check whether the system exists and handle failures better.
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <list>
|
||||
#include <optional>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
@ -40,8 +41,12 @@ public:
|
||||
std::getline(buffer, section, '.');
|
||||
std::getline(buffer, key, '=');
|
||||
std::getline(buffer, value, '=');
|
||||
Config::System system = Config::GetSystemFromName(system_str);
|
||||
m_values.emplace_back(std::make_tuple(Config::ConfigLocation{system, section, key}, value));
|
||||
const std::optional<Config::System> system = Config::GetSystemFromName(system_str);
|
||||
if (system)
|
||||
{
|
||||
m_values.emplace_back(
|
||||
std::make_tuple(Config::ConfigLocation{*system, section, key}, value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user