From 4ef40f75483b90ea91f805ff25250ca4bd26cb22 Mon Sep 17 00:00:00 2001 From: zhangkun Date: Sat, 7 Feb 2026 13:05:41 +0800 Subject: [PATCH] fix: set default cursor when cursor is null MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the cursor parameter is null in overrideChangeCursor, the original function call would pass null to QPlatformCursor::changeCursor. This could cause the platform cursor to fall back to the parent window's cursor, which might be incorrect or unintended. By creating a default Qt::ArrowCursor and using it when cursor is null, we ensure a consistent cursor appearance and prevent unexpected cursor behavior. Log: Fixed cursor display issue when setting null cursor fix: 当光标为null时设置默认光标 当overrideChangeCursor函数中的cursor参数为null时,原始函数调用会将 null传递给QPlatformCursor::changeCursor。这可能导致平台光标回退到父 窗口的光标,而父窗口的光标可能是错误或不正确的。通过创建一个默认的 Qt::ArrowCursor并在cursor为null时使用它,我们确保了光标外观的一致性,并 防止了意外的光标行为。 Log: 修复设置null光标时的显示问题 PMS: BUG-345829 PMS: BUG-344197 --- xcb/dplatformintegration.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xcb/dplatformintegration.cpp b/xcb/dplatformintegration.cpp index 0a009c13..0e1c0691 100644 --- a/xcb/dplatformintegration.cpp +++ b/xcb/dplatformintegration.cpp @@ -973,7 +973,12 @@ static void overrideChangeCursor(QPlatformCursor *cursorHandle, QCursor * cursor } #endif // D_ENABLE_CURSOR_HOOK - VtableHook::callOriginalFun(cursorHandle, &QPlatformCursor::changeCursor, cursor, widget); + if (cursor) { + VtableHook::callOriginalFun(cursorHandle, &QPlatformCursor::changeCursor, cursor, widget); + } else { + QCursor defaultCursor; + VtableHook::callOriginalFun(cursorHandle, &QPlatformCursor::changeCursor, &defaultCursor, widget); + } } static void hookXcbCursor(QScreen *screen)