macOS: Ensure NSEvent processing during NSApp initialization

After 27f0854813 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 <timur.pocheptsov@qt.io>
bb10
Tor Arne Vestbø 2023-01-02 15:40:19 +01:00
parent 25c67c608a
commit 76cef0f171
1 changed files with 1 additions and 0 deletions

View File

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