From 554ba2c39bbede3b73671c8d8c7635377c4a8107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 14 Nov 2022 17:41:47 +0100 Subject: macOS: Don't send posted events via runloop observer The logic was added in b0016ea9a6b225757e3ee06b50e8f7d05463ddf7, but the test-case in the bug report works fine without this logic. As sending events from a runloop observer is dubious, and causes problems since it's not tied to the quite complex machinery of the general event processing, it's better to remove it. The original issue is already tested by sendEventsOnProcessEvents in tst_QCore/GuiApplication. Task-number: QTBUG-4521 Change-Id: I857519a09a13a72b7434727c0229606403be7ed3 Reviewed-by: Qt CI Bot Reviewed-by: Volker Hilsheimer --- .../platforms/cocoa/qcocoaeventdispatcher.h | 2 -- .../platforms/cocoa/qcocoaeventdispatcher.mm | 37 ---------------------- 2 files changed, 39 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h index b4db7775da..787b23ec4d 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h @@ -148,7 +148,6 @@ public: QList queuedUserInputEvents; // NSEvent * CFRunLoopSourceRef postedEventsSource; CFRunLoopObserverRef waitingObserver; - CFRunLoopObserverRef firstTimeObserver; QAtomicInt serialNumber; int lastSerial; bool interrupt; @@ -157,7 +156,6 @@ public: static void postedEventsSourceCallback(void *info); static void waitingObserverCallback(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info); - static void firstLoopEntry(CFRunLoopObserverRef ref, CFRunLoopActivity activity, void *info); bool sendQueuedUserInputEvents(); void processPostedEvents(); }; diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index 1ea3344ee8..dbb2de0198 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -818,21 +818,6 @@ QCocoaEventDispatcher::QCocoaEventDispatcher(QObject *parent) QCocoaEventDispatcherPrivate::waitingObserverCallback, &observerContext); CFRunLoopAddObserver(mainRunLoop(), d->waitingObserver, kCFRunLoopCommonModes); - - /* The first cycle in the loop adds the source and the events of the source - are not processed. - We use an observer to process the posted events for the first - execution of the loop. */ - CFRunLoopObserverContext firstTimeObserverContext; - bzero(&firstTimeObserverContext, sizeof(CFRunLoopObserverContext)); - firstTimeObserverContext.info = d; - d->firstTimeObserver = CFRunLoopObserverCreate(kCFAllocatorDefault, - kCFRunLoopEntry, - /* repeats = */ false, - 0, - QCocoaEventDispatcherPrivate::firstLoopEntry, - &firstTimeObserverContext); - CFRunLoopAddObserver(mainRunLoop(), d->firstTimeObserver, kCFRunLoopCommonModes); } void QCocoaEventDispatcherPrivate::waitingObserverCallback(CFRunLoopObserverRef, @@ -897,25 +882,6 @@ void QCocoaEventDispatcherPrivate::processPostedEvents() } } -void QCocoaEventDispatcherPrivate::firstLoopEntry(CFRunLoopObserverRef ref, - CFRunLoopActivity activity, - void *info) -{ - Q_UNUSED(ref); - Q_UNUSED(activity); - - QCocoaEventDispatcherPrivate *d = static_cast(info); - if (d->initializingNSApplication) { - qCDebug(lcEventDispatcher) << "Deferring" << __FUNCTION__ << "due to NSApp initialization"; - // We don't want to process any sources during explicit NSApplication - // initialization, so defer the source until the actual event processing. - CFRunLoopSourceSignal(d->postedEventsSource); - return; - } - - static_cast(info)->processPostedEvents(); -} - void QCocoaEventDispatcherPrivate::postedEventsSourceCallback(void *info) { QCocoaEventDispatcherPrivate *d = static_cast(info); @@ -1017,9 +983,6 @@ QCocoaEventDispatcher::~QCocoaEventDispatcher() CFRunLoopObserverInvalidate(d->waitingObserver); CFRelease(d->waitingObserver); - - CFRunLoopObserverInvalidate(d->firstTimeObserver); - CFRelease(d->firstTimeObserver); } QtCocoaInterruptDispatcher* QtCocoaInterruptDispatcher::instance = nullptr; -- cgit v1.2.3