From 40033ac299824949ff910007c2254840ad0a53f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 17 Jun 2013 15:55:31 +0200 Subject: iOS: Implement hasPendingEvents() in the event dispatcher As we're using CFRunLoopIsWaiting() to check for the possible presence of system events hasPendingEvents() will never return false if called on the main thread. We assume clients will not use this function to determine whether or not to call processEvents(), but instead use the return value from processEvents. Change-Id: Ifd63892c6d35bb7da204072616bfe3ee69ca1d85 Reviewed-by: Richard Moe Gustavsen --- src/platformsupport/eventdispatchers/qeventdispatcher_cf.mm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/platformsupport/eventdispatchers') diff --git a/src/platformsupport/eventdispatchers/qeventdispatcher_cf.mm b/src/platformsupport/eventdispatchers/qeventdispatcher_cf.mm index ab26b4c1d8..6442df715a 100644 --- a/src/platformsupport/eventdispatchers/qeventdispatcher_cf.mm +++ b/src/platformsupport/eventdispatchers/qeventdispatcher_cf.mm @@ -460,8 +460,17 @@ void QEventDispatcherCoreFoundation::handleRunLoopActivity(CFRunLoopActivity act bool QEventDispatcherCoreFoundation::hasPendingEvents() { - qDebug() << __FUNCTION__ << "not implemented"; - return false; + // There doesn't seem to be any API on iOS to peek into the other sources + // to figure out if there are pending non-Qt events. As a workaround, we + // assume that if the run-loop is currently blocking and waiting for a + // source to signal then there are no system-events pending. If this + // function is called from the main thread then the second clause + // of the condition will always be true, as the the run loop is + // never waiting in that case. The function would be more aptly named + // 'maybeHasPendingEvents' in our case. + + extern uint qGlobalPostedEventsCount(); + return qGlobalPostedEventsCount() || !CFRunLoopIsWaiting(CFRunLoopGetMain()); } void QEventDispatcherCoreFoundation::wakeUp() -- cgit v1.2.3