macOS: Retain NSWindow during event delivery
We have logic to deal with self.platformWindow and frame strut mouse events which happens after delivering the event to the NSWindow, but delivering it might dealloc the window, e.g. when closing it, so we need to explicitly retain it for the duration of [QNSWindow sendEvent:] Task-number: QTBUG-64023 Change-Id: I223fe3e3ac36a309da375522ba11f20f1ad6fc4f Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
This commit is contained in:
parent
17d5141113
commit
3a92f7cf4f
@ -185,6 +185,10 @@ static bool isMouseEvent(NSEvent *ev)
|
||||
if (!self.platformWindow)
|
||||
return;
|
||||
|
||||
// Prevent deallocation of this NSWindow during event delivery, as we
|
||||
// have logic further below that depends on the window being alive.
|
||||
[[self retain] autorelease];
|
||||
|
||||
const char *eventType = object_getClassName(theEvent);
|
||||
if (QWindowSystemInterface::handleNativeEvent(self.platformWindow->window(),
|
||||
QByteArray::fromRawData(eventType, qstrlen(eventType)), theEvent, nullptr)) {
|
||||
@ -221,6 +225,7 @@ static bool isMouseEvent(NSEvent *ev)
|
||||
#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
|
||||
- (void)dealloc
|
||||
{
|
||||
qCDebug(lcQpaCocoaWindow) << "dealloc" << self;
|
||||
qt_objcDynamicSuper();
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
Loading…
x
Reference in New Issue
Block a user