summaryrefslogtreecommitdiffstats
path: root/src/platformsupport
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-07-08 15:57:41 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-23 11:28:48 +0200
commit321cc1f27712100933da6a087e1846633b8b0051 (patch)
tree08b401447f9e5e9a3057147bde1e85b95ff33d0c /src/platformsupport
parentc0e5f31ad8621127af17ae8cc1660a249391d1eb (diff)
Share named time-interval constants in CoreFoundation event dispatcher
Change-Id: Ie9ae40e3f7e2631c461ad01b6e5a4640c0b773c9 Reviewed-by: Ian Dean <ian@mediator-software.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'src/platformsupport')
-rw-r--r--src/platformsupport/eventdispatchers/qeventdispatcher_cf.mm21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/platformsupport/eventdispatchers/qeventdispatcher_cf.mm b/src/platformsupport/eventdispatchers/qeventdispatcher_cf.mm
index d270dbcfcb..d128d2936d 100644
--- a/src/platformsupport/eventdispatchers/qeventdispatcher_cf.mm
+++ b/src/platformsupport/eventdispatchers/qeventdispatcher_cf.mm
@@ -45,11 +45,16 @@
#include <QtCore/QThread>
#include <QtCore/private/qcoreapplication_p.h>
+#include <limits>
+
#include <UIKit/UIApplication.h>
QT_BEGIN_NAMESPACE
QT_USE_NAMESPACE
+static const CFTimeInterval kCFTimeIntervalMinimum = 0;
+static const CFTimeInterval kCFTimeIntervalDistantFuture = std::numeric_limits<CFTimeInterval>::max();
+
void QEventDispatcherCoreFoundation::nonBlockingTimerRunLoopCallback(CFRunLoopTimerRef, void *info)
{
// The (one and only) CFRunLoopTimer has fired, which means that at least
@@ -77,7 +82,6 @@ void QEventDispatcherCoreFoundation::maybeStartCFRunLoopTimer()
if (m_runLoopTimerRef == 0) {
// start the CFRunLoopTimer
- CFTimeInterval oneyear = CFTimeInterval(3600. * 24. * 365.);
// calculate when the next timer should fire:
struct timespec tv;
@@ -86,14 +90,14 @@ void QEventDispatcherCoreFoundation::maybeStartCFRunLoopTimer()
} else {
// this shouldn't really happen, but in case it does, set the timer
// to fire a some point in the distant future:
- interval = oneyear;
+ interval = kCFTimeIntervalDistantFuture;
}
ttf += interval;
CFRunLoopTimerContext info = { 0, this, 0, 0, 0 };
// create the timer with a large interval, as recommended by the CFRunLoopTimerSetNextFireDate()
// documentation, since we will adjust the timer's time-to-fire as needed to keep Qt timers working
- m_runLoopTimerRef = CFRunLoopTimerCreate(0, ttf, oneyear, 0, 0, QEventDispatcherCoreFoundation::nonBlockingTimerRunLoopCallback, &info);
+ m_runLoopTimerRef = CFRunLoopTimerCreate(0, ttf, kCFTimeIntervalDistantFuture, 0, 0, QEventDispatcherCoreFoundation::nonBlockingTimerRunLoopCallback, &info);
Q_ASSERT(m_runLoopTimerRef != 0);
CFRunLoopRef mainRunLoop = CFRunLoopGetMain();
@@ -173,17 +177,16 @@ bool QEventDispatcherCoreFoundation::processEvents(QEventLoop::ProcessEventsFlag
bool execFlagSet = (flags & QEventLoop::DialogExec) || (flags & QEventLoop::EventLoopExec);
bool useExecMode = execFlagSet && !excludeUserEvents;
- CFTimeInterval distantFuture = CFTimeInterval(3600. * 24. * 365. * 10.);
SInt32 result;
if (useExecMode) {
while (!m_interrupted) {
// Run a single pass on the runloop to unblock it
- result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true);
+ result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, kCFTimeIntervalMinimum, true);
// Run the default runloop until interrupted (by Qt or UIKit)
if (result != kCFRunLoopRunFinished)
- result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, distantFuture, false);
+ result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, kCFTimeIntervalDistantFuture, false);
// App has quit or Qt has interrupted?
if (result == kCFRunLoopRunFinished || m_interrupted)
@@ -193,7 +196,7 @@ bool QEventDispatcherCoreFoundation::processEvents(QEventLoop::ProcessEventsFlag
if (result == kCFRunLoopRunStopped && !m_interrupted) {
// Run runloop in UI tracking mode
if (CFRunLoopRunInMode((CFStringRef) UITrackingRunLoopMode,
- distantFuture, false) == kCFRunLoopRunFinished)
+ kCFTimeIntervalDistantFuture, false) == kCFRunLoopRunFinished)
break;
}
}
@@ -203,10 +206,10 @@ bool QEventDispatcherCoreFoundation::processEvents(QEventLoop::ProcessEventsFlag
wakeUp();
// Run runloop in default mode
- result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, distantFuture, true);
+ result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, kCFTimeIntervalDistantFuture, true);
if (result != kCFRunLoopRunFinished) {
// Run runloop in UI tracking mode
- CFRunLoopRunInMode((CFStringRef) UITrackingRunLoopMode, distantFuture, false);
+ CFRunLoopRunInMode((CFStringRef) UITrackingRunLoopMode, kCFTimeIntervalDistantFuture, false);
}
eventsProcessed = (result == kCFRunLoopRunHandledSource);
}