macOS: Ensure NSWindow delegate is released in sync with its NSWindow

Releasing it in [QNSWindow closeAndRelease] is wrong, as we only call
that method from a few call sites, and can easily end up with a normal
dealloc by means of e.g. the [m_nsWindow release] in ~QCocoaWindow.

This still leaves Xcode thinking we have a single leaking delegate
per active NSWindow, as it apparently doesn't realize we're calling
release manually. This needs to be investigated further.

Task-number: QTBUG-65693
Change-Id: I9105602274d8532465e5108aba2b05bf253268e9
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Tor Arne Vestbø 2018-11-15 13:45:46 +01:00 committed by Liang Qi
parent 574bf5d9aa
commit 6c1656397a

View File

@ -239,10 +239,6 @@ static bool isMouseEvent(NSEvent *ev)
- (void)closeAndRelease
{
qCDebug(lcQpaWindow) << "closeAndRelease" << self;
[self.delegate release];
self.delegate = nil;
[self close];
[self release];
}
@ -252,6 +248,9 @@ static bool isMouseEvent(NSEvent *ev)
- (void)dealloc
{
qCDebug(lcQpaWindow) << "dealloc" << self;
[self.delegate release];
self.delegate = nil;
qt_objcDynamicSuper();
}
#pragma clang diagnostic pop