summaryrefslogtreecommitdiffstats
path: root/src/platformsupport
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-06-17 15:55:31 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-12 16:48:00 +0200
commit40033ac299824949ff910007c2254840ad0a53f3 (patch)
treec98afffc96e475d50c5a377a21484e2e1f866ea1 /src/platformsupport
parent5d926657f4149cde9aaa447808785abda835147f (diff)
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 <richard.gustavsen@digia.com>
Diffstat (limited to 'src/platformsupport')
-rw-r--r--src/platformsupport/eventdispatchers/qeventdispatcher_cf.mm13
1 files changed, 11 insertions, 2 deletions
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()