From 8d6e825ddfa14f75959ae20a76e4e1a34f4faec2 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 30 Sep 2021 11:04:48 +0200 Subject: [PATCH] windows qpa: Handle invisible child windows gracefully on dpi changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-96466 Pick-to: 6.2 Change-Id: I58d90e85b4bb837df2dc5fd89abe984dadcd468d Reviewed-by: Morten Johan Sørvig --- 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 433e58a97a..bbdf1ad692 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -1474,6 +1474,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, // Scale child QPlatformWindow size. Windows sends WM_DPICHANGE to top-level windows only. for (QWindow *childWindow : platformWindow->window()->findChildren()) { QWindowsWindow *platformChildWindow = static_cast(childWindow->handle()); + if (!platformChildWindow) + continue; QRect currentGeometry = platformChildWindow->geometry(); QRect scaledGeometry = QRect(currentGeometry.topLeft() * scale, currentGeometry.size() * scale); platformChildWindow->setGeometry(scaledGeometry);