From 7ffcf328c75ddfc93e45d35eef549adb474cbda1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?=
 <morten.sorvig@theqtcompany.com>
Date: Mon, 11 May 2015 21:56:57 +0200
Subject: [PATCH] Remove QNSView from superview in ~QCocoaWindow()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

A QNSView without a corresponding live QCocoaWindow
object is not in a valid state. Previously we would
call removeFromSuperview for child QWindows to avoid
having Cocoa send messages to the now invalid QNSView.

Do this for QWindows embedded in native Cocoa
hierarchies as well.

Change-Id: I49c6daef8ed061b3f40138fe9b4ce6be190f2fd0
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
---
 src/plugins/platforms/cocoa/qcocoawindow.mm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 3db3fc3547a..cbe4227b63e 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -415,7 +415,7 @@ QCocoaWindow::~QCocoaWindow()
     if (m_isNSWindowChild) {
         if (m_parentCocoaWindow)
             m_parentCocoaWindow->removeChildWindow(this);
-    } else if (parent()) {
+    } else if ([m_contentView superview]) {
         [m_contentView removeFromSuperview];
     }
 
-- 
GitLab