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>
This commit is contained in:
parent
e66a878838
commit
abde2a59c6
@ -1477,7 +1477,11 @@ void QCocoaWindow::setNSWindow(QCocoaNSWindow *window)
|
|||||||
{
|
{
|
||||||
if (window.contentView != m_contentView) {
|
if (window.contentView != m_contentView) {
|
||||||
[m_contentView setPostsFrameChangedNotifications: NO];
|
[m_contentView setPostsFrameChangedNotifications: NO];
|
||||||
|
[m_contentView retain];
|
||||||
|
if (m_contentView.superview) // m_contentView comes from another NSWindow
|
||||||
|
[m_contentView removeFromSuperview];
|
||||||
[window setContentView:m_contentView];
|
[window setContentView:m_contentView];
|
||||||
|
[m_contentView release];
|
||||||
[m_contentView setPostsFrameChangedNotifications: YES];
|
[m_contentView setPostsFrameChangedNotifications: YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user