From d599451e24b68c1555d965e3566bd9b74bf1b6a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 22 Sep 2023 17:39:28 +0200 Subject: [PATCH] Guard QWindowsContext::instance() during screen change on shutdown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Destructing the QWindowsScreenManager might result in a WM_DISPLAYCHANGE, at which point our QWindowsContext instance is likely gone. We need to guard against that. Fixes: QTBUG-117473 Pick-to: 6.5 Change-Id: If32941c5c11231f7c27e9dde54f4315f18da1100 Reviewed-by: Wladimir Leuschner Reviewed-by: Tor Arne Vestbø Reviewed-by: Timothée Keller (cherry picked from commit 7d663d2e08fb71801f0f1f084a124e706722bf0f) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/windows/qwindowsscreen.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index 6b85a68f69b..677a4dcadeb 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -656,7 +656,8 @@ extern "C" LRESULT QT_WIN_CALLBACK qDisplayChangeObserverWndProc(HWND hwnd, UINT if (QWindowsTheme *t = QWindowsTheme::instance()) t->displayChanged(); QWindowsWindow::displayChanged(); - QWindowsContext::instance()->screenManager().handleScreenChanges(); + if (auto *context = QWindowsContext::instance()) + context->screenManager().handleScreenChanges(); } return DefWindowProc(hwnd, message, wParam, lParam);