mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-08 16:01:42 +12:00
Qt: Remove unused GUI entries when saving a config
This commit is contained in:
parent
8d54453981
commit
a7acb84b8b
6 changed files with 90 additions and 21 deletions
|
@ -174,10 +174,12 @@ void emu_settings::LoadSettings(const std::string& title_id)
|
|||
}
|
||||
}
|
||||
|
||||
void emu_settings::ValidateSettings()
|
||||
bool emu_settings::ValidateSettings(bool cleanup)
|
||||
{
|
||||
std::function<void(int, const YAML::Node&, std::vector<std::string>&, cfg::_base*)> search_level;
|
||||
search_level = [&search_level](int level, const YAML::Node& yml_node, std::vector<std::string>& keys, cfg::_base* cfg_base)
|
||||
bool is_clean = true;
|
||||
|
||||
std::function<void(int, YAML::Node&, std::vector<std::string>&, cfg::_base*)> search_level;
|
||||
search_level = [&search_level, &is_clean, &cleanup, this](int level, YAML::Node& yml_node, std::vector<std::string>& keys, cfg::_base* cfg_base)
|
||||
{
|
||||
if (!yml_node || !yml_node.IsMap())
|
||||
{
|
||||
|
@ -208,30 +210,59 @@ void emu_settings::ValidateSettings()
|
|||
|
||||
if (cfg_node)
|
||||
{
|
||||
search_level(next_level, yml_node[key], keys, cfg_node);
|
||||
YAML::Node next_node = yml_node[key];
|
||||
search_level(next_level, next_node, keys, cfg_node);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string key;
|
||||
for (usz i = 0; i < keys.size(); i++)
|
||||
const auto get_full_key = [&keys](const std::string& seperator) -> std::string
|
||||
{
|
||||
key += keys[i];
|
||||
if (i < keys.size() - 1) key += ": ";
|
||||
std::string full_key;
|
||||
for (usz i = 0; i < keys.size(); i++)
|
||||
{
|
||||
full_key += keys[i];
|
||||
if (i < keys.size() - 1) full_key += seperator;
|
||||
}
|
||||
return full_key;
|
||||
};
|
||||
|
||||
is_clean = false;
|
||||
|
||||
if (cleanup)
|
||||
{
|
||||
if (!yml_node.remove(key))
|
||||
{
|
||||
cfg_log.error("Could not remove config entry: %s", get_full_key(": "));
|
||||
is_clean = true; // abort
|
||||
return;
|
||||
}
|
||||
|
||||
// Let's only remove one entry at a time. I got some weird issues when doing all at once.
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg_log.warning("Unknown config entry found: %s", get_full_key(": "));
|
||||
}
|
||||
cfg_log.warning("Unknown config entry found: %s", key);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
cfg_root root;
|
||||
std::vector<std::string> keys;
|
||||
search_level(0, m_current_settings, keys, &root);
|
||||
|
||||
do
|
||||
{
|
||||
is_clean = true;
|
||||
search_level(0, m_current_settings, keys, &root);
|
||||
}
|
||||
while (cleanup && !is_clean);
|
||||
|
||||
return is_clean;
|
||||
}
|
||||
|
||||
void emu_settings::SaveSettings()
|
||||
{
|
||||
ValidateSettings();
|
||||
|
||||
YAML::Emitter out;
|
||||
emit_data(out, m_current_settings);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue