From 1900ef3c9805d7fe15e0634cef9b5ff2a5dc7838 Mon Sep 17 00:00:00 2001 From: SineStriker <trueful@163.com> Date: 周三, 20 12月 2023 20:02:05 +0800 Subject: [PATCH] minor tweaks --- src/core/contexts/win32windowcontext.cpp | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/core/contexts/win32windowcontext.cpp b/src/core/contexts/win32windowcontext.cpp index 3b2d3e8..7a8ad24 100644 --- a/src/core/contexts/win32windowcontext.cpp +++ b/src/core/contexts/win32windowcontext.cpp @@ -985,11 +985,18 @@ } void Win32WindowContext::winIdChanged(QWindow *oldWindow, bool isDestroyed) { - if (isDestroyed) { - removeManagedWindow(reinterpret_cast<HWND>(windowId)); - } else { - removeManagedWindow<false>(reinterpret_cast<HWND>(windowId)); + Q_UNUSED(isDestroyed) + + // If the original window id is valid, remove all resources related + if (windowId) { + if (isDestroyed) { + removeManagedWindow(reinterpret_cast<HWND>(windowId)); + } else { + removeManagedWindow<false>(reinterpret_cast<HWND>(windowId)); + } + windowId = 0; } + if (!m_windowHandle) { return; } -- Gitblit v1.9.1