From 700a216ec945bc93a9462d4a6d0dc173d41a15d0 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 25 May 2023 16:19:11 +0200 Subject: [PATCH] Forget that attribute is modified if it's changed back to its original state refs #7986 --- lib/base/configobject.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/base/configobject.cpp b/lib/base/configobject.cpp index 4317771d1f8..6b851d4fc72 100644 --- a/lib/base/configobject.cpp +++ b/lib/base/configobject.cpp @@ -174,8 +174,17 @@ void ConfigObject::ModifyAttribute(const String& attr, const Value& value, bool original_attributes->Set(key, Empty); } } - } else if (!original_attributes->Contains(attr)) - original_attributes->Set(attr, oldValue); + } else { + Value originalAttribute; + + if (original_attributes->Get(attr, &originalAttribute)) { + if (JsonEncode(value) == JsonEncode(originalAttribute)) { + original_attributes->Remove(attr); + } + } else { + original_attributes->Set(attr, oldValue); + } + } } dict->Set(key, value); @@ -183,7 +192,14 @@ void ConfigObject::ModifyAttribute(const String& attr, const Value& value, bool newValue = value; if (field.Attributes & FAConfig) { - if (!original_attributes->Contains(attr)) { + Value originalAttribute; + + if (original_attributes->Get(attr, &originalAttribute)) { + if (JsonEncode(value) == JsonEncode(originalAttribute)) { + updated_original_attributes = true; + original_attributes->Remove(attr); + } + } else { updated_original_attributes = true; original_attributes->Set(attr, oldValue); }