QCocoaEventDispatcherPrivate *d = static_cast<QCocoaEventDispatcherPrivate *>(info);
(void) d->timerInfoList.activateTimers();
d->maybeStartCFRunLoopTimer();
+ d->maybeCancelWaitForMoreEvents();
}
void QCocoaEventDispatcherPrivate::maybeStartCFRunLoopTimer()
if (socketInfo->writeNotifier)
QGuiApplication::sendEvent(socketInfo->writeNotifier, ¬ifierEvent);
}
+
+ eventDispatcher->maybeCancelWaitForMoreEvents();
}
/*
bool interruptLater = false;
QtCocoaInterruptDispatcher::cancelInterruptLater();
- // In case we end up recursing while we now process events, make sure
- // that we send remaining posted Qt events before this call returns:
- wakeUp();
emit awake();
bool excludeUserEvents = flags & QEventLoop::ExcludeUserInputEvents;
bool retVal = false;
+ uint oldflags = d->processEventsFlags;
+ d->processEventsFlags = flags;
forever {
if (d->interrupt)
break;
}
retVal = true;
} else {
+ bool hadModalSession = d->currentModalSessionCached != 0;
// We cannot block the thread (and run in a tight loop).
// Instead we will process all current pending events and return.
d->ensureNSAppInitialized();
}
} while (!d->interrupt && event != nil);
- // Be sure to flush the Qt posted events when not using exec mode
- // (exec mode will always do this call from the event loop source):
- if (!d->interrupt)
- QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
-
// Since the window that holds modality might have changed while processing
// events, we we need to interrupt when we return back the previous process
// event recursion to ensure that we spin the correct modal session.
// We do the interruptLater at the end of the function to ensure that we don't
// disturb the 'wait for more events' below (as deleteLater will post an event):
- interruptLater = true;
+ if (hadModalSession && d->currentModalSessionCached == 0)
+ interruptLater = true;
}
bool canWait = (d->threadData->canWait
&& !retVal
}
}
+ d->processEventsFlags = oldflags;
+
// If we're interrupted, we need to interrupt the _current_
// recursion as well to check if it is still supposed to be
// executing. This way we wind down the stack until we land
}
QCocoaEventDispatcherPrivate::QCocoaEventDispatcherPrivate()
- : runLoopTimerRef(0),
+ : processEventsFlags(0),
+ runLoopTimerRef(0),
blockSendPostedEvents(false),
currentExecIsNSAppRun(false),
nsAppRunCalledByQt(false),
void QCocoaEventDispatcherPrivate::postedEventsSourcePerformCallback(void *info)
{
- static_cast<QCocoaEventDispatcherPrivate *>(info)->processPostedEvents();
+ QCocoaEventDispatcherPrivate *d = static_cast<QCocoaEventDispatcherPrivate *>(info);
+ d->processPostedEvents();
+ d->maybeCancelWaitForMoreEvents();
}
void QCocoaEventDispatcherPrivate::cancelWaitForMoreEvents()
subtype:QtCocoaEventSubTypeWakeup data1:0 data2:0] atStart:NO];
}
+void QCocoaEventDispatcherPrivate::maybeCancelWaitForMoreEvents()
+{
+ if ((processEventsFlags & (QEventLoop::EventLoopExec | QEventLoop::WaitForMoreEvents)) == QEventLoop::WaitForMoreEvents) {
+ // RunLoop sources are not NSEvents, but they do generate Qt events. If
+ // WaitForMoreEvents was set, but EventLoopExec is not, processEvents()
+ // should return after a source has sent some Qt events.
+ cancelWaitForMoreEvents();
+ }
+}
+
void QCocoaEventDispatcher::interrupt()
{
Q_D(QCocoaEventDispatcher);