From 499afac952920595e6c3d4f94806427f894c7674 Mon Sep 17 00:00:00 2001 From: Sine Striker <trueful@163.com> Date: 周六, 02 12月 2023 19:05:24 +0800 Subject: [PATCH] optimize code --- src/core/contexts/win32windowcontext.cpp | 21 ++++----------------- 1 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/core/contexts/win32windowcontext.cpp b/src/core/contexts/win32windowcontext.cpp index ab32ed0..a0d5779 100644 --- a/src/core/contexts/win32windowcontext.cpp +++ b/src/core/contexts/win32windowcontext.cpp @@ -24,8 +24,7 @@ // Try hooked procedure LRESULT result; - bool handled = ctx->windowProc(hWnd, message, wParam, lParam, &result); - if (handled) { + if (ctx->windowProc(hWnd, message, wParam, lParam, &result)) { return result; } @@ -45,25 +44,11 @@ bool Win32WindowContext::setup() { auto winId = m_windowHandle->winId(); - Q_ASSERT(winId); - if (!winId) { - return false; - } // Install window hook auto hWnd = reinterpret_cast<HWND>(winId); auto qtWindowProc = reinterpret_cast<WNDPROC>(::GetWindowLongPtrW(hWnd, GWLP_WNDPROC)); - Q_ASSERT(qtWindowProc); - if (!qtWindowProc) { - QWK_WARNING << winLastErrorMessage(); - return false; - } - - if (::SetWindowLongPtrW(hWnd, GWLP_WNDPROC, - reinterpret_cast<LONG_PTR>(QWK_WindowsWndProc)) == 0) { - QWK_WARNING << winLastErrorMessage(); - return false; - } + ::SetWindowLongPtrW(hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(QWK_WindowsWndProc)); windowId = winId; @@ -85,6 +70,8 @@ // TODO: Implement // ... + Q_UNUSED(windowId) + return false; // Not handled } -- Gitblit v1.9.1