summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>2014-09-22 14:55:04 +0200
committerGabriel de Dietrich <gabriel.dedietrich@digia.com>2014-09-23 13:29:21 +0200
commitabde2a59c603899c80e67bb5e7f892d554ff72fd (patch)
tree0e01d65b2ba960d79ffd88c60f4077abb185e0e7
parente66a878838f17a0626b0b10b340b1ca4dba56cc1 (diff)
Cocoa: Properly remove content view from its superview in setNSWindow()
-[NSWindow setContentView:] doesn't make assupmtions about where that view comes from, and just attaches it to the window. We need to make sure we detach it from its previous window by calling -[NSView removeFromSuperview], or the previous NSWindow may keep references to the view. This can be an issue if the view is deleted right after. Task-number: QTBUG-39628 Change-Id: I152dedcb64ac044d8ca290c9996b388809e2477b Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 19d0f7a987..96c882887e 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -1477,7 +1477,11 @@ void QCocoaWindow::setNSWindow(QCocoaNSWindow *window)
{
if (window.contentView != m_contentView) {
[m_contentView setPostsFrameChangedNotifications: NO];
+ [m_contentView retain];
+ if (m_contentView.superview) // m_contentView comes from another NSWindow
+ [m_contentView removeFromSuperview];
[window setContentView:m_contentView];
+ [m_contentView release];
[m_contentView setPostsFrameChangedNotifications: YES];
}
}