QEventDispatcherWin32: consistently use ms precision in calculations
Windows does not support nanosecond-resolution timers, so we ceil nanosecond interval to milliseconds in registerTimers(). Later on, we also use millisecond-resolution to calculate the expected timeout. However, the remainingTime() method was using nanosecond resolution when doing the calculations. As a result, we could never get remainingTime() equal to the specified interval. This patch uses the same ceil-to-milliseconds logic in remainingTime() to make all time calculations consistent. It's not really possible to provide a reliable unit-test for this case, because we can only check that the remaining time does not exceed the specified interval. Amends 0d0b346322f6b078e6fe60cd3612e8d08a0d5f00. Task-number: QTBUG-129170 Task-number: QTBUG-132388 Change-Id: I48eaa15d55174e1925fc5eb3ca76b78d85e46f42 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
f4b64f9c12
commit
0fb3661f13
@ -801,9 +801,9 @@ QEventDispatcherWin32::Duration QEventDispatcherWin32::remainingTime(Qt::TimerId
|
||||
// timer found, return time to wait
|
||||
using namespace std::chrono;
|
||||
using namespace std::chrono_literals;
|
||||
const Duration currentTimeNs = steady_clock::now().time_since_epoch();
|
||||
const Duration timeoutNs = Duration{t->timeout * 1ms};
|
||||
return timeoutNs > currentTimeNs ? timeoutNs - currentTimeNs : 0ns;
|
||||
const auto currentTimeMs = duration_cast<milliseconds>(steady_clock::now().time_since_epoch());
|
||||
const auto timeoutMs = t->timeout * 1ms;
|
||||
return timeoutMs > currentTimeMs ? milliseconds{timeoutMs - currentTimeMs} : 0ms;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
|
Loading…
x
Reference in New Issue
Block a user