From a6b34517ecf458d5c09fe4a1e6cf53811be7bd66 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 23 Sep 2015 17:51:49 +0200 Subject: [PATCH] Cocoa integration - re-parent NSView correctly If we add some view as a child into another view, make sure it's removed from the previous superview. Change-Id: I8c9f373907ded8e3ff75b1f2357401b308628125 Task-number: QTBUG-42059 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoawindow.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 543fcd50d1..f790259f0e 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1350,6 +1350,9 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow) } } else { // Child windows have no NSWindow, link the NSViews instead. + if ([m_contentView superview]) + [m_contentView removeFromSuperview]; + [m_parentCocoaWindow->m_contentView addSubview : m_contentView]; QRect rect = windowGeometry(); // Prevent setting a (0,0) window size; causes opengl context