From 84a1f6d72be581e4d57071f3b77314360cce5c4a Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 23 Feb 2013 15:34:47 +0100 Subject: [PATCH] configfile: set the modified flag correctly on set*Vector methods Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/07a8027b4d99f3dda11944dcdc226a7a6cb3adfd Author: Stefan Seyfried Date: 2013-02-23 (Sat, 23 Feb 2013) --- lib/libconfigfile/configfile.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/libconfigfile/configfile.cpp b/lib/libconfigfile/configfile.cpp index 52830b3c0..67848ead5 100644 --- a/lib/libconfigfile/configfile.cpp +++ b/lib/libconfigfile/configfile.cpp @@ -387,6 +387,9 @@ void CConfigFile::setString(const std::string & key, const std::string & val) void CConfigFile::setInt32Vector(const std::string & key, const std::vector vec) { + bool tmpUnknownKeyQueryedFlag = unknownKeyQueryedFlag; + unknownKeyQueryedFlag = false; + std::string oldVal = getString(key); std::stringstream s; for (std::vector::const_iterator it = vec.begin(); ; ) @@ -399,21 +402,35 @@ void CConfigFile::setInt32Vector(const std::string & key, const std::vector> configData[key]; + if (oldVal != s.str() || unknownKeyQueryedFlag) + { + modifiedFlag = true; + configData[key] = s.str(); + } + unknownKeyQueryedFlag = tmpUnknownKeyQueryedFlag; } void CConfigFile::setStringVector(const std::string & key, const std::vector vec) { - configData[key] = ""; + bool tmpUnknownKeyQueryedFlag = unknownKeyQueryedFlag; + unknownKeyQueryedFlag = false; + std::string oldVal = getString(key); + std::string newVal = ""; for (std::vector::const_iterator it = vec.begin(); ; ) { if (it == vec.end()) break; - configData[key] += *it; + newVal += *it; ++it; if (it == vec.end()) break; - configData[key] += delimiter; + newVal += delimiter; } + if (oldVal != newVal || unknownKeyQueryedFlag) + { + modifiedFlag = true; + configData[key] = newVal; + } + unknownKeyQueryedFlag = tmpUnknownKeyQueryedFlag; }