summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorThomas Sondergaard <ts@medical-insight.com>2009-06-04 11:06:31 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-06-04 11:11:40 (GMT)
commitc4773c1b2372ac9119244c5af6d0f0dae3e8f685 (patch)
tree2ff58dff5018de56a86320ea1ae404da6de13912 /src/corelib/kernel
parentdf5c557e7777c8844ac866d730346178ad33a0a6 (diff)
downloadQt-c4773c1b2372ac9119244c5af6d0f0dae3e8f685.zip
Qt-c4773c1b2372ac9119244c5af6d0f0dae3e8f685.tar.gz
Qt-c4773c1b2372ac9119244c5af6d0f0dae3e8f685.tar.bz2
Don't use inactivatable timers to calculate time to wait for next timer.
This patch prevents the eventloop from waking up needlessly. Without this patch the event loop will not sleep at all if a 0-timer is already 'inTimerEvent' Merge-request: 550 Reviewed-by: Olivier Goffart <ogoffart@trolltech.com>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp
index 6aa3b56..f7293d4 100644
--- a/src/corelib/kernel/qeventdispatcher_unix.cpp
+++ b/src/corelib/kernel/qeventdispatcher_unix.cpp
@@ -420,10 +420,18 @@ bool QTimerInfoList::timerWait(timeval &tm)
timeval currentTime = updateCurrentTime();
repairTimersIfNeeded();
- if (isEmpty())
- return false;
+ // Find first waiting timer not already active
+ QTimerInfo *t = 0;
+ for (QTimerInfoList::const_iterator it = constBegin(); it != constEnd(); ++it) {
+ if (!(*it)->inTimerEvent) {
+ t = *it;
+ break;
+ }
+ }
+
+ if (!t)
+ return false;
- QTimerInfo *t = first(); // first waiting timer
if (currentTime < t->timeout) {
// time to wait
tm = t->timeout - currentTime;