QCocoaWindow.mm: Avoid crash whe using native windows

When using native windows, notification were received after the platform
window pointer was cleaned up, which caused crashes.

Change-Id: I438fc29d1761a32a4705c4c802afe46908505756
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
Filipe Azevedo 2015-03-12 14:52:13 +01:00 committed by Shawn Rutledge
parent 7212b52e85
commit d178fd0bb8

View File

@ -441,9 +441,12 @@ QCocoaWindow::~QCocoaWindow()
m_parentCocoaWindow->removeChildWindow(this);
} else if (parent()) {
[m_contentView removeFromSuperview];
} else if (m_qtView) {
[[NSNotificationCenter defaultCenter] removeObserver:m_qtView
name:nil object:m_nsWindow];
}
// Make sure to disconnect observer in all case if view is valid
// to avoid notifications received when deleting when using Qt::AA_NativeWindows attribute
if (m_qtView) {
[[NSNotificationCenter defaultCenter] removeObserver:m_qtView];
}
// The QNSView object may outlive the corresponding QCocoaWindow object,