Cocoa: Clear window hash entry in ~QCocoaWindow.

The Cocoa platform plugin maintains a NSWindow->
QCocoaWindow hash.

Hash entries was not properly cleared on QCocoaWindow
destruction. Add call to clear the entry for the
destroyed window. Make QCocoaIntegration remove
the key from the hash in this case instead of
setting it to 0.

Task-number: QTBUG-37597
Change-Id: I3adaeee45069aea1d2ecacd948298302eafe1929
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
bb10
Morten Johan Sørvig 2014-05-02 20:52:25 +02:00 committed by The Qt Project
parent 9a747cb5b7
commit 54cc481760
2 changed files with 7 additions and 1 deletions

View File

@ -520,7 +520,10 @@ NSToolbar *QCocoaIntegration::toolbar(QWindow *window) const
void QCocoaIntegration::setWindow(NSWindow* nsWindow, QCocoaWindow *window)
{
mWindows.insert(nsWindow, window);
if (window == 0)
mWindows.remove(nsWindow);
else
mWindows.insert(nsWindow, window);
}
QCocoaWindow *QCocoaIntegration::window(NSWindow *window)

View File

@ -420,6 +420,9 @@ QCocoaWindow::~QCocoaWindow()
qDebug() << "QCocoaWindow::~QCocoaWindow" << this;
#endif
if (QCocoaIntegration *ci = QCocoaIntegration::instance())
ci->setWindow(m_nsWindow, 0);
QCocoaAutoReleasePool pool;
[m_nsWindow setContentView:nil];
[m_nsWindow.helper detachFromPlatformWindow];