summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoawindow.mm
diff options
context:
space:
mode:
authorMorten Sorvig <morten.sorvig@nokia.com>2011-08-15 13:50:22 +0200
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2011-08-18 09:50:06 +0200
commit4e6c4d50a5fe10e355802ac05ce143aed32cffb4 (patch)
treee92dfdc843ddb51dca07f09998d22fac8fd5665a /src/plugins/platforms/cocoa/qcocoawindow.mm
parentc9d1adb7fa42cb36e5da0fb691efb6fd61f4d2f2 (diff)
Fix crash-on-exit in qmlscene.
Take control over NSWindow deletion to make sure it's lifetime matches that of the QCocoaWindow. Change-Id: Ia10006d814345356e6aebe7fa1f9a0e012535786 Reviewed-on: http://codereview.qt.nokia.com/2960 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@nokia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoawindow.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 7e88cdbf75..80a195d788 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -82,6 +82,12 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
[m_nsWindow setDelegate:delegate];
[m_nsWindow setAcceptsMouseMovedEvents:YES];
+ // Prevent Cocoa from releasing the window on close. Qt
+ // handles the close event asynchronously and we want to
+ // make sure that m_nsWindow stays valid until the
+ // QCocoaWindow is deleted by Qt.
+ [m_nsWindow setReleasedWhenClosed : NO];
+
m_contentView = [[QNSView alloc] initWithQWindow:tlw];
if (tlw->surfaceType() == QWindow::OpenGLSurface) {
@@ -99,7 +105,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
QCocoaWindow::~QCocoaWindow()
{
-
+ [m_nsWindow release];
}
void QCocoaWindow::setGeometry(const QRect &rect)
@@ -178,6 +184,12 @@ void QCocoaWindow::windowDidResize()
m_glContext->update();
}
+
+void QCocoaWindow::windowWillClose()
+{
+ QWindowSystemInterface::handleCloseEvent(window());
+}
+
void QCocoaWindow::setCurrentContext(QCocoaGLContext *context)
{
m_glContext = context;