From 76cef0f1714c303aec2ee28996984babdd91d1b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 2 Jan 2023 15:40:19 +0100 Subject: [PATCH] macOS: Ensure NSEvent processing during NSApp initialization After 27f08548131e385f3c0c1fd4721e5979d512effe we are ensuring NSApp initialization without relying on our own runloop sources. But stopping the app only happens after it has processed an NSEvent, such as a mouse move or key press, which in the case of an auto tests might not happen. To ensure that the [NSApp stop] has an effect we post a synthetic event, that has no other effect than waking up the runloop. Change-Id: Ifa8912a80f9deff62645cbef56c1b1230542f3e4 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index dbb2de0198..fd0a4b4717 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -596,6 +596,7 @@ void QCocoaEventDispatcherPrivate::ensureNSAppInitialized() CFRunLoopPerformBlock(mainRunLoop(), kCFRunLoopCommonModes, ^{ qCDebug(lcEventDispatcher) << "NSApplication has been initialized; Stopping NSApp"; [NSApp stop:NSApp]; + cancelWaitForMoreEvents(); // Post event that wakes up the runloop }); [NSApp run]; qCDebug(lcEventDispatcher) << "Finished ensuring NSApplication is initialized";