diff --git a/src/core/contexts/win32windowcontext.cpp b/src/core/contexts/win32windowcontext.cpp index ebaa63d..9efd33c 100644 --- a/src/core/contexts/win32windowcontext.cpp +++ b/src/core/contexts/win32windowcontext.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -655,10 +656,9 @@ namespace QWK { return ::CallWindowProcW(g_qtWindowProc, hWnd, message, wParam, lParam); } - WindowsNativeEventFilter::lastMessageContext = ctx; - const auto &contextCleaner = qScopeGuard([]() { - WindowsNativeEventFilter::lastMessageContext = nullptr; // - }); + // Nested window messages must preserve the context of the outer dispatch. + const QScopedValueRollback contextGuard( + WindowsNativeEventFilter::lastMessageContext, ctx); // Since Qt does the necessary processing of the WM_NCCALCSIZE message, we need to // forward it right away and process it in our native event filter.