summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qelapsedtimer_win.cpp
diff options
context:
space:
mode:
authorKai Köhne <kai.koehne@qt.io>2022-03-15 12:14:43 +0100
committerKai Köhne <kai.koehne@qt.io>2022-03-16 00:30:34 +0100
commit7d5604c19441e215c69c8f7b5a0229316373264f (patch)
treef26f19f4f87bdc4f1b660c5681fa8642fc24b352 /src/corelib/kernel/qelapsedtimer_win.cpp
parentaaa3184f8d5d14658c0c0fd7f7d9dd8bc639ffeb (diff)
Deprecate QElapsedTimer::TickCounter
Also remove left-over code paths related to it. [ChangeLog][QtCore] QElapsedTimer::TickCounter enum is now deprecated. Qt does not use the Windows API behind this enum already since Qt 5.9, so it's fair to assume that any code path relying on the enum is dead code. Change-Id: I308fe23658835034774e2015a8ee64659102de56 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qelapsedtimer_win.cpp')
-rw-r--r--src/corelib/kernel/qelapsedtimer_win.cpp41
1 files changed, 14 insertions, 27 deletions
diff --git a/src/corelib/kernel/qelapsedtimer_win.cpp b/src/corelib/kernel/qelapsedtimer_win.cpp
index deeeb05921..7d0528d5fd 100644
--- a/src/corelib/kernel/qelapsedtimer_win.cpp
+++ b/src/corelib/kernel/qelapsedtimer_win.cpp
@@ -44,7 +44,7 @@
QT_BEGIN_NAMESPACE
-// Result of QueryPerformanceFrequency, 0 indicates that the high resolution timer is unavailable
+// Result of QueryPerformanceFrequency
static quint64 counterFrequency = 0;
static void resolveCounterFrequency()
@@ -55,26 +55,19 @@ static void resolveCounterFrequency()
// Retrieve the number of high-resolution performance counter ticks per second
LARGE_INTEGER frequency;
- if (!QueryPerformanceFrequency(&frequency)) {
+ if (!QueryPerformanceFrequency(&frequency) || frequency.QuadPart == 0)
qFatal("QueryPerformanceFrequency failed, even though Microsoft documentation promises it wouldn't.");
- counterFrequency = 0;
- } else {
- counterFrequency = frequency.QuadPart;
- }
+ counterFrequency = frequency.QuadPart;
done = true;
}
static inline qint64 ticksToNanoseconds(qint64 ticks)
{
- if (counterFrequency > 0) {
- // QueryPerformanceCounter uses an arbitrary frequency
- qint64 seconds = ticks / counterFrequency;
- qint64 nanoSeconds = (ticks - seconds * counterFrequency) * 1000000000 / counterFrequency;
- return seconds * 1000000000 + nanoSeconds;
- }
- // GetTickCount(64) returns milliseconds
- return ticks * 1000000;
+ // QueryPerformanceCounter uses an arbitrary frequency
+ qint64 seconds = ticks / counterFrequency;
+ qint64 nanoSeconds = (ticks - seconds * counterFrequency) * 1000000000 / counterFrequency;
+ return seconds * 1000000000 + nanoSeconds;
}
@@ -82,18 +75,12 @@ static quint64 getTickCount()
{
resolveCounterFrequency();
- // This avoids a division by zero and disables the high performance counter if it's not available
- if (counterFrequency > 0) {
- LARGE_INTEGER counter;
-
- bool ok = QueryPerformanceCounter(&counter);
- Q_ASSERT_X(ok, "QElapsedTimer::start()",
- "QueryPerformanceCounter failed, although QueryPerformanceFrequency succeeded.");
- Q_UNUSED(ok);
- return counter.QuadPart;
- }
-
- return GetTickCount64();
+ LARGE_INTEGER counter;
+ bool ok = QueryPerformanceCounter(&counter);
+ Q_ASSERT_X(ok, "QElapsedTimer::start()",
+ "QueryPerformanceCounter failed, although QueryPerformanceFrequency succeeded.");
+ Q_UNUSED(ok);
+ return counter.QuadPart;
}
quint64 qt_msectime()
@@ -105,7 +92,7 @@ QElapsedTimer::ClockType QElapsedTimer::clockType() noexcept
{
resolveCounterFrequency();
- return counterFrequency > 0 ? PerformanceCounter : TickCounter;
+ return PerformanceCounter;
}
bool QElapsedTimer::isMonotonic() noexcept