win: add one more safe guard

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2023-01-18 18:01:10 +08:00
parent 7534a4631c
commit a23438b02b
1 changed files with 5 additions and 1 deletions

View File

@ -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<MSG **>(message);
#else
const auto msg = static_cast<LPMSG>(message);
const auto msg = static_cast<const MSG *>(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)) {