summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2012-01-05 13:56:01 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-06 14:40:57 +0100
commit156d160c56a802c8b477a1a975853eda2f8eff61 (patch)
tree101862e10d43061b5227ad40b65a540d23ef5fd2
parentfc6c050b409ec4697a58e8f4fc028a6a4b3d46f7 (diff)
QTimerInfo::expected is only needed for debugging
The code for calculating the expected time is only useful for debugging purposes. Don't compile this into the library unless QTIMERINFO_DEBUG is defined. Change-Id: I6530e6a70410a12544410ef286225df98ceddcee Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/kernel/qtimerinfo_unix.cpp25
-rw-r--r--src/corelib/kernel/qtimerinfo_unix_p.h2
2 files changed, 17 insertions, 10 deletions
diff --git a/src/corelib/kernel/qtimerinfo_unix.cpp b/src/corelib/kernel/qtimerinfo_unix.cpp
index c9ffee50bf..b89d4ccb30 100644
--- a/src/corelib/kernel/qtimerinfo_unix.cpp
+++ b/src/corelib/kernel/qtimerinfo_unix.cpp
@@ -342,17 +342,18 @@ static void calculateNextTimeout(QTimerInfo *t, timeval currentTime)
switch (t->timerType) {
case Qt::PreciseTimer:
case Qt::CoarseTimer:
- t->expected += t->interval;
- if (t->expected < currentTime) {
- t->expected = currentTime;
- t->expected += t->interval;
- }
-
t->timeout += t->interval;
if (t->timeout < currentTime) {
t->timeout = currentTime;
t->timeout += t->interval;
}
+#ifdef QTIMERINFO_DEBUG
+ t->expected += t->interval;
+ if (t->expected < currentTime) {
+ t->expected = currentTime;
+ t->expected += t->interval;
+ }
+#endif
if (t->timerType == Qt::CoarseTimer)
calculateCoarseTimerTimeout(t, currentTime);
return;
@@ -362,7 +363,11 @@ static void calculateNextTimeout(QTimerInfo *t, timeval currentTime)
t->timeout.tv_sec += t->interval;
if (t->timeout.tv_sec <= currentTime.tv_sec)
t->timeout.tv_sec = currentTime.tv_sec + t->interval;
+#ifdef QTIMERINFO_DEBUG
t->expected.tv_sec += t->interval;
+ if (t->expected.tv_sec <= currentTime.tv_sec)
+ t->expected.tv_sec = currentTime.tv_sec + t->interval;
+#endif
return;
}
@@ -413,15 +418,16 @@ void QTimerInfoList::registerTimer(int timerId, int interval, Qt::TimerType time
t->id = timerId;
t->interval = interval;
t->timerType = timerType;
- t->expected = updateCurrentTime() + interval;
t->obj = object;
t->activateRef = 0;
+ timeval expected = updateCurrentTime() + interval;
+
switch (timerType) {
case Qt::PreciseTimer:
// high precision timer is based on millisecond precision
// so no adjustment is necessary
- t->timeout = t->expected;
+ t->timeout = expected;
break;
case Qt::CoarseTimer:
@@ -433,7 +439,7 @@ void QTimerInfoList::registerTimer(int timerId, int interval, Qt::TimerType time
t->timerType = Qt::VeryCoarseTimer;
// fall through
} else {
- t->timeout = t->expected;
+ t->timeout = expected;
if (interval <= 20) {
t->timerType = Qt::PreciseTimer;
// no adjustment is necessary
@@ -460,6 +466,7 @@ void QTimerInfoList::registerTimer(int timerId, int interval, Qt::TimerType time
timerInsert(t);
#ifdef QTIMERINFO_DEBUG
+ t->expected = expected;
t->cumulativeError = 0;
t->count = 0;
if (t->timerType != Qt::PreciseTimer)
diff --git a/src/corelib/kernel/qtimerinfo_unix_p.h b/src/corelib/kernel/qtimerinfo_unix_p.h
index 89d4d457b0..7f651381ab 100644
--- a/src/corelib/kernel/qtimerinfo_unix_p.h
+++ b/src/corelib/kernel/qtimerinfo_unix_p.h
@@ -66,12 +66,12 @@ struct QTimerInfo {
int id; // - timer identifier
int interval; // - timer interval in milliseconds
Qt::TimerType timerType; // - timer type
- timeval expected; // when timer is expected to fire
timeval timeout; // - when to actually fire
QObject *obj; // - object to receive event
QTimerInfo **activateRef; // - ref from activateTimers
#ifdef QTIMERINFO_DEBUG
+ timeval expected; // when timer is expected to fire
float cumulativeError;
uint count;
#endif