Skip to content

chore: replace Qt keywords with macros (QT_NO_KEYWORDS) - #591

Open
18202781743 wants to merge 2 commits into
masterfrom
agent/bot/c3e499a90052
Open

18202781743 wants to merge 2 commits into
masterfrom
agent/bot/c3e499a90052

Conversation

@18202781743

@18202781743 18202781743 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Description

Replace Qt keywords with macro equivalents to prevent naming conflicts with third-party libraries:

  • emit → Q_EMIT
  • signals: → Q_SIGNALS:
  • slots: → Q_SLOTS:

Add QT_NO_KEYWORDS compile definition in CMake to enforce macro-only usage.

Notes

  • Vendored third-party directories (3rdparty/, libqt5xcbqpa-dev/, libqt6xcbqpa-dev/, qtwayland-dev/) are NOT modified
  • dde-qtintegration and dde-qtplatform-plugins use per-target target_compile_definitions instead of global add_compile_definitions to protect vendored code
  • Files including vendored headers with bare Qt keywords are protected with set_source_files_properties(... COMPILE_FLAGS -UQT_NO_KEYWORDS)

Issue: DDE-499

Summary by Sourcery

Adopt Qt macro equivalents throughout the project to prevent naming conflicts with third-party libraries.

Enhancements:

  • Enforce Qt keyword-free source compatibility by enabling QT_NO_KEYWORDS and replacing legacy Qt keywords and foreach usage with their macro equivalents.

Build:

  • Enable QT_NO_KEYWORDS at the project build level.

Chores:

  • Update affected test and tool source files to use Qt macro syntax while preserving vendored code compatibility.

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743

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

@sourcery-ai

sourcery-ai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Replaces Qt keywords with Q_* macro equivalents and enables QT_NO_KEYWORDS in the build, using target/source-level exceptions to avoid breaking vendored code; test coverage is updated accordingly and SPDX metadata is added to the top-level CMake file.

File-Level Changes

Change Details Files
Enforce Qt keyword-free compilation across project sources while preserving compatibility with vendored code.
  • Define QT_NO_KEYWORDS in the top-level build configuration.
  • Use per-target compile definitions in affected integration/plugin targets and undefine the setting for sources that include vendored headers requiring bare Qt keywords.
  • Replace remaining test declarations and signal emission with Q_SIGNALS and Q_EMIT.
  • Leave vendored third-party directories unchanged.
CMakeLists.txt
dde-qtintegration CMake configuration
dde-qtplatform-plugins CMake configuration
tests/fakedbus/fakedbusservice.h
tests/ut_dthreadutils.cpp
Add SPDX licensing metadata to the top-level build file.
  • Add copyright and LGPL-3.0-or-later SPDX identifiers.
CMakeLists.txt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@18202781743
18202781743 force-pushed the agent/bot/c3e499a90052 branch from d526f81 to 85b9498 Compare October 29, 2026 02:05
@18202781743
18202781743 marked this pull request as ready for review October 29, 2026 02:08
@18202781743 18202781743 changed the title feat: replace Qt keywords with macros (QT_NO_KEYWORDS) chore: replace Qt keywords with macros (QT_NO_KEYWORDS) Oct 29, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Log:
1. Replace emit/signals:/slots: with Q_EMIT/Q_SIGNALS:/Q_SLOTS: in all source and test files
2. Add QT_NO_KEYWORDS compile definition in CMake to enforce macro-only usage
3. Vendored third-party directories are not modified

Influence:
1. All affected files now use Qt macro equivalents, compatible with projects defining QT_NO_KEYWORDS
2. No functional changes, mechanical keyword replacement only

chore: 替换 Qt 关键字为宏形式(QT_NO_KEYWORDS)

Log:
1. 将所有源文件和测试文件中的 emit/signals:/slots: 替换为 Q_EMIT/Q_SIGNALS:/Q_SLOTS:
2. 在 CMake 中添加 QT_NO_KEYWORDS 编译定义,强制使用宏形式
3. 不修改 vendored 第三方目录

Influence:
1. 所有受影响文件使用 Qt 宏等价形式,兼容定义了 QT_NO_KEYWORDS 的项目
2. 无功能变更,仅为机械性关键字替换
@18202781743
18202781743 force-pushed the agent/bot/c3e499a90052 branch from 85b9498 to 91ec130 Compare October 29, 2026 02:24
@18202781743
18202781743 requested review from BLumia and mhduiy November 3, 2026 02:16
@18202781743

Copy link
Copy Markdown
Contributor Author

审查结论

阻塞:CI 已复现编译失败。

顶层启用 QT_NO_KEYWORDS 后,tools/qdbusxml2cpp/qdbusxml2cpp.cpp 中仍有 12 处 foreach(...),CI 的 container 配置报错例如:

qdbusxml2cpp.cpp:304:9: error: 'foreach' was not declared in this scope

代表位置:304、587、651、780、837、958、973、1147、1171、1216、1259、1367。

请将这些位置改为 range-for 或 Q_FOREACH。当前 8 个 container job 均因此失败,必须修复后再合并。

1. Replace all occurrences of the deprecated Qt `foreach` macro with
`Q_FOREACH` in qdbusxml2cpp.cpp
2. The `foreach` macro is a Qt keyword that can conflict with other
libraries and is not recommended in modern Qt code
3. `Q_FOREACH` is the preferred macro form that avoids namespace
pollution and keyword conflicts
4. Changes affect loop iterations in classNameForInterface, writeProxy,
and writeAdaptor functions

Influence:
1. Verify qdbusxml2cpp tool generates correct proxy and adaptor code
2. Test XML introspection file processing with multiple interfaces,
methods, signals, and properties
3. Confirm generated header and source files compile correctly
4. Validate that include handling and class name generation work as
expected
5. Test edge cases such as empty interface lists and deprecated
annotations
6. Ensure no behavioral changes in the generated output compared to
previous version

fix: 将 Qt foreach 替换为 Q_FOREACH

1. 在 qdbusxml2cpp.cpp 中将所有已弃用的 Qt `foreach` 宏替换为
`Q_FOREACH`
2. `foreach` 宏是 Qt 关键字,可能与其他库冲突,在现代 Qt 代码中不推荐
使用
3. `Q_FOREACH` 是首选的宏形式,可避免命名空间污染和关键字冲突
4. 更改影响 classNameForInterface、writeProxy 和 writeAdaptor 函数中的循
环迭代

Influence:
1. 验证 qdbusxml2cpp 工具能正确生成代理和适配器代码
2. 测试 XML 内省文件处理,涵盖多个接口、方法、信号和属性
3. 确认生成的头部和源文件能正确编译
4. 验证 include 处理和类名生成按预期工作
5. 测试空接口列表和弃用注解等边界情况
6. 确保生成输出与之前版本相比无行为变化
@18202781743

Copy link
Copy Markdown
Contributor Author

已补充提交 7965d04:将本分支非第三方代码中的 foreach( 全部替换为 Qt 提供的 Q_FOREACH((12 处),未修改 3rdparty/。

验证:本地 qdbusxml2cpp-fix 目标构建通过;全量测试目标另有一个既有 DCapFSFileEngine::beginEntryList 签名错误,与 foreach 无关;CI 仍在运行。

This branch has not been deployed

No deployments
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.

2 participants