From b4411b9fd05760433c8b15b3a9baa1dbe788a1f0 Mon Sep 17 00:00:00 2001
From: tangjie02 <tangjie02@kylinsec.com.cn>
Date: Thu, 10 Aug 2023 15:55:34 +0800
Subject: [PATCH] fix(xsettings): Fix the problem that variable serial isn't
 increased when xsettings registry property is updated.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- 修复当xsettings registry属性变化时serial变量未递增问题

Related #11637

Signed-off-by: tangjie02 <tangjie02@kylinsec.com.cn>
---
 plugins/xsettings/xsettings-registry.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/plugins/xsettings/xsettings-registry.cpp b/plugins/xsettings/xsettings-registry.cpp
index 13472de..4d76599 100644
--- a/plugins/xsettings/xsettings-registry.cpp
+++ b/plugins/xsettings/xsettings-registry.cpp
@@ -209,19 +209,19 @@ bool XSettingsRegistry::init()
 
 bool XSettingsRegistry::update(const std::string &name, int32_t value)
 {
-    auto var = std::make_shared<XSettingsPropertyInt>(name, value);
+    auto var = std::make_shared<XSettingsPropertyInt>(name, value, this->serial_);
     return this->update(var);
 }
 
 bool XSettingsRegistry::update(const std::string &name, const Glib::ustring &value)
 {
-    auto var = std::make_shared<XSettingsPropertyString>(name, value.raw());
+    auto var = std::make_shared<XSettingsPropertyString>(name, value.raw(), this->serial_);
     return this->update(var);
 }
 
 bool XSettingsRegistry::update(const std::string &name, const XSettingsColor &value)
 {
-    auto var = std::make_shared<XSettingsPropertyColor>(name, value);
+    auto var = std::make_shared<XSettingsPropertyColor>(name, value, this->serial_);
     return this->update(var);
 }
 
@@ -282,6 +282,7 @@ bool XSettingsRegistry::notify()
     data.append(std::string("\0\0\0", 3));
     data.append(std::string((char *)&this->serial_, 4));
     data.append(std::string((char *)&nsettings, 4));
+    ++this->serial_;
 
     // 填充body
     for (const auto &iter : this->properties_)
@@ -310,4 +311,4 @@ char XSettingsRegistry::byte_order()
     return (*(char *)&myint == 1) ? MSBFirst : LSBFirst;
 }
 
-}  // namespace Kiran
\ No newline at end of file
+}  // namespace Kiran
-- 
2.36.1

