Skip to content

fix(dde-apps): support GCC 16 meta-object compilation - #1736

Merged
BLumia merged 1 commit into
linuxdeepin:masterfrom
felixonmars:fix/gcc16-itemspage
Sep 14, 2026
Merged

BLumia merged 1 commit into
linuxdeepin:masterfrom
felixonmars:fix/gcc16-itemspage

Conversation

@felixonmars

@felixonmars felixonmars commented Sep 11, 2026

Copy link
Copy Markdown
Member

Tell moc to include itemspage.h for the ItemsPage* return type of AppGroupManager::groupPages(). Without its definition, Qt probes the forward-declared type in a SFINAE context before the combined MOC translation unit defines it. GCC 16 diagnoses this with -Wsfinae-incomplete, and the project's -Werror setting turns the warning into a build failure.

Q_MOC_INCLUDE keeps the ordinary header's forward declaration while making the type complete for generated metadata.

Log: Fix dde-apps builds with GCC 16

Summary by Sourcery

Bug Fixes:

  • Fix dde-apps builds with GCC 16 by ensuring Qt meta-object compilation sees the complete ItemsPage type.

Tell moc to include itemspage.h for the ItemsPage* return type of
AppGroupManager::groupPages(). Without its definition, Qt probes the
forward-declared type in a SFINAE context before the combined MOC
translation unit defines it. GCC 16 diagnoses this with
-Wsfinae-incomplete, and the project's -Werror setting turns the
warning into a build failure.

Q_MOC_INCLUDE keeps the ordinary header's forward declaration while
making the type complete for generated metadata.

Log: Fix dde-apps builds with GCC 16
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: felixonmars

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 Sep 11, 2026

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

Reviewer's Guide

Adds a Q_MOC_INCLUDE for itemspage.h so Qt’s generated meta-object code sees ItemsPage as complete during type probing, fixing GCC 16 builds without changing the ordinary header dependency model.

File-Level Changes

Change Details Files
Provide MOC with the complete ItemsPage definition while preserving the header’s forward declaration.
  • Add a Q_MOC_INCLUDE directive for itemspage.h alongside the ItemsPage forward declaration.
  • Ensure generated Qt metadata can inspect the groupPages() return type without triggering GCC 16 incomplete-type SFINAE warnings treated as errors.
applets/dde-apps/appgroupmanager.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 ✨

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

AI 代码审查报告

PR: linuxdeepin/dde-shell#1736
标题: fix(dde-apps): support GCC 16 meta-object compilation
作者: felixonmars
分支: fix/gcc16-itemspage → master
修改文件: 1 个
变更行数: +2 / -0


总体评价

总分: 100/100
评价: 代码审查通过

本次 PR 通过在 applets/dde-apps/appgroupmanager.h 中添加 Q_MOC_INCLUDE("itemspage.h") 宏,修复了 GCC 16 环境下 dde-apps 模块的 Qt MOC 元对象编译失败问题。变更极其精简(仅新增2行),目的明确,实现方式正确,是解决此类 Qt MOC 前向声明问题的标准做法。未发现任何安全漏洞或代码质量问题。


漏洞统计

指标 数量
当前漏洞总数 0
新增漏洞 0
修复漏洞 0
持平漏洞 0

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个


四维度评分

维度1: 语法逻辑 ✓ (25/25)

语法正确,逻辑清晰

分析:

本次变更在 applets/dde-apps/appgroupmanager.h 第17行添加了 Q_MOC_INCLUDE("itemspage.h") 宏调用。该宏是 Qt 5.15+ 提供的标准宏,语法使用正确。

变更背景:AppGroupManager 类(第43行)使用 Q_OBJECT 宏,其 groupPages(int groupId) 方法(第68行)返回 ItemsPage* 类型。ItemsPage 在第16行仅做前向声明(class ItemsPage;),在 MOC 生成的元对象代码中,Qt 会在 SFINAE 上下文中探测该类型,但此时类型定义尚未可见。GCC 16 的 -Wsfinae-incomplete 会诊断此情况,配合项目的 -Werror 设置导致编译失败。

Q_MOC_INCLUDE("itemspage.h") 告知 moc 工具在生成的元对象代码中包含 itemspage.h,使 ItemsPage 类型在 MOC 代码中完整可用,同时保持原头文件中的前向声明不变。这是 Qt 官方推荐的标准解决方案。

  • 无编译错误
  • 无逻辑缺陷
  • 边界处理完善

维度2: 代码质量 ✓ (25/25)

代码结构清晰,注释完整

分析:

  1. 变更最小化且聚焦——仅添加解决编译问题所需的一行宏调用,无多余改动
  2. 放置位置恰当——紧跟 class ItemsPage; 前向声明之后,namespace apps 之前,逻辑清晰
  3. 无代码重复
  4. 无残留调试代码
  5. Q_MOC_INCLUDE 是 Qt 社区广泛认知的标准宏,代码自解释性好

维度3: 代码性能 ✓ (20/20)

性能良好,资源使用合理

分析:

Q_MOC_INCLUDE 是编译时指令,仅影响 moc 工具生成的元对象代码,不产生任何运行时开销。对程序性能无任何影响。


维度4: 代码安全 ✓ (30/30)

存在0个安全漏洞

分析:

本次变更未引入任何安全风险:

  1. Q_MOC_INCLUDE 是 Qt 标准宏,非用户输入,无注入风险
  2. 包含的头文件 itemspage.h 是项目本地文件,无路径遍历风险
  3. 无硬编码密钥或敏感信息
  4. 无权限绕过或缓冲区溢出风险
  5. 无不安全密码算法使用

改进建议

本次变更质量优秀,无需改进。以下为可选的增强建议:

  1. 可在 Q_MOC_INCLUDE 行上方添加简短注释说明原因,例如:
class ItemsPage;
// GCC 16 -Wsfinae-incomplete: MOC needs the full definition for ItemsPage* return type
Q_MOC_INCLUDE("itemspage.h")

审查结论

本次 PR 通过添加 Q_MOC_INCLUDE("itemspage.h") 修复 GCC 16 编译问题,变更目的明确、实现正确、影响范围极小。代码符合"修复编译问题"的 commit 目的,无安全漏洞,四维度评分均为满分。建议合并。

@BLumia
BLumia merged commit 485ca66 into linuxdeepin:master Sep 14, 2026
7 of 10 checks passed
@felixonmars
felixonmars deleted the fix/gcc16-itemspage branch September 14, 2026 10:16
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