QNSView: Remove tracking area on deallocation

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ø <tor.arne.vestbo@qt.io>
bb10
Gabriel de Dietrich 2017-05-24 17:17:00 -07:00
parent 57d16c12cc
commit b91d37a600
1 changed files with 4 additions and 1 deletions

View File

@ -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];