summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qdeadlinetimer.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-07-05 21:52:52 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-07-07 07:21:58 +0000
commit35096261282bfb2d66373d290dfa35b993158bb8 (patch)
tree8e7ce00a9de3700c8fc16965f0ae7ea1cd7c969d /src/corelib/kernel/qdeadlinetimer.cpp
parentbcd19b723a4adad4d5f1dbbd35079cc24331dfa8 (diff)
QDeadlineTimer: round milliseconds up instead of down
Code like: QElapsedTimer timer; timer.start(); QTest::qWait(30); QVERIFY(timer.elapsed() >= 30); is failing, because qWait sleeps in increments of 10 ms and the last chunk may be off by less than one millisecond, so we end up sleeping too little and thus returning before 30 ms have elapsed. This matches the QElapsedTimer::elapsed() code that rounds down: return nsecsElapsed() / Q_INT64_C(1000000); Task-number: QTBUG-61741 Change-Id: Ic3a088f9f08a4fd7ae91fffd14cea4a91d3f51a8 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/corelib/kernel/qdeadlinetimer.cpp')
-rw-r--r--src/corelib/kernel/qdeadlinetimer.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/kernel/qdeadlinetimer.cpp b/src/corelib/kernel/qdeadlinetimer.cpp
index a2ec813f11..ae4ffdcefc 100644
--- a/src/corelib/kernel/qdeadlinetimer.cpp
+++ b/src/corelib/kernel/qdeadlinetimer.cpp
@@ -420,7 +420,7 @@ void QDeadlineTimer::setTimerType(Qt::TimerType timerType)
qint64 QDeadlineTimer::remainingTime() const Q_DECL_NOTHROW
{
qint64 ns = remainingTimeNSecs();
- return ns <= 0 ? ns : ns / (1000 * 1000);
+ return ns <= 0 ? ns : (ns + 999999) / (1000 * 1000);
}
/*!