Skip to content

fix: prevent theme saving when DontSaveApplicationTheme is set#315

Merged
deepin-bot[bot] merged 2 commits intolinuxdeepin:masterfrom
18202781743:master
May 8, 2025
Merged

fix: prevent theme saving when DontSaveApplicationTheme is set#315
deepin-bot[bot] merged 2 commits intolinuxdeepin:masterfrom
18202781743:master

Conversation

@18202781743
Copy link
Copy Markdown
Contributor

  • fix: prevent theme saving when DontSaveApplicationTheme is set
  • fix: correct bitwise operation in preference handling

Added a condition to check DontSaveApplicationTheme attribute before
saving theme type to config
This prevents unwanted theme persistence when the application explicitly
requests not to save theme preferences
The change maintains backward compatibility while respecting the
application's preference flag

fix: 当设置DontSaveApplicationTheme时阻止主题保存

在将主题类型保存到配置前添加了检查DontSaveApplicationTheme属性的条件
这可以防止当应用程序明确要求不保存主题偏好时进行不必要的主题持久化
该改动在尊重应用程序偏好标志的同时保持了向后兼容性
1. Fixed incorrect bitwise AND operation in OrgDeepinDTKPreference class
2. Changed `fetchAndAndOrdered(1 << (index - 0))` to
`fetchAndAndOrdered(~(1 << (index - 0)))`
3. This ensures proper bit clearing operation when updating property
status flags
4. The original code would incorrectly set bits instead of clearing them

fix: 修复偏好设置处理中的位操作错误

1. 修正了 OrgDeepinDTKPreference 类中错误的位与操作
2. 将 `fetchAndAndOrdered(1 << (index - 0))` 改为
`fetchAndAndOrdered(~(1 << (index - 0)))`
3. 确保在更新属性状态标志时正确的位清除操作
4. 原代码会错误地设置位而不是清除它们
@18202781743 18202781743 requested review from BLumia and mhduiy May 8, 2025 09:33
@18202781743 18202781743 changed the title master fix: prevent theme saving when DontSaveApplicationTheme is set May 8, 2025
deepin-ci-robot added a commit to linuxdeepin/dtk6gui that referenced this pull request May 8, 2025
Synchronize source files from linuxdeepin/dtkgui.

Source-pull-request: linuxdeepin/dtkgui#315
@deepin-ci-robot
Copy link
Copy Markdown
Contributor

deepin pr auto review

代码审查意见:

  1. dguiapplicationhelper.cpp文件中,新增了一个条件判断来决定是否调用_d_dconfig->setThemeType。这个改动是合理的,因为它增加了灵活性,允许在不保存主题的情况下执行其他操作。但是,应该确保这个条件判断的合理性,即DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::DontSaveApplicationTheme)的返回值是经过充分测试和验证的。

  2. orgdeepindtkpreference.hpp文件中,m_propertySetStatus0.fetchAndAndOrdered函数的参数从1 << (index - 0)变为了~(1 << (index - 0))。这个改动改变了逻辑,因为~(1 << (index - 0))会清除对应位置的位,而原来的1 << (index - 0)只会设置对应位置的位。这个改动可能会影响程序的行为,需要确认这是否是预期的行为,并且相关的逻辑是否已经更新以适应这个变化。

  3. 两个文件的修改都没有明显的语法错误,但是应该确保所有的修改都已经通过了单元测试,并且没有引入新的bug。

  4. 代码注释应该更新以反映最新的修改,特别是在orgdeepindtkpreference.hpp文件中,生成时间的注释应该更新为最新的时间戳。

  5. 代码风格应该保持一致,特别是在orgdeepindtkpreference.hpp文件中,注释的格式应该与其他注释保持一致。

  6. 如果DGuiApplicationHelper::testAttribute函数的返回值依赖于外部状态,应该确保这个状态在调用setPaletteType方法之前已经被正确设置,以避免潜在的竞态条件。

  7. 如果DGuiApplicationHelper::DontSaveApplicationTheme是一个枚举值,应该确保在调用testAttribute方法时传递的是正确的枚举值。

  8. 如果_d_dconfig->setThemeType方法有副作用(例如,它会修改全局状态),应该确保这个方法在多线程环境下是线程安全的,或者在使用时考虑加锁。

  9. 如果m_propertySetStatus0是一个共享资源,应该确保在修改它的值时使用适当的同步机制,以避免数据竞争。

  10. 如果m_propertySetStatus0是一个位掩码,应该确保在清除位时使用正确的操作,即~(1 << (index - 0)),而不是1 << (index - 0)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2025

  • 敏感词检查失败, 检测到1个文件存在敏感词
详情
{
    "src/kernel/dguiapplicationhelper.cpp": [
        {
            "line": "    QString socket_key = \"_d_dtk_single_instance_\";",
            "line_number": 1468,
            "rule": "S106",
            "reason": "Var naming | 2ad926d35b"
        }
    ]
}

@deepin-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, mhduiy

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@18202781743
Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot
Copy link
Copy Markdown
Contributor

deepin-bot Bot commented May 8, 2025

This pr force merged! (status: blocked)

@deepin-bot deepin-bot Bot merged commit 6d6a4a4 into linuxdeepin:master May 8, 2025
20 of 24 checks passed
18202781743 pushed a commit to linuxdeepin/dtk6gui that referenced this pull request May 8, 2025
Synchronize source files from linuxdeepin/dtkgui.

Source-pull-request: linuxdeepin/dtkgui#315
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants