From c8cdc3eb96494283d2f5027268e415b46f21a1de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 18 May 2022 13:09:36 +0200 Subject: [PATCH] Windows: Account for not finding child windows when calling ChildWindowFromPointEx The main code path of findPlatformWindowHelper had a check to verify that the resulting child was not the parent HWND handle itself, but the code path for handling QTBUG-40555 was missing this check, resulting in infinite loops when the top level window was a transparent window. We add the same kind of check to this code path, where neither the hwnd out pointer or the result out pointer is updated. This is okey since we return false and don't expect the function to continue iterating based on an updated hwnd pointer. Ideally the iteration logic should be moved into findPlatformWindowHelper instead of having the outer loop outside of the function, but that's left for another day. Fixes: QTBUG-103571 Change-Id: I9465253bca52bebf9137b24d7ce36646553d8d39 Reviewed-by: Volker Hilsheimer (cherry picked from commit cb51ab41e89516031abb2cf704cc22a376c21ef0) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/windows/qwindowscontext.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index d87804cda29..b52d624a762 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -733,6 +733,8 @@ static inline bool findPlatformWindowHelper(const POINT &screenPoint, unsigned c if (!(cwexFlags & CWP_SKIPTRANSPARENT) && (GetWindowLongPtr(child, GWL_EXSTYLE) & WS_EX_TRANSPARENT)) { const HWND nonTransparentChild = ChildWindowFromPointEx(*hwnd, point, cwexFlags | CWP_SKIPTRANSPARENT); + if (!nonTransparentChild || nonTransparentChild == *hwnd) + return false; if (QWindowsWindow *nonTransparentWindow = context->findPlatformWindow(nonTransparentChild)) { *result = nonTransparentWindow; *hwnd = nonTransparentChild;