diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qfile.cpp | 5 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemengine_win.cpp | 44 | ||||
-rw-r--r-- | src/corelib/io/qiodevice.cpp | 6 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_symbian.cpp | 26 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_win.cpp | 21 | ||||
-rw-r--r-- | src/corelib/kernel/qtranslator.cpp | 40 | ||||
-rw-r--r-- | src/corelib/plugin/qsystemlibrary.cpp | 15 | ||||
-rw-r--r-- | src/corelib/plugin/qsystemlibrary_p.h | 9 | ||||
-rw-r--r-- | src/corelib/thread/qmutex_p.h | 8 | ||||
-rw-r--r-- | src/corelib/thread/qmutex_unix.cpp | 50 | ||||
-rw-r--r-- | src/corelib/tools/qelapsedtimer_win.cpp | 14 |
11 files changed, 131 insertions, 107 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index d08574d..cdee7ce 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -918,6 +918,7 @@ QFile::copy(const QString &newName) #endif if (error) { out.close(); + close(); d->setError(QFile::CopyError, tr("Cannot open for output")); } else { char block[4096]; @@ -928,6 +929,7 @@ QFile::copy(const QString &newName) break; totalRead += in; if(in != out.write(block, in)) { + close(); d->setError(QFile::CopyError, tr("Failure to write block")); error = true; break; @@ -941,6 +943,7 @@ QFile::copy(const QString &newName) } if (!error && !out.rename(newName)) { error = true; + close(); d->setError(QFile::CopyError, tr("Cannot create %1 for output").arg(newName)); } #ifdef QT_NO_TEMPORARYFILE @@ -951,10 +954,10 @@ QFile::copy(const QString &newName) out.setAutoRemove(false); #endif } - close(); } if(!error) { QFile::setPermissions(newName, permissions()); + close(); unsetError(); return true; } diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 28a7267..86b9496 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -186,14 +186,13 @@ static void resolveLibs() } #endif - triedResolve = true; #if !defined(Q_OS_WINCE) - HINSTANCE advapiHnd = QSystemLibrary::load(L"advapi32"); - if (advapiHnd) { - ptrGetNamedSecurityInfoW = (PtrGetNamedSecurityInfoW)GetProcAddress(advapiHnd, "GetNamedSecurityInfoW"); - ptrLookupAccountSidW = (PtrLookupAccountSidW)GetProcAddress(advapiHnd, "LookupAccountSidW"); - ptrBuildTrusteeWithSidW = (PtrBuildTrusteeWithSidW)GetProcAddress(advapiHnd, "BuildTrusteeWithSidW"); - ptrGetEffectiveRightsFromAclW = (PtrGetEffectiveRightsFromAclW)GetProcAddress(advapiHnd, "GetEffectiveRightsFromAclW"); + QSystemLibrary advapi32(QLatin1String("advapi32")); + if (advapi32.load()) { + ptrGetNamedSecurityInfoW = (PtrGetNamedSecurityInfoW)advapi32.resolve("GetNamedSecurityInfoW"); + ptrLookupAccountSidW = (PtrLookupAccountSidW)advapi32.resolve("LookupAccountSidW"); + ptrBuildTrusteeWithSidW = (PtrBuildTrusteeWithSidW)advapi32.resolve("BuildTrusteeWithSidW"); + ptrGetEffectiveRightsFromAclW = (PtrGetEffectiveRightsFromAclW)advapi32.resolve("GetEffectiveRightsFromAclW"); } if (ptrBuildTrusteeWithSidW) { // Create TRUSTEE for current user @@ -208,9 +207,9 @@ static void resolveLibs() } typedef BOOL (WINAPI *PtrAllocateAndInitializeSid)(PSID_IDENTIFIER_AUTHORITY, BYTE, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, PSID*); - PtrAllocateAndInitializeSid ptrAllocateAndInitializeSid = (PtrAllocateAndInitializeSid)GetProcAddress(advapiHnd, "AllocateAndInitializeSid"); + PtrAllocateAndInitializeSid ptrAllocateAndInitializeSid = (PtrAllocateAndInitializeSid)advapi32.resolve("AllocateAndInitializeSid"); typedef PVOID (WINAPI *PtrFreeSid)(PSID); - PtrFreeSid ptrFreeSid = (PtrFreeSid)GetProcAddress(advapiHnd, "FreeSid"); + PtrFreeSid ptrFreeSid = (PtrFreeSid)advapi32.resolve("FreeSid"); if (ptrAllocateAndInitializeSid && ptrFreeSid) { // Create TRUSTEE for Everyone (World) SID_IDENTIFIER_AUTHORITY worldAuth = { SECURITY_WORLD_SID_AUTHORITY }; @@ -220,13 +219,16 @@ static void resolveLibs() ptrFreeSid(pWorld); } } - HINSTANCE userenvHnd = QSystemLibrary::load(L"userenv"); - if (userenvHnd) - ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW"); - HINSTANCE kernel32 = LoadLibrary(L"kernel32"); - if(kernel32) - ptrGetVolumePathNamesForVolumeNameW = (PtrGetVolumePathNamesForVolumeNameW)GetProcAddress(kernel32, "GetVolumePathNamesForVolumeNameW"); + + QSystemLibrary userenv(QLatin1String("userenv")); + if (userenv.load()) + ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)userenv.resolve("GetUserProfileDirectoryW"); + + QSystemLibrary kernel32(QLatin1String("kernel32")); + if (kernel32.load()) + ptrGetVolumePathNamesForVolumeNameW = (PtrGetVolumePathNamesForVolumeNameW)kernel32.resolve("GetVolumePathNamesForVolumeNameW"); #endif + triedResolve = true; } } #endif // QT_NO_LIBRARY @@ -252,15 +254,15 @@ static bool resolveUNCLibs() return ptrNetShareEnum && ptrNetApiBufferFree; } #endif - triedResolve = true; + #if !defined(Q_OS_WINCE) - HINSTANCE hLib = QSystemLibrary::load(L"Netapi32"); - if (hLib) { - ptrNetShareEnum = (PtrNetShareEnum)GetProcAddress(hLib, "NetShareEnum"); - if (ptrNetShareEnum) - ptrNetApiBufferFree = (PtrNetApiBufferFree)GetProcAddress(hLib, "NetApiBufferFree"); + QSystemLibrary netapi32(QLatin1String("Netapi32")); + if (netapi32.load()) { + ptrNetShareEnum = (PtrNetShareEnum)netapi32.resolve("NetShareEnum"); + ptrNetApiBufferFree = (PtrNetApiBufferFree)netapi32.resolve("NetApiBufferFree"); } #endif + triedResolve = true; } return ptrNetShareEnum && ptrNetApiBufferFree; } diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index dae4e82..56fff90 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -468,11 +468,17 @@ void QIODevice::setOpenMode(OpenMode openMode) otherwise the \l Text flag is removed. This feature is useful for classes that provide custom end-of-line handling on a QIODevice. + The IO device should be opened before calling this function. + \sa open(), setOpenMode() */ void QIODevice::setTextModeEnabled(bool enabled) { Q_D(QIODevice); + if (!isOpen()) { + qWarning("QIODevice::setTextModeEnabled: The device is not open"); + return; + } if (enabled) d->openMode |= Text; else diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index b216075..fca2feb 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -60,6 +60,24 @@ QT_BEGIN_NAMESPACE #define WAKE_UP_PRIORITY CActive::EPriorityStandard #define TIMER_PRIORITY CActive::EPriorityHigh +class Incrementer { + int &variable; +public: + inline Incrementer(int &variable) : variable(variable) + { ++variable; } + inline ~Incrementer() + { --variable; } +}; + +class Decrementer { + int &variable; +public: + inline Decrementer(int &variable) : variable(variable) + { --variable; } + inline ~Decrementer() + { ++variable; } +}; + static inline int qt_pipe_write(int socket, const char *data, qint64 len) { return ::write(socket, data, len); @@ -951,6 +969,8 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla #endif while (1) { + //native active object callbacks are logically part of the event loop, so inc nesting level + Incrementer inc(d->threadData->loopLevel); if (block) { // This is where Qt will spend most of its time. CActiveScheduler::Current()->WaitForAnyRequest(); @@ -1045,6 +1065,7 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla void QEventDispatcherSymbian::timerFired(int timerId) { + Q_D(QAbstractEventDispatcher); QHash<int, SymbianTimerInfoPtr>::iterator i = m_timerList.find(timerId); if (i == m_timerList.end()) { // The timer has been deleted. Ignore this event. @@ -1063,6 +1084,8 @@ void QEventDispatcherSymbian::timerFired(int timerId) m_insideTimerEvent = true; QTimerEvent event(timerInfo->timerId); + //undo the added nesting level around RunIfReady, since Qt's event system also nests + Decrementer dec(d->threadData->loopLevel); QCoreApplication::sendEvent(timerInfo->receiver, &event); m_insideTimerEvent = oldInsideTimerEventValue; @@ -1073,6 +1096,7 @@ void QEventDispatcherSymbian::timerFired(int timerId) void QEventDispatcherSymbian::wakeUpWasCalled() { + Q_D(QAbstractEventDispatcher); // The reactivation should happen in RunL, right before the call to this function. // This is because m_wakeUpDone is the "signal" that the object can be completed // once more. @@ -1082,6 +1106,8 @@ void QEventDispatcherSymbian::wakeUpWasCalled() // the sendPostedEvents was done, but before the object was ready to be completed // again. This could deadlock the application if there are no other posted events. m_wakeUpDone.fetchAndStoreOrdered(0); + //undo the added nesting level around RunIfReady, since Qt's event system also nests + Decrementer dec(d->threadData->loopLevel); sendPostedEvents(); } diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 84663fa..c135c4a 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -53,7 +53,6 @@ #include "qabstracteventdispatcher_p.h" #include "qcoreapplication_p.h" #include <private/qthread_p.h> -#include <private/qmutexpool_p.h> QT_BEGIN_NAMESPACE @@ -322,19 +321,17 @@ static void resolveTimerAPI() { static bool triedResolve = false; if (!triedResolve) { -#ifndef QT_NO_THREAD - QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve)); - if (triedResolve) - return; -#endif - triedResolve = true; -#if !defined(Q_OS_WINCE) - qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeSetEvent"); - qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeKillEvent"); +#ifndef Q_OS_WINCE + QSystemLibrary library(QLatin1String("Mmtimer")); #else - qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("Mmtimer"), "timeSetEvent"); - qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("Mmtimer"), "timeKillEvent"); + QSystemLibrary library(QLatin1String("winmm")); #endif + if (library.load()) { + qtimeSetEvent = (ptimeSetEvent)library.resolve("timeSetEvent"); + qtimeKillEvent = (ptimeKillEvent)library.resolve("timeKillEvent"); + } + + triedResolve = true; } } diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index d255422..dfc90e8 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -51,6 +51,7 @@ #include "qcoreapplication.h" #include "qcoreapplication_p.h" #include "qdatastream.h" +#include "qdir.h" #include "qfile.h" #include "qmap.h" #include "qalgorithms.h" @@ -63,6 +64,10 @@ #include "private/qcore_unix_p.h" #endif +#ifdef Q_OS_SYMBIAN +#include "private/qcore_symbian_p.h" +#endif + // most of the headers below are already included in qplatformdefs.h // also this lacks Large File support but that's probably irrelevant #if defined(QT_USE_MMAP) @@ -405,11 +410,24 @@ bool QTranslator::load(const QString & filename, const QString & directory, QString prefix; if (QFileInfo(filename).isRelative()) { +#ifdef Q_OS_SYMBIAN + if (directory.isEmpty()) + prefix = QCoreApplication::applicationDirPath(); + else + prefix = QFileInfo(directory).absoluteFilePath(); //TFindFile doesn't like dirty paths + if (prefix.length() > 2 && prefix.at(1) == QLatin1Char(':') && prefix.at(0).isLetter()) + prefix[0] = QLatin1Char('Y'); +#else prefix = directory; - if (prefix.length() && !prefix.endsWith(QLatin1Char('/'))) - prefix += QLatin1Char('/'); +#endif + if (prefix.length() && !prefix.endsWith(QLatin1Char('/'))) + prefix += QLatin1Char('/'); } +#ifdef Q_OS_SYMBIAN + QString nativePrefix = QDir::toNativeSeparators(prefix); +#endif + QString fname = filename; QString realname; QString delims; @@ -418,6 +436,24 @@ bool QTranslator::load(const QString & filename, const QString & directory, for (;;) { QFileInfo fi; +#ifdef Q_OS_SYMBIAN + //search for translations on other drives, e.g. Qt may be in Z, while app is in C + //note this uses symbian search rules, i.e. y:->a:, followed by z: + TFindFile finder(qt_s60GetRFs()); + QString fname2 = fname + (suffix.isNull() ? QString::fromLatin1(".qm") : suffix); + TInt err = finder.FindByDir( + qt_QString2TPtrC(fname2), + qt_QString2TPtrC(nativePrefix)); + if (err != KErrNone) + err = finder.FindByDir(qt_QString2TPtrC(fname), qt_QString2TPtrC(nativePrefix)); + if (err == KErrNone) { + fi.setFile(qt_TDesC2QString(finder.File())); + realname = fi.canonicalFilePath(); + if (fi.isReadable() && fi.isFile()) + break; + } +#endif + realname = prefix + fname + (suffix.isNull() ? QString::fromLatin1(".qm") : suffix); fi.setFile(realname); if (fi.isReadable() && fi.isFile()) diff --git a/src/corelib/plugin/qsystemlibrary.cpp b/src/corelib/plugin/qsystemlibrary.cpp index bb9c82a..7296c5b 100644 --- a/src/corelib/plugin/qsystemlibrary.cpp +++ b/src/corelib/plugin/qsystemlibrary.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qsystemlibrary_p.h" + #include <QtCore/qvarlengtharray.h> #include <QtCore/qstringlist.h> #include <QtCore/qfileinfo.h> @@ -91,7 +92,7 @@ HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirect extern QString qAppFileName(); #endif -static QString qSystemDirectory() +static inline QString qSystemDirectory() { QVarLengthArray<wchar_t, MAX_PATH> fullPath; @@ -115,27 +116,25 @@ HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirect searchOrder << qSystemDirectory(); if (!onlySystemDirectory) { - const QString PATH(QLatin1String(qgetenv("PATH").constData())); + const QString PATH = QString::fromWCharArray((const wchar_t *)_wgetenv(L"PATH")); searchOrder << PATH.split(QLatin1Char(';'), QString::SkipEmptyParts); } - QString fileName = QString::fromWCharArray(libraryName); - fileName.append(QLatin1String(".dll")); + const QString fileName = QString::fromWCharArray(libraryName) + QLatin1String(".dll"); // Start looking in the order specified for (int i = 0; i < searchOrder.count(); ++i) { QString fullPathAttempt = searchOrder.at(i); - if (!fullPathAttempt.endsWith(QLatin1Char('\\'))) { + if (!fullPathAttempt.endsWith(QLatin1Char('\\'))) fullPathAttempt.append(QLatin1Char('\\')); - } fullPathAttempt.append(fileName); HINSTANCE inst = ::LoadLibrary((const wchar_t *)fullPathAttempt.utf16()); if (inst != 0) return inst; } - return 0; + return 0; } -#endif //Q_OS_WINCE +#endif // !Q_OS_WINCE QT_END_NAMESPACE diff --git a/src/corelib/plugin/qsystemlibrary_p.h b/src/corelib/plugin/qsystemlibrary_p.h index f20d0b6..88ab82c 100644 --- a/src/corelib/plugin/qsystemlibrary_p.h +++ b/src/corelib/plugin/qsystemlibrary_p.h @@ -85,9 +85,9 @@ public: if (!m_handle) return 0; #ifdef Q_OS_WINCE - return (void*)GetProcAddress(m_handle, (const wchar_t*)QString::fromLatin1(symbol).utf16()); + return (void*)GetProcAddress(m_handle, (const wchar_t*)QString::fromLatin1(symbol).utf16()); #else - return (void*)GetProcAddress(m_handle, symbol); + return (void*)GetProcAddress(m_handle, symbol); #endif } @@ -97,6 +97,7 @@ public: } static Q_CORE_EXPORT HINSTANCE load(const wchar_t *lpFileName, bool onlySystemDirectory = true); + private: HINSTANCE m_handle; QString m_libraryName; @@ -105,6 +106,6 @@ private: QT_END_NAMESPACE -#endif //Q_OS_WIN +#endif // Q_OS_WIN -#endif //QSYSTEMLIBRARY_P_H +#endif // QSYSTEMLIBRARY_P_H diff --git a/src/corelib/thread/qmutex_p.h b/src/corelib/thread/qmutex_p.h index a9923c4..d2ffd28 100644 --- a/src/corelib/thread/qmutex_p.h +++ b/src/corelib/thread/qmutex_p.h @@ -58,10 +58,6 @@ #include <QtCore/qnamespace.h> #include <QtCore/qmutex.h> -#if defined(Q_OS_MAC) -# include <mach/semaphore.h> -#endif - #if defined(Q_OS_SYMBIAN) # include <e32std.h> #endif @@ -83,9 +79,7 @@ public: Qt::HANDLE owner; uint count; -#if defined(Q_OS_MAC) - semaphore_t mach_semaphore; -#elif defined(Q_OS_UNIX) && !defined(Q_OS_LINUX) && !defined(Q_OS_SYMBIAN) +#if defined(Q_OS_UNIX) && !defined(Q_OS_LINUX) && !defined(Q_OS_SYMBIAN) volatile bool wakeup; pthread_mutex_t mutex; pthread_cond_t cond; diff --git a/src/corelib/thread/qmutex_unix.cpp b/src/corelib/thread/qmutex_unix.cpp index 2a9d23c..790fad3 100644 --- a/src/corelib/thread/qmutex_unix.cpp +++ b/src/corelib/thread/qmutex_unix.cpp @@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE -#if !defined(Q_OS_MAC) && !defined(Q_OS_LINUX) +#if !defined(Q_OS_LINUX) static void report_error(int code, const char *where, const char *what) { if (code != 0) @@ -77,11 +77,7 @@ static void report_error(int code, const char *where, const char *what) QMutexPrivate::QMutexPrivate(QMutex::RecursionMode mode) : QMutexData(mode), maximumSpinTime(MaximumSpinTimeThreshold), averageWaitTime(0), owner(0), count(0) { -#if defined(Q_OS_MAC) - kern_return_t r = semaphore_create(mach_task_self(), &mach_semaphore, SYNC_POLICY_FIFO, 0); - if (r != KERN_SUCCESS) - qWarning("QMutex: failed to create semaphore, error %d", r); -#elif !defined(Q_OS_LINUX) +#if !defined(Q_OS_LINUX) wakeup = false; report_error(pthread_mutex_init(&mutex, NULL), "QMutex", "mutex init"); report_error(pthread_cond_init(&cond, NULL), "QMutex", "cv init"); @@ -90,47 +86,13 @@ QMutexPrivate::QMutexPrivate(QMutex::RecursionMode mode) QMutexPrivate::~QMutexPrivate() { -#if defined(Q_OS_MAC) - kern_return_t r = semaphore_destroy(mach_task_self(), mach_semaphore); - if (r != KERN_SUCCESS) - qWarning("QMutex: failed to destroy semaphore, error %d", r); -#elif !defined(Q_OS_LINUX) +#if !defined(Q_OS_LINUX) report_error(pthread_cond_destroy(&cond), "QMutex", "cv destroy"); report_error(pthread_mutex_destroy(&mutex), "QMutex", "mutex destroy"); #endif } -#if defined(Q_OS_MAC) - -bool QMutexPrivate::wait(int timeout) -{ - if (contenders.fetchAndAddAcquire(1) == 0) { - // lock acquired without waiting - return true; - } - kern_return_t r; - if (timeout < 0) { - do { - r = semaphore_wait(mach_semaphore); - } while (r == KERN_ABORTED); - if (r != KERN_SUCCESS) - qWarning("QMutex: infinite wait failed, error %d", r); - } else { - mach_timespec_t ts; - ts.tv_nsec = ((timeout % 1000) * 1000) * 1000; - ts.tv_sec = (timeout / 1000); - r = semaphore_timedwait(mach_semaphore, ts); - } - contenders.deref(); - return r == KERN_SUCCESS; -} - -void QMutexPrivate::wakeUp() -{ - semaphore_signal(mach_semaphore); -} - -#elif defined(Q_OS_LINUX) +#if defined(Q_OS_LINUX) static inline int _q_futex(volatile int *addr, int op, int val, const struct timespec *timeout, int *addr2, int val2) { @@ -174,7 +136,7 @@ void QMutexPrivate::wakeUp() (void) _q_futex(&contenders._q_value, FUTEX_WAKE, 1, 0, 0, 0); } -#else // !Q_OS_MAC && !Q_OS_LINUX +#else // !Q_OS_LINUX bool QMutexPrivate::wait(int timeout) { @@ -221,7 +183,7 @@ void QMutexPrivate::wakeUp() report_error(pthread_mutex_unlock(&mutex), "QMutex::unlock", "mutex unlock"); } -#endif // !Q_OS_MAC && !Q_OS_LINUX +#endif // !Q_OS_LINUX QT_END_NAMESPACE 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; |