Skip to content

feat: replace Qt keywords with Q_ macros - #243

Open
18202781743 wants to merge 1 commit into
masterfrom
agent/developer/dea1631977fa
Open

18202781743 wants to merge 1 commit into
masterfrom
agent/developer/dea1631977fa

Conversation

@18202781743

@18202781743 18202781743 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Replace Qt keywords (emit/signals/slots) with Q_ macros (Q_EMIT/Q_SIGNALS/Q_SLOTS) to avoid naming conflicts with third-party libraries.

Add QT_NO_KEYWORDS compile definition in CMakeLists.txt.

Issue: DDE-499

Summary by Sourcery

Disable Qt keyword aliases and migrate signal, slot, and emission declarations to Q_ macros.

Enhancements:

  • Replace Qt keyword syntax with Q_ macros throughout the project to prevent naming conflicts with third-party libraries.

Build:

  • Define QT_NO_KEYWORDS for the main project and the keyring checker tool.

Chores:

  • Update SPDX copyright years for modified source files.

@deepin-ci-robot

Copy link
Copy Markdown

[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 Nov 2, 2026

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

Reviewer's Guide

The PR avoids Qt keyword collisions with third-party libraries by enabling QT_NO_KEYWORDS project-wide and converting affected signal, slot, and emission syntax to Qt’s Q_ macros.

File-Level Changes

Change Details Files
Disable Qt’s legacy keyword macros and migrate QObject declarations and signal emissions to the explicit Q_ forms.
  • Define QT_NO_KEYWORDS globally in CMake.
  • Replace signals and slots declarations with Q_SIGNALS and Q_SLOTS.
  • Replace emit statements with Q_EMIT in the OOM score adjustment tool.
CMakeLists.txt
src/dde-session/impl/sessionmanager.h
tools/dde-oom-score-adj/oomscoreadjuster.cpp
tools/dde-oom-score-adj/oomscoreadjuster.h
tools/dde-quick-login/lockprocessmanager.h

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

@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 ✨

@18202781743
18202781743 force-pushed the agent/developer/dea1631977fa branch 3 times, most recently from 853acc8 to e436dc1 Compare November 2, 2026 09:43
Replace emit/signals:/slots: with Q_EMIT/Q_SIGNALS:/Q_SLOTS: to avoid
naming conflicts with pure C++ or third-party libraries. Add QT_NO_KEYWORDS
compile definition after project() in CMakeLists.txt.

将 emit/signals:/slots: 替换为 Q_EMIT/Q_SIGNALS:/Q_SLOTS:,
避免纯 C++ 或第三方库引入时的命名冲突。在 CMakeLists.txt 中
添加 QT_NO_KEYWORDS 编译定义。

Log: 替换Qt关键字为宏形式并添加QT_NO_KEYWORDS编译定义
Influence: 无行为变更,仅关键字到宏的替换,解决第三方库命名冲突。
@18202781743
18202781743 force-pushed the agent/developer/dea1631977fa branch from e436dc1 to 1d4cb58 Compare November 2, 2026 10:44
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交将 Qt 小写关键字(signals/slots/emit)替换为 Q_ 宏形式(Q_SIGNALS/Q_SLOTS/Q_EMIT),并在 CMakeLists 中添加 QT_NO_KEYWORDS 编译定义以禁用小写关键字。变更属于纯重构,语法正确、逻辑无改动、无性能影响、无安全风险,三源(AI 四维度分析、启发式扫描、OCR)均无发现问题。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 无


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 无


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 无


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: 无


💡 改进建议代码示例

本次变更无需修复,代码已符合规范。Q_ 宏形式是 Qt 官方推荐的最佳实践, 可避免 signals/slots/emit 等小写关键字与其他库或代码标识符冲突。 以下为正确用法的示例:
// 头文件中 class MyClass : public QObject {
    Q_OBJECT
public Q_SLOTS:
    void doSomething();
Q_SIGNALS:
    void somethingDone();
};
// 源文件中 Q_EMIT somethingDone();

本报告由 AI 代码审查工具自动生成

@18202781743
18202781743 requested review from BLumia and mhduiy November 3, 2026 02:16
@18202781743

Copy link
Copy Markdown
Contributor Author

审查结论

未发现阻塞问题(静态审查)。

已核对:

  • 可编译代码中没有残留 foreach/forever。
  • emit、signals:、slots: 替换完整,未发现语义变化。
  • QT_NO_KEYWORDS 定义位于顶层且在子目录构建前生效。

当前完整构建任务未实际执行,建议合并前补跑构建。

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