summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qelapsedtimer_win.cpp
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2011-10-07 12:45:12 (GMT)
committerJan-Arve Saether <jan-arve.saether@nokia.com>2011-10-07 12:45:12 (GMT)
commit48a73353029104a4d2c5fda2c9fb007d1924c9ec (patch)
treefbfee63d17157f8ff57452273f041f94a863c38e /src/corelib/tools/qelapsedtimer_win.cpp
parent6425f239d1e01e1b55cfadde8f95ab884f4dd76c (diff)
downloadQt-48a73353029104a4d2c5fda2c9fb007d1924c9ec.zip
Qt-48a73353029104a4d2c5fda2c9fb007d1924c9ec.tar.gz
Qt-48a73353029104a4d2c5fda2c9fb007d1924c9ec.tar.bz2
make QElapsedTimer use QSystemLibrary on win
we also need to ensure the counterFrequency was already set up, thus volatile (which fixes possible race condition) Merge-request: 2655 Reviewed-by: Jan-Arve Saether <jan-arve.saether@nokia.com>
Diffstat (limited to 'src/corelib/tools/qelapsedtimer_win.cpp')
-rw-r--r--src/corelib/tools/qelapsedtimer_win.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/corelib/tools/qelapsedtimer_win.cpp b/src/corelib/tools/qelapsedtimer_win.cpp
index d79dc5d..e6bce27 100644
--- a/src/corelib/tools/qelapsedtimer_win.cpp
+++ b/src/corelib/tools/qelapsedtimer_win.cpp
@@ -42,6 +42,8 @@
#include "qelapsedtimer.h"
#include <windows.h>
+#include <private/qsystemlibrary_p.h>
+
typedef ULONGLONG (WINAPI *PtrGetTickCount64)(void);
static PtrGetTickCount64 ptrGetTickCount64 = 0;
@@ -52,21 +54,17 @@ static quint64 counterFrequency = 0;
static void resolveLibs()
{
- static bool done = false;
+ static volatile bool done = false;
if (done)
return;
// try to get GetTickCount64 from the system
- HMODULE kernel32 = GetModuleHandleW(L"kernel32");
- if (!kernel32)
+ QSystemLibrary kernel32(QLatin1String("kernel32"));
+ if (!kernel32.load())
return;
-#if defined(Q_OS_WINCE)
// does this function exist on WinCE, or will ever exist?
- ptrGetTickCount64 = (PtrGetTickCount64)GetProcAddress(kernel32, L"GetTickCount64");
-#else
- ptrGetTickCount64 = (PtrGetTickCount64)GetProcAddress(kernel32, "GetTickCount64");
-#endif
+ ptrGetTickCount64 = (PtrGetTickCount64)kernel32.resolve("GetTickCount64");
// Retrieve the number of high-resolution performance counter ticks per second
LARGE_INTEGER frequency;