Skip to content

fix: compatibility with Qt 6.10#660

Merged
BLumia merged 1 commit into
linuxdeepin:masterfrom
felixonmars:qt-6.10
Oct 15, 2025
Merged

fix: compatibility with Qt 6.10#660
BLumia 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

我对这个git diff进行了审查,以下是分析和改进建议:

1. 语法逻辑分析

  • 代码在CMakeLists.txt中添加了对Qt6.10及以上版本的私有组件的检查条件
  • 条件判断使用了VERSION_GREATER_EQUAL操作符,这是正确的语法
  • 添加了对Qt6::GuiPrivate和Qt6::WaylandClientPrivate组件的查找

2. 代码质量

  • 优点:
    • 使用了条件判断来兼容不同版本的Qt,提高了代码的兼容性
    • 代码结构清晰,注释适当
  • 改进建议:
    • 建议在条件判断中添加明确的注释,说明为什么需要特定版本的私有组件
    • 考虑添加版本变量的记录,方便后续维护

3. 代码性能

  • 这部分代码是CMake配置代码,对运行时性能影响极小
  • 改进建议:
    • 可以考虑将版本检查提取为变量,避免重复检查
    • 例如:
      set(QT6_10_OR_LATER (Qt6_VERSION VERSION_GREATER_EQUAL 6.10))
      if(${QT6_10_OR_LATER})
        find_package(Qt6 COMPONENTS GuiPrivate REQUIRED)
      endif()

4. 代码安全

  • 优点:
    • 使用了条件判断确保只在需要的版本中查找私有组件,避免了不必要的依赖
  • 改进建议:
    • 建议添加对Qt6::GuiPrivate和Qt6::WaylandClientPrivate组件找到后的验证
    • 可以添加以下代码确保组件被正确找到:
      if(Qt6_VERSION VERSION_GREATER_EQUAL 6.10)
        find_package(Qt6 COMPONENTS GuiPrivate REQUIRED)
        if(NOT TARGET Qt6::GuiPrivate)
          message(FATAL_ERROR "Qt6::GuiPrivate not found but required")
        endif()
      endif()

5. 综合建议

  1. 添加更详细的注释,说明为什么需要特定版本的私有组件
  2. 提取版本检查为变量,提高代码可维护性
  3. 添加对找到的组件的验证
  4. 考虑添加错误处理机制,当找不到必需组件时有明确的错误提示

改进后的代码示例:

# Check for Qt version and private components
set(QT6_10_OR_LATER (Qt6_VERSION VERSION_GREATER_EQUAL 6.10))

if(${QT6_10_OR_LATER})
  # Qt6.10+ requires private components for advanced features
  find_package(Qt6 COMPONENTS GuiPrivate REQUIRED)
  find_package(Qt6 COMPONENTS WaylandClientPrivate REQUIRED)
  
  # Verify that private components are found
  if(NOT TARGET Qt6::GuiPrivate)
    message(FATAL_ERROR "Qt6::GuiPrivate not found but required for Qt6.10+")
  endif()
  if(NOT TARGET Qt6::WaylandClientPrivate)
    message(FATAL_ERROR "Qt6::WaylandClientPrivate not found but required for Qt6.10+")
  endif()
endif()

这些改进将使代码更加健壮、可维护,并提供更好的错误处理机制。

@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 merged commit f3acf55 into linuxdeepin:master Oct 15, 2025
7 of 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