From a23438b02bbefd24f9277496475e89ae8af9f575 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Wed, 18 Jan 2023 18:01:10 +0800 Subject: [PATCH] win: add one more safe guard Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- src/core/framelesshelper_win.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/framelesshelper_win.cpp b/src/core/framelesshelper_win.cpp index 90e1fb8..5539f78 100644 --- a/src/core/framelesshelper_win.cpp +++ b/src/core/framelesshelper_win.cpp @@ -625,7 +625,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me // Work-around a bug caused by typo which only exists in Qt 5.11.1 const auto msg = *static_cast(message); #else - const auto msg = static_cast(message); + const auto msg = static_cast(message); #endif const HWND hWnd = msg->hwnd; if (!hWnd) { @@ -633,6 +633,10 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me // Anyway, we should skip the entire processing in this case. return false; } + // Let's be extra safe. + if (IsWindow(hWnd) == FALSE) { + return false; + } const UINT uMsg = msg->message; // WM_QUIT won't be posted to the WindowProc function. if ((uMsg == WM_CLOSE) || (uMsg == WM_DESTROY)) {