Skip to content

Commit d8ad8ce

Browse files
deepin-wmagent
authored andcommitted
fix: add serial comparison in DConfigCacheImpl::setValue
1. Add serial comparison condition to setValue() so cache is updated when serial differs even if value is the same 2. Update two setValue() doc comments to reflect new return value semantics Log: Fixed dconfig write failure after serial upgrade Influence: 1. Test dconfig setValue with same value but different serial 2. Verify cache updates correctly when serial changes 3. Test that setValue returns false only when both value and serial match fix: DConfigCacheImpl::setValue增加serial比较条件 1. setValue()方法增加serial比较条件,当serial不一致时 强制更新缓存 2. 更新两处setValue()文档注释,说明返回值的新语义 Log: 修复dconfig serial升级后写入相同值失败的问题 Influence: 1. 测试dconfig在serial不同但值相同时的setValue行为 2. 验证serial变更时缓存是否正确更新 3. 测试setValue仅在值和serial都匹配时返回false
1 parent 35a315f commit d8ad8ce

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/dconfigfile.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2021 - 2023 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2021 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: LGPL-3.0-or-later
44

@@ -985,7 +985,7 @@ DConfigMetaImpl::~DConfigMetaImpl()
985985
\a value Configuration name
986986
\a uid User Id at setup time
987987
\a callerAppid Application id at setup time
988-
@return A value of true indicates that the new value has been reset, and false indicates that it has not been set
988+
@return true if the cache was updated (value or serial changed), false if no update was needed
989989
*/
990990

991991
/*!
@@ -1124,7 +1124,7 @@ class Q_DECL_HIDDEN DConfigCacheImpl : public DConfigCache {
11241124
}
11251125
bool setValue(const QString &key, const QVariant &value, const int serial, const uint uid, const QString &appid) override
11261126
{
1127-
if (values.value(key) == value) {
1127+
if (values.value(key) == value && values.serial(key) == serial) {
11281128
return false;
11291129
}
11301130
values.setValue(key, value);
@@ -1487,7 +1487,7 @@ QVariant DConfigFile::cacheValue(DConfigCache *userCache, const QString &key) co
14871487
\a value The value to set
14881488
\a userCache Specific user cache at setup time
14891489
\a appid Application id at setup time
1490-
@return A value of true indicates that the new value has been reset, and false indicates that it has not been set
1490+
@return true if the cache was updated (value or serial changed), false if no update was needed
14911491
*/
14921492
bool DConfigFile::setValue(const QString &key, const QVariant &value, const QString &callerAppid, DConfigCache *userCache)
14931493
{

0 commit comments

Comments
 (0)