summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoawindow.mm
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-11-12 16:10:05 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-11-16 18:54:32 +0000
commit99bb78f6c2a748070d1354f9e13951b1e3344b19 (patch)
tree9c4bfe05f4922303a8cb0354ec415f2644d0119b /src/plugins/platforms/cocoa/qcocoawindow.mm
parent550e02b80975dc6aede664651216bd6b9511f7df (diff)
macOS: Clear NSOpenGLContext drawable when QNSView is about to go away
Calling doneCurrent() on a QCocoaGLContext only clears the current context, but doesns't reset the drawable (view) of the context. In most cases this is fine, but it has been observed to cause issues when using the software GL renderer on Big Sur and above. To be a good citizen we clear the drawable of any of our contexts that are tied to the NSView this about to be go away. Pick-to: 6.2 6.2.2 Change-Id: I8c845727c50871f30fbebc2ed62a7d0485651ecf Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoawindow.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 1bc53bde5c..70cfa42974 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -186,6 +186,8 @@ void QCocoaWindow::initialize()
m_initialized = true;
}
+const NSNotificationName QCocoaWindowWillReleaseQNSViewNotification = @"QCocoaWindowWillReleaseQNSViewNotification";
+
QCocoaWindow::~QCocoaWindow()
{
qCDebug(lcQpaWindow) << "QCocoaWindow::~QCocoaWindow" << window();
@@ -209,6 +211,13 @@ QCocoaWindow::~QCocoaWindow()
}
#endif
+ // Must send notification before calling release, as doing it from
+ // [QNSView dealloc] would mean that any weak references to the view
+ // would already return nil.
+ [NSNotificationCenter.defaultCenter
+ postNotificationName:QCocoaWindowWillReleaseQNSViewNotification
+ object:m_view];
+
[m_view release];
[m_nsWindow close];
[m_nsWindow release];