From 1e57c2b3f6bd2a4f1756150e669eedffc29cf13d Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Wed, 3 Jan 2018 22:29:17 +0100 Subject: Fixed crash with Settings dialog - User Configuration gets completely written, instead of being just overrides --- lib/settings/configuration.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'lib/settings/configuration.h') diff --git a/lib/settings/configuration.h b/lib/settings/configuration.h index 1909eb8..b258cb3 100644 --- a/lib/settings/configuration.h +++ b/lib/settings/configuration.h @@ -25,9 +25,11 @@ public: ~Configuration(); bool readUserConfiguration(const std::string &path); + bool parse(const std::string &contents); bool writeUserConfiguration(const std::string &path); + bool writeIfNeeded(); - bool readDefaultConfiguration(const std::string &data); + bool parseDefaultConfiguration(const std::string &contents); std::vector childrenSettings(const char *name = ""); std::vector childrenGroups(const char *name = ""); @@ -38,14 +40,12 @@ public: std::optional value(const char* path) const; template - void setValue(std::string path, const T &val); + bool setValue(std::string path, const T &val); private: - libconfig::Config* getConfig(const char* path) const; - + bool changed = false; std::string m_userCfgPath; - libconfig::Config *m_userCfg; - libconfig::Config *m_defaultCfg; + libconfig::Config *m_userCfg, *m_defaultCfg; }; // replace ~ with home @@ -71,19 +71,19 @@ extern template std::optional Configuration::value(const char* path) extern template std::optional Configuration::value(const char* path) const; // Settings::setValue<> -extern template void Configuration::setValue(std::string path, const int &val); -extern template void Configuration::setValue(std::string path, const unsigned int &val); -extern template void Configuration::setValue(std::string path, const long &val); -extern template void Configuration::setValue(std::string path, const unsigned long &val); +extern template bool Configuration::setValue(std::string path, const int &val); +extern template bool Configuration::setValue(std::string path, const unsigned int &val); +extern template bool Configuration::setValue(std::string path, const long &val); +extern template bool Configuration::setValue(std::string path, const unsigned long &val); -extern template void Configuration::setValue(std::string path, const long long &val); -extern template void Configuration::setValue(std::string path, const unsigned long long &val); +extern template bool Configuration::setValue(std::string path, const long long &val); +extern template bool Configuration::setValue(std::string path, const unsigned long long &val); -extern template void Configuration::setValue(std::string path, const float &val); -extern template void Configuration::setValue(std::string path, const double &val); +extern template bool Configuration::setValue(std::string path, const float &val); +extern template bool Configuration::setValue(std::string path, const double &val); -extern template void Configuration::setValue(std::string path, const bool &val); +extern template bool Configuration::setValue(std::string path, const bool &val); -extern template void Configuration::setValue(std::string path, const std::string &val); +extern template bool Configuration::setValue(std::string path, const std::string &val); #endif // CONFIGURATION_H -- cgit v1.2.1