Remove dynamic loading of functions that are present in Windows Vista onwards.
Invoke functions directly and add libraries accordingly. Task-number: QTBUG-51673 Change-Id: Ie19d1fc6aa932d6e93a7d310048e4c162fb81046 Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
This commit is contained in:
parent
710ec5caed
commit
4879bc91d4
@ -54,6 +54,8 @@ win32 {
|
||||
# Override MinGW's definition in _mingw.h
|
||||
DEFINES += WINVER=0x600 _WIN32_WINNT=0x0600
|
||||
}
|
||||
|
||||
!winrt: LIBS_PRIVATE += -lwinmm
|
||||
}
|
||||
|
||||
mac|darwin {
|
||||
|
@ -47,7 +47,6 @@
|
||||
#include "qdatetime.h"
|
||||
#include <private/qlocale_tools_p.h>
|
||||
|
||||
#include <private/qsystemlibrary_p.h>
|
||||
#include <qmutex.h>
|
||||
|
||||
#ifndef QT_NO_QOBJECT
|
||||
|
@ -176,8 +176,6 @@ typedef DWORD (WINAPI *PtrGetEffectiveRightsFromAclW)(PACL, PTRUSTEE_W, OUT PACC
|
||||
static PtrGetEffectiveRightsFromAclW ptrGetEffectiveRightsFromAclW = 0;
|
||||
typedef BOOL (WINAPI *PtrGetUserProfileDirectoryW)(HANDLE, LPWSTR, LPDWORD);
|
||||
static PtrGetUserProfileDirectoryW ptrGetUserProfileDirectoryW = 0;
|
||||
typedef BOOL (WINAPI *PtrGetVolumePathNamesForVolumeNameW)(LPCWSTR,LPWSTR,DWORD,PDWORD);
|
||||
static PtrGetVolumePathNamesForVolumeNameW ptrGetVolumePathNamesForVolumeNameW = 0;
|
||||
QT_END_INCLUDE_NAMESPACE
|
||||
|
||||
static TRUSTEE_W currentUserTrusteeW;
|
||||
@ -272,9 +270,6 @@ static void resolveLibs()
|
||||
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");
|
||||
}
|
||||
}
|
||||
#endif // QT_NO_LIBRARY
|
||||
@ -349,16 +344,14 @@ static QString readSymLink(const QFileSystemEntry &link)
|
||||
|
||||
#if !defined(QT_NO_LIBRARY)
|
||||
resolveLibs();
|
||||
if (ptrGetVolumePathNamesForVolumeNameW) {
|
||||
QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive);
|
||||
if (matchVolName.indexIn(result) == 0) {
|
||||
DWORD len;
|
||||
wchar_t buffer[MAX_PATH];
|
||||
QString volumeName = result.mid(0, matchVolName.matchedLength()).prepend(QLatin1String("\\\\?\\"));
|
||||
if(ptrGetVolumePathNamesForVolumeNameW((wchar_t*)volumeName.utf16(), buffer, MAX_PATH, &len) != 0)
|
||||
if (GetVolumePathNamesForVolumeName(reinterpret_cast<LPCWSTR>(volumeName.utf16()), buffer, MAX_PATH, &len) != 0)
|
||||
result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer));
|
||||
}
|
||||
}
|
||||
#endif // !Q_OS_WINRT
|
||||
}
|
||||
#else
|
||||
@ -583,23 +576,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
|
||||
return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
|
||||
}
|
||||
|
||||
// FILE_INFO_BY_HANDLE_CLASS has been extended by FileIdInfo = 18 as of VS2012.
|
||||
typedef enum { Q_FileIdInfo = 18 } Q_FILE_INFO_BY_HANDLE_CLASS;
|
||||
|
||||
# if defined(Q_CC_MINGW) || (defined(Q_CC_MSVC) && (_MSC_VER < 1700 || WINVER <= 0x0601))
|
||||
|
||||
// MinGW-64 defines FILE_ID_128 as of gcc-4.8.1 along with FILE_SUPPORTS_INTEGRITY_STREAMS
|
||||
# if !(defined(Q_CC_MINGW) && defined(FILE_SUPPORTS_INTEGRITY_STREAMS))
|
||||
typedef struct _FILE_ID_128 {
|
||||
BYTE Identifier[16];
|
||||
} FILE_ID_128, *PFILE_ID_128;
|
||||
# endif // !(Q_CC_MINGW && FILE_SUPPORTS_INTEGRITY_STREAMS)
|
||||
#if defined(Q_CC_MINGW) && WINVER < 0x0602 // Windows 8 onwards
|
||||
|
||||
typedef struct _FILE_ID_INFO {
|
||||
ULONGLONG VolumeSerialNumber;
|
||||
FILE_ID_128 FileId;
|
||||
} FILE_ID_INFO, *PFILE_ID_INFO;
|
||||
# endif // if defined (Q_CC_MINGW) || (defined(Q_CC_MSVC) && (_MSC_VER < 1700 || WINVER <= 0x0601))
|
||||
|
||||
#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
|
||||
|
||||
// File ID for Windows up to version 7.
|
||||
static inline QByteArray fileId(HANDLE handle)
|
||||
@ -622,37 +606,21 @@ static inline QByteArray fileId(HANDLE handle)
|
||||
// File ID for Windows starting from version 8.
|
||||
QByteArray fileIdWin8(HANDLE handle)
|
||||
{
|
||||
#ifndef Q_OS_WINRT
|
||||
typedef BOOL (WINAPI* GetFileInformationByHandleExType)(HANDLE, Q_FILE_INFO_BY_HANDLE_CLASS, void *, DWORD);
|
||||
|
||||
// Dynamically resolve GetFileInformationByHandleEx (Vista onwards).
|
||||
static GetFileInformationByHandleExType getFileInformationByHandleEx = 0;
|
||||
if (!getFileInformationByHandleEx) {
|
||||
QSystemLibrary library(QLatin1String("kernel32"));
|
||||
getFileInformationByHandleEx = (GetFileInformationByHandleExType)library.resolve("GetFileInformationByHandleEx");
|
||||
}
|
||||
#if !defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE)
|
||||
QByteArray result;
|
||||
if (getFileInformationByHandleEx) {
|
||||
FILE_ID_INFO infoEx;
|
||||
if (getFileInformationByHandleEx(handle, Q_FileIdInfo,
|
||||
if (GetFileInformationByHandleEx(handle,
|
||||
static_cast<FILE_INFO_BY_HANDLE_CLASS>(18), // FileIdInfo in Windows 8
|
||||
&infoEx, sizeof(FILE_ID_INFO))) {
|
||||
result = QByteArray::number(infoEx.VolumeSerialNumber, 16);
|
||||
result += ':';
|
||||
// Note: MinGW-64's definition of FILE_ID_128 differs from the MSVC one.
|
||||
result += QByteArray((char *)&infoEx.FileId, sizeof(infoEx.FileId)).toHex();
|
||||
result += QByteArray(reinterpret_cast<const char *>(&infoEx.FileId), int(sizeof(infoEx.FileId))).toHex();
|
||||
}
|
||||
}
|
||||
#else // !Q_OS_WINRT
|
||||
QByteArray result;
|
||||
FILE_ID_INFO infoEx;
|
||||
if (GetFileInformationByHandleEx(handle, FileIdInfo,
|
||||
&infoEx, sizeof(FILE_ID_INFO))) {
|
||||
result = QByteArray::number(infoEx.VolumeSerialNumber, 16);
|
||||
result += ':';
|
||||
result += QByteArray((char *)infoEx.FileId.Identifier, sizeof(infoEx.FileId.Identifier)).toHex();
|
||||
}
|
||||
#endif // Q_OS_WINRT
|
||||
return result;
|
||||
#else // !QT_BOOTSTRAPPED && !QT_BUILD_QMAKE
|
||||
return fileId(handle);
|
||||
#endif
|
||||
}
|
||||
|
||||
//static
|
||||
|
@ -81,7 +81,6 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef Q_OS_WIN // for homedirpath reading from registry
|
||||
# include <private/qsystemlibrary_p.h>
|
||||
# include <qt_windows.h>
|
||||
# ifndef Q_OS_WINRT
|
||||
# include <shlobj.h>
|
||||
|
@ -91,35 +91,13 @@ class QEventDispatcherWin32Private;
|
||||
#define DWORD_PTR DWORD
|
||||
#endif
|
||||
|
||||
typedef MMRESULT(WINAPI *ptimeSetEvent)(UINT, UINT, LPTIMECALLBACK, DWORD_PTR, UINT);
|
||||
typedef MMRESULT(WINAPI *ptimeKillEvent)(UINT);
|
||||
|
||||
static ptimeSetEvent qtimeSetEvent = 0;
|
||||
static ptimeKillEvent qtimeKillEvent = 0;
|
||||
|
||||
LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp);
|
||||
|
||||
static void resolveTimerAPI()
|
||||
{
|
||||
static bool triedResolve = false;
|
||||
if (!triedResolve) {
|
||||
#ifndef QT_NO_THREAD
|
||||
QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve));
|
||||
if (triedResolve)
|
||||
return;
|
||||
#endif
|
||||
triedResolve = true;
|
||||
qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeSetEvent");
|
||||
qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeKillEvent");
|
||||
}
|
||||
}
|
||||
|
||||
QEventDispatcherWin32Private::QEventDispatcherWin32Private()
|
||||
: threadId(GetCurrentThreadId()), interrupt(false), closingDown(false), internalHwnd(0),
|
||||
getMessageHook(0), serialNumber(0), lastSerialNumber(0), sendPostedEventsWindowsTimerId(0),
|
||||
wakeUps(0), activateNotifiersPosted(false)
|
||||
{
|
||||
resolveTimerAPI();
|
||||
}
|
||||
|
||||
QEventDispatcherWin32Private::~QEventDispatcherWin32Private()
|
||||
@ -394,24 +372,27 @@ void QEventDispatcherWin32Private::registerTimer(WinTimerInfo *t)
|
||||
|
||||
Q_Q(QEventDispatcherWin32);
|
||||
|
||||
int ok = 0;
|
||||
bool ok = false;
|
||||
calculateNextTimeout(t, qt_msectime());
|
||||
uint interval = t->interval;
|
||||
if (interval == 0u) {
|
||||
// optimization for single-shot-zero-timer
|
||||
QCoreApplication::postEvent(q, new QZeroTimerEvent(t->timerId));
|
||||
ok = 1;
|
||||
} else if ((interval < 20u || t->timerType == Qt::PreciseTimer) && qtimeSetEvent) {
|
||||
ok = t->fastTimerId = qtimeSetEvent(interval, 1, qt_fast_timer_proc, (DWORD_PTR)t,
|
||||
ok = true;
|
||||
} else if (interval < 20u || t->timerType == Qt::PreciseTimer) {
|
||||
// 3/2016: Although MSDN states timeSetEvent() is deprecated, the function
|
||||
// is still deemed to be the most reliable precision timer.
|
||||
t->fastTimerId = timeSetEvent(interval, 1, qt_fast_timer_proc, DWORD_PTR(t),
|
||||
TIME_CALLBACK_FUNCTION | TIME_PERIODIC | TIME_KILL_SYNCHRONOUS);
|
||||
ok = t->fastTimerId;
|
||||
}
|
||||
|
||||
if (ok == 0) {
|
||||
if (!ok) {
|
||||
// user normal timers for (Very)CoarseTimers, or if no more multimedia timers available
|
||||
ok = SetTimer(internalHwnd, t->timerId, interval, 0);
|
||||
}
|
||||
|
||||
if (ok == 0)
|
||||
if (!ok)
|
||||
qErrnoWarning("QEventDispatcherWin32::registerTimer: Failed to create a timer");
|
||||
}
|
||||
|
||||
@ -420,7 +401,7 @@ void QEventDispatcherWin32Private::unregisterTimer(WinTimerInfo *t)
|
||||
if (t->interval == 0) {
|
||||
QCoreApplicationPrivate::removePostedTimerEvent(t->dispatcher, t->timerId);
|
||||
} else if (t->fastTimerId != 0) {
|
||||
qtimeKillEvent(t->fastTimerId);
|
||||
timeKillEvent(t->fastTimerId);
|
||||
QCoreApplicationPrivate::removePostedTimerEvent(t->dispatcher, t->timerId);
|
||||
} else if (internalHwnd) {
|
||||
KillTimer(internalHwnd, t->timerId);
|
||||
|
@ -138,7 +138,7 @@ struct WinTimerInfo { // internal timer info
|
||||
quint64 timeout; // - when to actually fire
|
||||
QObject *obj; // - object to receive events
|
||||
bool inTimerEvent;
|
||||
int fastTimerId;
|
||||
UINT fastTimerId;
|
||||
};
|
||||
|
||||
class QZeroTimerEvent : public QTimerEvent
|
||||
|
@ -62,7 +62,6 @@
|
||||
#include "qvariant.h"
|
||||
#include "qstringbuilder.h"
|
||||
#include "private/qnumeric_p.h"
|
||||
#include "private/qsystemlibrary_p.h"
|
||||
#ifdef Q_OS_WIN
|
||||
# include <qt_windows.h>
|
||||
# include <time.h>
|
||||
|
@ -44,9 +44,6 @@
|
||||
#include "qstringlist.h"
|
||||
#include "qvariant.h"
|
||||
#include "qdatetime.h"
|
||||
|
||||
#include "private/qsystemlibrary_p.h"
|
||||
|
||||
#include "qdebug.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
@ -67,7 +64,6 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef Q_OS_WINRT
|
||||
static QByteArray getWinLocaleName(LCID id = LOCALE_USER_DEFAULT);
|
||||
static const char *winLangCodeToIsoName(int code);
|
||||
static QString winIso639LangName(LCID id = LOCALE_USER_DEFAULT);
|
||||
static QString winIso3116CtryName(LCID id = LOCALE_USER_DEFAULT);
|
||||
#else // !Q_OS_WINRT
|
||||
@ -600,33 +596,21 @@ QVariant QSystemLocalePrivate::toCurrencyString(const QSystemLocale::CurrencyToS
|
||||
|
||||
QVariant QSystemLocalePrivate::uiLanguages()
|
||||
{
|
||||
if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) {
|
||||
typedef BOOL (WINAPI *GetUserPreferredUILanguagesFunc) (
|
||||
DWORD dwFlags,
|
||||
PULONG pulNumLanguages,
|
||||
PWSTR pwszLanguagesBuffer,
|
||||
PULONG pcchLanguagesBuffer);
|
||||
static GetUserPreferredUILanguagesFunc GetUserPreferredUILanguages_ptr = 0;
|
||||
#ifndef Q_OS_WINRT
|
||||
if (!GetUserPreferredUILanguages_ptr) {
|
||||
QSystemLibrary lib(QLatin1String("kernel32"));
|
||||
if (lib.load())
|
||||
GetUserPreferredUILanguages_ptr = (GetUserPreferredUILanguagesFunc)lib.resolve("GetUserPreferredUILanguages");
|
||||
}
|
||||
#endif // !Q_OS_WINRT
|
||||
if (GetUserPreferredUILanguages_ptr) {
|
||||
unsigned long cnt = 0;
|
||||
QVarLengthArray<wchar_t, 64> buf(64);
|
||||
# if !defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE) // Not present in MinGW 4.9/bootstrap builds.
|
||||
unsigned long size = buf.size();
|
||||
if (!GetUserPreferredUILanguages_ptr(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size)) {
|
||||
if (!GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size)) {
|
||||
size = 0;
|
||||
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER &&
|
||||
GetUserPreferredUILanguages_ptr(MUI_LANGUAGE_NAME, &cnt, NULL, &size)) {
|
||||
GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &cnt, NULL, &size)) {
|
||||
buf.resize(size);
|
||||
if (!GetUserPreferredUILanguages_ptr(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size))
|
||||
if (!GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size))
|
||||
return QStringList();
|
||||
}
|
||||
}
|
||||
# endif // !QT_BOOTSTRAPPED && !QT_BUILD_QMAKE
|
||||
QStringList result;
|
||||
result.reserve(cnt);
|
||||
const wchar_t *str = buf.constData();
|
||||
@ -638,12 +622,6 @@ QVariant QSystemLocalePrivate::uiLanguages()
|
||||
str += s.size() + 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef Q_OS_WINRT
|
||||
// old Windows before Vista
|
||||
return QStringList(QString::fromLatin1(winLangCodeToIsoName(GetUserDefaultUILanguage())));
|
||||
#else // !Q_OS_WINRT
|
||||
QStringList result;
|
||||
ComPtr<ABI::Windows::Globalization::IApplicationLanguagesStatics> appLanguagesStatics;
|
||||
|
Loading…
Reference in New Issue
Block a user