summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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