Fix AppConfig text persistence and section-specific boolean reads (#16092)

This commit is contained in:
TheLegendTubaGuy
2026-10-03 20:27:44 -03:00
committed by GitHub
parent 5e2d8ab4f0
commit 32b1e69fdd
4 changed files with 30 additions and 3 deletions
+4 -1
View File
@@ -163,7 +163,7 @@ public:
std::string get(const std::string &key) const
{ std::string value; this->get("app", key, value); return value; }
bool get_bool(const std::string &section, const std::string &key) const
{ return this->get(section, key) == "true" || this->get(key) == "1"; }
{ const std::string value = this->get(section, key); return value == "true" || value == "1"; }
bool get_bool(const std::string &key) const
{ return this->get_bool("app", key); }
void set(const std::string &section, const std::string &key, const std::string &value)
@@ -200,6 +200,9 @@ public:
}
}
void set(const std::string& section, const std::string& key, const char* value)
{ this->set(section, key, std::string(value)); }
void set(const std::string& section, const std::string &key, bool value)
{
if (value){
+1 -1
View File
@@ -835,7 +835,7 @@ int GuideFrame::SaveProfile()
m_MainPtr->app_config->set_bool("stealth_mode", StealthMode);
//finish
m_MainPtr->app_config->set(std::string(m_SectionName.mb_str()), "finish", "1");
m_MainPtr->app_config->set(std::string(m_SectionName.mb_str()), "finish", true);
m_MainPtr->app_config->save();
+25
View File
@@ -45,6 +45,31 @@ TEST_CASE("AppConfig network version helpers", "[AppConfig]") {
}
}
TEST_CASE("Remembered checkbox settings retain both selections", "[AppConfig][Regression]") {
AppConfig config;
const bool checked = GENERATE(false, true);
config.set("recent", "checkbox", checked ? "1" : "0");
CHECK(config.get("recent", "checkbox") == (checked ? "1" : "0"));
}
TEST_CASE("Boolean setters retain their established encoding", "[AppConfig][Regression]") {
AppConfig config;
const bool value = GENERATE(false, true);
config.set("recent", "flag", value);
CHECK(config.get("recent", "flag") == (value ? "true" : "false"));
}
TEST_CASE("Boolean reads use only the requested section", "[AppConfig][Regression]") {
AppConfig config;
const bool value = GENERATE(false, true);
config.set("recent", "flag", std::string(value ? "1" : "0"));
config.set("app", "flag", std::string(value ? "0" : "1"));
CHECK(config.get_bool("recent", "flag") == value);
}
TEST_CASE("AppConfig Speed Dial recent count defaults, clamps and parses", "[AppConfig]") {
AppConfig config;
-1
View File
@@ -327,7 +327,6 @@ TEST_CASE("Custom bindings replace the default and survive a config round trip",
TEST_CASE("A Global shortcut refuses a config binding that would swallow typing", "[Shortcuts]")
{
AppConfig config;
// A string literal would pick AppConfig::set's bool overload.
config.set("shortcuts", "save_project", std::string("S"));
config.set("shortcuts", "new_project", std::string("F9"));
ShortcutRegistry registry;