Skip to content

fix: compatibility with Qt 6.10#373

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
felixonmars:qt-6.10
Oct 15, 2025
Merged

fix: compatibility with Qt 6.10#373
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
felixonmars:qt-6.10

Conversation

@felixonmars

Copy link
Copy Markdown
Member

Credits to Antonio Rojas from Arch Linux.

Credits to Antonio Rojas from Arch Linux.

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

Sorry @felixonmars, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

这段代码是一个CMakeLists.txt文件,主要处理Qt和Deepin工具包(DFLTK/DTK)的依赖关系。我来分析一下这段代码并提出改进意见:

语法逻辑

  • 语法没有问题,CMake的条件判断语法使用正确
  • 变量引用方式正确,使用了Qt版本变量${QT_VERSION_MAJOR}

代码质量

  • 代码结构清晰,依赖声明有序
  • 条件判断逻辑合理,针对Qt 6.10及以上版本添加额外的私有依赖

代码性能

  • 没有性能问题,CMake在配置阶段执行这些查找操作对构建性能影响很小

代码安全

  • 没有明显的安全问题

改进建议

  1. 版本兼容性处理

    • 当前代码只处理了Qt 6.10+的情况,建议添加注释说明为什么需要这个条件判断,以及这些私有API的用途
    • 可以考虑为更早的Qt版本提供替代方案或明确的错误提示
  2. 错误处理

    • 添加find_package失败时的错误处理,确保在依赖缺失时提供有意义的错误信息
    • 例如:
    if(NOT Qt${QT_VERSION_MAJOR}_GuiPrivate_FOUND)
      message(FATAL_ERROR "Qt GuiPrivate is required but not found")
    endif()
  3. 版本检查的健壮性

    • 考虑使用更严格的版本比较方式,例如:
    if(Qt${QT_VERSION_MAJOR}_VERSION VERSION_GREATER_EQUAL "6.10.0")

    这样可以避免可能的版本号解析问题

  4. 依赖管理

    • 考虑将依赖项分组,将必需依赖和可选依赖明确分开
    • 添加注释说明每个依赖包的具体用途
  5. 代码可读性

    • 添加注释说明为什么需要Qt 6.10+的特殊处理
    • 说明这些私有API在项目中的具体用途

改进后的代码可能如下:

# 查找Qt基本组件
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui WaylandClient)

# Qt 6.10+需要额外的私有API支持某些Wayland集成功能
if(Qt${QT_VERSION_MAJOR}_VERSION VERSION_GREATER_EQUAL "6.10.0")
  message(STATUS "Using Qt 6.10+ private APIs for Wayland integration")
  find_package(Qt${QT_VERSION_MAJOR} COMPONENTS GuiPrivate WaylandClientPrivate REQUIRED)
  if(NOT Qt${QT_VERSION_MAJOR}_GuiPrivate_FOUND OR NOT Qt${QT_VERSION_MAJOR}_WaylandClientPrivate_FOUND)
    message(FATAL_ERROR "Qt 6.10+ requires GuiPrivate and WaylandClientPrivate components")
  endif()
endif()

# 查找Deepin工具包
find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED COMPONENTS Gui Widget)

# 查找ECM模块
find_package(ECM REQUIRED MO_MODULE)

这样的改进提高了代码的可维护性和可读性,同时增强了错误处理能力。

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BLumia, 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

@BLumia

BLumia commented Oct 15, 2025

Copy link
Copy Markdown
Member

/merge

@deepin-bot deepin-bot Bot merged commit d9be456 into linuxdeepin:master Oct 15, 2025
9 checks passed
@felixonmars felixonmars deleted the qt-6.10 branch October 15, 2025 01:44
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