diff --git a/src/libslic3r/AppConfig.hpp b/src/libslic3r/AppConfig.hpp index a08c018bb2..122ca83d11 100644 --- a/src/libslic3r/AppConfig.hpp +++ b/src/libslic3r/AppConfig.hpp @@ -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 §ion, 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 §ion, 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){ diff --git a/src/slic3r/GUI/WebGuideDialog.cpp b/src/slic3r/GUI/WebGuideDialog.cpp index 350dd9d4be..ca4dec57a7 100644 --- a/src/slic3r/GUI/WebGuideDialog.cpp +++ b/src/slic3r/GUI/WebGuideDialog.cpp @@ -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(); diff --git a/tests/libslic3r/test_appconfig.cpp b/tests/libslic3r/test_appconfig.cpp index 3eb35d7490..f368636139 100644 --- a/tests/libslic3r/test_appconfig.cpp +++ b/tests/libslic3r/test_appconfig.cpp @@ -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; diff --git a/tests/slic3rutils/test_shortcuts.cpp b/tests/slic3rutils/test_shortcuts.cpp index ed7975b1e5..a93dd4c92d 100644 --- a/tests/slic3rutils/test_shortcuts.cpp +++ b/tests/slic3rutils/test_shortcuts.cpp @@ -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;