summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorChristian Andersen <csandersen3@gmail.com>2019-01-27 17:41:15 +0100
committerChristian Andersen <csandersen3@gmail.com>2019-01-28 06:34:03 +0000
commit6a7e2fedefba69b338d859cba091cd8678e2dcc1 (patch)
tree4c1f33d7aee4752581899d2dfc690ecb60d189d5 /src/corelib/kernel
parent8b91afe12e2b53d1fccded1e91cdc3e4290042b2 (diff)
Windows: improve QTimer::remainingTime when called before processEvents
This checks that intenalHwnd in QEventDispatcherWin32::remainingTime is initialized. If calling remaningTime, before createInternalHwnd is called, the timeout member in the WinTimerInfo struct is not initialized and contains a random value. This adds a check for that and in that case returns the requested timer interval as the timer has not yet been started. createInternalHwnd is called on the first request to process events. It also adds a test for checking the remaining time. But the issue can only be seen if solely running the remainingTimeInitial test in tst_QTimer. If running the test along side another test the other test likely calls processEvents indirectly, which hides the issue. I don't know if this is an issue in practice (the bug has been there for as long a the git history goes back, 2011), but it causes the basic_chrono test to fail if run as the only test. Change-Id: I05c35105da778912dedf8d749aa7c953841d986e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index 0bddf89b15..343ed70196 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -992,8 +992,14 @@ int QEventDispatcherWin32::remainingTime(int timerId)
quint64 currentTime = qt_msectime();
for (const WinTimerInfo *t : qAsConst(d->timerVec)) {
- if (t && t->timerId == timerId) // timer found, return time to wait
- return t->timeout > currentTime ? t->timeout - currentTime : 0;
+ if (t && t->timerId == timerId) {
+ // timer found, return time to wait
+
+ if (d->internalHwnd)
+ return t->timeout > currentTime ? t->timeout - currentTime : 0;
+ else
+ return t->interval;
+ }
}
#ifndef QT_NO_DEBUG