Skip to content

Commit e5c1de3

Browse files
fly602deepin-bot[bot]
authored andcommitted
fix: add Qt6 version guard for cursor context handling
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 中光标上下文管理没有内存泄漏
1 parent 6be09b7 commit e5c1de3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

xcb/dplatformintegration.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,9 @@ static void cursorThemePropertyChanged(xcb_connection_t *connection, const QByte
10741074
}
10751075
xcb_cursor->m_cursorHash.clear();
10761076

1077+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
10771078
// source from: QXCBCursor::updateContext()
1079+
// Note: m_cursorContext only exists in Qt6
10781080
if (xcb_cursor->m_cursorContext) {
10791081
xcb_cursor_context_free(xcb_cursor->m_cursorContext);
10801082
}
@@ -1084,6 +1086,7 @@ static void cursorThemePropertyChanged(xcb_connection_t *connection, const QByte
10841086
if (xcb_cursor_context_new(conn, xcb_cursor->m_screen->screen(), &xcb_cursor->m_cursorContext) < 0) {
10851087
xcb_cursor->m_cursorContext = nullptr;
10861088
}
1089+
#endif
10871090
}
10881091
}
10891092

0 commit comments

Comments
 (0)