From b91d37a600872298389e99fc354d76e9c37aa3bb Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 24 May 2017 17:17:00 -0700 Subject: QNSView: Remove tracking area on deallocation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ultimately, the tracking areas seem to be managed by the NSWindow (or at least somewhere else than the NSView itself). So, it can happen that we involuntarily leave dangling pointers in the system after the QNSView is released. This has shown to crash applications creating and deleting many native views on a single QNSWindow, e.g. calling winId() on a complex and dynamic QWidget hierarchy. The crash would happen when the QNSWindow receives a native enter event, which results on Cocoa trying to invoke the owner of a previously deallocated NSTrackingArea. Change-Id: I3ca7a39ee5f1ec51c2215639f61ba907de3d8659 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qnsview.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 72e90a5363..66c3b6fad4 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -177,7 +177,10 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)dealloc { CGImageRelease(m_maskImage); - [m_trackingArea release]; + if (m_trackingArea) { + [self removeTrackingArea:m_trackingArea]; + [m_trackingArea release]; + } m_maskImage = 0; [m_inputSource release]; [[NSNotificationCenter defaultCenter] removeObserver:self]; -- cgit v1.2.3