fix: add serial comparison in DConfigCacheImpl::setValue#568
Conversation
|
Skipping CI for Draft Pull Request. |
There was a problem hiding this comment.
Sorry @deepin-wm, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
3ec1ea8 to
d8ad8ce
Compare
d8ad8ce to
23b7840
Compare
There was a problem hiding this comment.
Sorry @18202781743, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
1. Fix incorrect early return when checking value equality without serial comparison 2. Add DConfigInfo::checkSerial to compare both value and serial before returning false 3. Update setValue documentation to accurately describe return behavior 4. Add unit tests covering serial comparison scenarios: - Same value and same serial returns false - Same value but different serial returns true (bug fix) - Different value and same serial returns true - Different value and different serial returns true 5. Add test meta and override data files for serial testing 6. Update copyright year from 2023 to 2026 fix: 修复DConfigCache的setValue中序列号比较逻辑 1. 修正仅检查值相等就提前返回的错误逻辑 2. 增加DConfigInfo::checkSerial同时比较值和序列号 3. 更新setValue文档准确描述返回值行为 4. 添加涵盖序列号比较场景的单元测试: - 相同值和相同序列号返回false - 相同值但不同序列号返回true(bug修复) - 不同值相同序列号返回true - 不同值不同序列号返回true 5. 添加序列号测试所需的元数据和覆盖文件 6. 更新版权年份从2023到2026 Influence: 1. Test DConfig setValue when value is same but serial is updated via override 2. Verify no regression when setting different values with same or different serials 3. Validate cache update behavior matches documented return semantics 4. Ensure override layer serial changes properly trigger value updates Influence: 1. 测试当值相同但通过覆盖文件更新序列号时setValue的行为 2. 验证设置不同值(相同或不同序列号)时无回归 3. 确认缓存更新行为符合文档中的返回语义 4. 确保覆盖层序列号变化能正确触发值更新
23b7840 to
c2b27a0
Compare
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 当前代码已足够优秀,无需额外修改,此处展示其核心逻辑以供参考
bool setValue(const QString &key, const QVariant &value, const int serial, const uint uid, const QString &appid) override
{
// 双重校验:值相等且序列号未变更时,跳过无意义的更新操作
if (values.value(key) == value && DConfigInfo::checkSerial(values.serial(key), serial)) {
return false;
}
values.setValue(key, value);
// ...后续逻辑
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: deepin-wm, mhduiy The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
When the serial of a dconfig configuration is upgraded, and the user sets the same value again,
DConfigCacheImpl::setValue()only compares the value without comparing the serial. This causes the cache serial to not be updated,checkSerial()fails, and the value falls back to the default.Changes:
DConfigCacheImpl::setValue(): Added serial comparison condition — when value is the same but serial differs, the cache is forced to updatesetValue()doc comments to reflect new return value semantics:true if the cache was updated (value or serial changed), false if no update was needed