summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm14
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.mm4
3 files changed, 17 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 92fc026bc1..035a09b607 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -76,6 +76,7 @@ public:
void windowDidMove();
void windowDidResize();
+ void windowWillClose();
void setCurrentContext(QCocoaGLContext *context);
QCocoaGLContext *currentContext() const;
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;
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
index 6521db5cf7..869ef7840b 100644
--- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
@@ -75,7 +75,9 @@
- (void)windowWillClose:(NSNotification *)notification
{
Q_UNUSED(notification);
- QWindowSystemInterface::handleCloseEvent(m_cocoaWindow->window());
+ if (m_cocoaWindow) {
+ m_cocoaWindow->windowWillClose();
+ }
}
@end