Fix crash in many cases

Check whether the QWindow is null

Fixes: #37

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2020-11-27 18:55:45 +08:00
parent 84ce2eb418
commit b601d083bf
1 changed files with 3 additions and 0 deletions

View File

@ -1270,6 +1270,9 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType,
return false; return false;
} }
const QWindow *window = getWindowFromRawHandle(msg->hwnd); const QWindow *window = getWindowFromRawHandle(msg->hwnd);
if (!window) {
return false;
}
const auto data = reinterpret_cast<WINDOWDATA *>( const auto data = reinterpret_cast<WINDOWDATA *>(
WNEF_EXECUTE_WINAPI_RETURN(GetWindowLongPtrW, 0, msg->hwnd, GWLP_USERDATA)); WNEF_EXECUTE_WINAPI_RETURN(GetWindowLongPtrW, 0, msg->hwnd, GWLP_USERDATA));
if (!data) { if (!data) {