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/cocoawindowcontext.mm |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/core/contexts/cocoawindowcontext.mm b/src/core/contexts/cocoawindowcontext.mm
index 79ad85e..c16c5a2 100644
--- a/src/core/contexts/cocoawindowcontext.mm
+++ b/src/core/contexts/cocoawindowcontext.mm
@@ -404,11 +404,18 @@
     }
 
     void CocoaWindowContext::winIdChanged(QWindow *oldWindow, bool isDestroyed) {
-        releaseWindowProxy(windowId);
+        // If the original window id is valid, remove all resources related
+        if (windowId) {
+            releaseWindowProxy(windowId);
+            windowId = 0;
+            cocoaWindowEventFilter.reset();
+        }
+
         if (!m_windowHandle) {
             return;
         }
 
+        // Allocate new resources
         windowId = m_windowHandle->winId();
         ensureWindowProxy(windowId)->setSystemTitleBarVisible(false);
         cocoaWindowEventFilter = std::make_unique<CocoaWindowEventFilter>(this, this);

--
Gitblit v1.9.1