From 642fad9a6e9c817edca1726334b08c00e7106273 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Mon, 25 Jul 2022 11:25:42 +0200 Subject: [PATCH] cfg: per-game settings must be deleted when changed back to standard When a per-game setting is the same as the standard one, it is ignored and not saved to emu.cfg. However the previously saved per-game setting wasn't deleted, making it impossible to revert. Issue #653 --- core/cfg/cfg.cpp | 5 +++++ core/cfg/cfg.h | 1 + core/cfg/option.h | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/core/cfg/cfg.cpp b/core/cfg/cfg.cpp index 6fac8905a..4a464b845 100644 --- a/core/cfg/cfg.cpp +++ b/core/cfg/cfg.cpp @@ -119,6 +119,11 @@ void cfgDeleteSection(const std::string& section) cfgdb.delete_section(section); } +void cfgDeleteEntry(const std::string& section, const std::string& key) +{ + cfgdb.delete_entry(section, key); +} + void cfgSetAutoSave(bool autoSave) { ::autoSave = autoSave; diff --git a/core/cfg/cfg.h b/core/cfg/cfg.h index 73dc8bca7..be6163ca4 100644 --- a/core/cfg/cfg.h +++ b/core/cfg/cfg.h @@ -19,3 +19,4 @@ bool ParseCommandLine(int argc, char *argv[]); void cfgSetAutoSave(bool autoSave); bool cfgHasSection(const std::string& section); void cfgDeleteSection(const std::string& section); +void cfgDeleteEntry(const std::string& section, const std::string& key); diff --git a/core/cfg/option.h b/core/cfg/option.h index 9e06b167b..97de3aa30 100644 --- a/core/cfg/option.h +++ b/core/cfg/option.h @@ -142,7 +142,11 @@ public: else if (PerGameOption && settings.hasPerGameConfig()) { if (value == doLoad(section, name)) + { + // delete existing per-game option if any + cfgDeleteEntry(settings.gameId, section + "." + name); return; + } } if (PerGameOption && settings.hasPerGameConfig()) doSave(settings.gameId, section + "." + name);