Skip to content

Conversation

@fly602
Copy link
Contributor

@fly602 fly602 commented Dec 5, 2025

Added conditional compilation guards around cursor context management code that is specific to Qt6. The m_cursorContext member only exists in Qt6 version, so accessing it in Qt5 builds would cause compilation errors. This fix ensures the code only compiles the Qt6-specific cursor context cleanup and reinitialization when building with Qt6 or later.

The changes include:

  1. Wrapping cursor context freeing and reinitialization with #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
  2. Added comment noting that m_cursorContext only exists in Qt6
  3. Properly guards against accessing Qt6-specific APIs in Qt5 builds

Influence:

  1. Verify application compiles successfully with both Qt5 and Qt6
  2. Test cursor functionality remains working in both Qt versions
  3. Confirm cursor theme changes are properly handled in Qt6 builds
  4. Validate no memory leaks in cursor context management for Qt6

fix: 为光标上下文处理添加 Qt6 版本保护

添加了条件编译保护,围绕特定于 Qt6 的光标上下文管理代码。m_cursorContext
成员仅存在于 Qt6 版本中,因此在 Qt5 构建中访问它会导致编译错误。此修复
确保代码仅在 Qt6 或更高版本构建时编译 Qt6 特定的光标上下文清理和重新初
始化。

更改包括:

  1. 使用 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 包装光标上下文释放和 重新初始化
  2. 添加注释说明 m_cursorContext 仅存在于 Qt6
  3. 在 Qt5 构建中正确防止访问 Qt6 特定 API

Influence:

  1. 验证应用程序在 Qt5 和 Qt6 下都能成功编译
  2. 测试光标功能在两个 Qt 版本中保持正常工作
  3. 确认在 Qt6 构建中光标主题更改得到正确处理
  4. 验证 Qt6 中光标上下文管理没有内存泄漏

Added conditional compilation guards around cursor context management
code that is specific to Qt6. The m_cursorContext member only exists
in Qt6 version, so accessing it in Qt5 builds would cause compilation
errors. This fix ensures the code only compiles the Qt6-specific cursor
context cleanup and reinitialization when building with Qt6 or later.

The changes include:
1. Wrapping cursor context freeing and reinitialization with #if
QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
2. Added comment noting that m_cursorContext only exists in Qt6
3. Properly guards against accessing Qt6-specific APIs in Qt5 builds

Influence:
1. Verify application compiles successfully with both Qt5 and Qt6
2. Test cursor functionality remains working in both Qt versions
3. Confirm cursor theme changes are properly handled in Qt6 builds
4. Validate no memory leaks in cursor context management for Qt6

fix: 为光标上下文处理添加 Qt6 版本保护

添加了条件编译保护,围绕特定于 Qt6 的光标上下文管理代码。m_cursorContext
成员仅存在于 Qt6 版本中,因此在 Qt5 构建中访问它会导致编译错误。此修复
确保代码仅在 Qt6 或更高版本构建时编译 Qt6 特定的光标上下文清理和重新初
始化。

更改包括:
1. 使用 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 包装光标上下文释放和
重新初始化
2. 添加注释说明 m_cursorContext 仅存在于 Qt6
3. 在 Qt5 构建中正确防止访问 Qt6 特定 API

Influence:
1. 验证应用程序在 Qt5 和 Qt6 下都能成功编译
2. 测试光标功能在两个 Qt 版本中保持正常工作
3. 确认在 Qt6 构建中光标主题更改得到正确处理
4. 验证 Qt6 中光标上下文管理没有内存泄漏
deepin-ci-robot added a commit to linuxdeepin/qt6platform-plugins that referenced this pull request Dec 5, 2025
Synchronize source files from linuxdeepin/qt5platform-plugins.

Source-pull-request: linuxdeepin/qt5platform-plugins#313
@deepin-ci-robot
Copy link
Contributor

deepin pr auto review

我来对这个代码差异进行审查:

  1. 语法逻辑:
  • 代码通过条件编译 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 正确地处理了 Qt5 和 Qt6 的版本差异
  • 添加的注释清晰地说明了 m_cursorContext 只在 Qt6 中存在
  • 代码逻辑正确,在 Qt6 版本中正确处理了 m_cursorContext 的释放和重建
  1. 代码质量:
  • 注释清晰,说明了代码来源和注意事项
  • 代码缩进和格式保持一致
  • 错误处理完善,在创建新 context 失败时正确设置为 nullptr
  1. 代码性能:
  • 这个改动主要是版本兼容性处理,不会影响性能
  • 清理和重建 cursor context 的逻辑是必要的,没有多余操作
  1. 代码安全:
  • 通过条件编译确保了在 Qt5 环境下不会访问不存在的 m_cursorContext 成员
  • 在创建新 context 前先释放旧的 context,避免内存泄漏
  • xcb_cursor_context_new() 的返回值进行了检查,确保错误处理

改进建议:

  1. 可以考虑在文件头部添加一个宏定义来简化版本检查,例如:
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#define HAS_QT6_CURSOR_CONTEXT 1
#else
#define HAS_QT6_CURSOR_CONTEXT 0
#endif

这样代码中可以使用 #if HAS_QT6_CURSOR_CONTEXT 来提高可读性。

  1. 可以考虑将 Qt6 特定的代码抽取到一个单独的函数中,提高代码的组织性和可维护性。

总体来说,这是一个很好的改动,正确处理了 Qt 版本兼容性问题,代码质量良好。

@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fly602, yixinshark

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

@fly602
Copy link
Contributor Author

fly602 commented Dec 5, 2025

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Dec 5, 2025

This pr force merged! (status: blocked)

@deepin-bot deepin-bot bot merged commit e5c1de3 into linuxdeepin:master Dec 5, 2025
19 of 22 checks passed
18202781743 pushed a commit to linuxdeepin/qt6platform-plugins that referenced this pull request Dec 9, 2025
Synchronize source files from linuxdeepin/qt5platform-plugins.

Source-pull-request: linuxdeepin/qt5platform-plugins#313
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