From 45b0f1be686cfba8dcecb9be5c875cae59c69276 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Fri, 5 Jun 2020 09:24:37 +0200 Subject: Remove winrt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Macros and the await helper function from qfunctions_winrt(_p).h are needed in other Qt modules which use UWP APIs on desktop windows. Task-number: QTBUG-84434 Change-Id: Ice09c11436ad151c17bdccd2c7defadd08c13925 Reviewed-by: Tor Arne Vestbø --- src/corelib/global/archdetect.cpp | 2 +- src/corelib/global/qglobal.cpp | 37 ++++++---------------- src/corelib/global/qlibraryinfo.cpp | 8 ----- src/corelib/global/qlogging.cpp | 11 ++----- src/corelib/global/qoperatingsystemversion_win.cpp | 33 ------------------- src/corelib/global/qprocessordetection.h | 3 +- src/corelib/global/qrandom.cpp | 10 ++---- src/corelib/global/qsystemdetection.h | 16 +--------- 8 files changed, 17 insertions(+), 103 deletions(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/archdetect.cpp b/src/corelib/global/archdetect.cpp index 1d00b7f5a5..b758b2326c 100644 --- a/src/corelib/global/archdetect.cpp +++ b/src/corelib/global/archdetect.cpp @@ -95,7 +95,7 @@ #endif // pointer type -#if defined(Q_OS_WIN64) || (defined(Q_OS_WINRT) && defined(_M_X64)) +#if defined(Q_OS_WIN64) # define ARCH_POINTER "llp64" #elif defined(__LP64__) || QT_POINTER_SIZE - 0 == 8 # define ARCH_POINTER "lp64" diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 798e445ee4..4d990f5bb5 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -46,11 +46,9 @@ #include "qdatetime.h" #include "qoperatingsystemversion.h" #include "qoperatingsystemversion_p.h" -#if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) || defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) # include "qoperatingsystemversion_win_p.h" -# ifndef Q_OS_WINRT -# include "private/qwinregistry_p.h" -# endif +# include "private/qwinregistry_p.h" #endif // Q_OS_WIN || Q_OS_CYGWIN #include @@ -72,10 +70,6 @@ # include #endif -#ifdef Q_OS_WINRT -#include -#endif // Q_OS_WINRT - #ifdef Q_OS_WIN # include #endif @@ -1463,7 +1457,7 @@ bool qSharedBuild() noexcept \relates Defined on all supported versions of Windows. That is, if - \l Q_OS_WIN32, \l Q_OS_WIN64, or \l Q_OS_WINRT is defined. + \l Q_OS_WIN32 or \l Q_OS_WIN64 is defined. */ /*! @@ -1487,14 +1481,6 @@ bool qSharedBuild() noexcept Defined on 64-bit versions of Windows. */ -/*! - \macro Q_OS_WINRT - \relates - - Defined for Windows Runtime (Windows Store apps) on Windows 8, Windows RT, - and Windows Phone 8. -*/ - /*! \macro Q_OS_CYGWIN \relates @@ -2165,7 +2151,7 @@ static const char *osVer_helper(QOperatingSystemVersion version = QOperatingSyst } #endif -#elif defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) || defined(Q_OS_WINRT) +#elif defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) QT_BEGIN_INCLUDE_NAMESPACE #include "qt_windows.h" @@ -2223,7 +2209,7 @@ QT_WARNING_POP static QString readVersionRegistryString(const wchar_t *subKey) { -#if !defined(QT_BUILD_QMAKE) && !defined(Q_OS_WINRT) +#if !defined(QT_BUILD_QMAKE) return QWinRegistryKey(HKEY_LOCAL_MACHINE, LR"(SOFTWARE\Microsoft\Windows NT\CurrentVersion)") .stringValue(subKey); #else @@ -2834,8 +2820,7 @@ QString QSysInfo::kernelVersion() \b{FreeBSD note}: this function returns "debian" for Debian/kFreeBSD and "unknown" otherwise. - \b{Windows note}: this function "winrt" for WinRT builds, and "windows" - for normal desktop builds. + \b{Windows note}: this function return "windows" For other Unix-type systems, this function usually returns "unknown". @@ -2844,9 +2829,7 @@ QString QSysInfo::kernelVersion() QString QSysInfo::productType() { // similar, but not identical to QFileSelectorPrivate::platformSelectors -#if defined(Q_OS_WINRT) - return QStringLiteral("winrt"); -#elif defined(Q_OS_WIN) +#if defined(Q_OS_WIN) return QStringLiteral("windows"); #elif defined(Q_OS_QNX) @@ -2968,7 +2951,7 @@ QString QSysInfo::prettyProductName() if (!name) return result + versionString; result += QLatin1String(name); -# if !defined(Q_OS_WIN) || defined(Q_OS_WINRT) +# if !defined(Q_OS_WIN) return result + QLatin1String(" (") + versionString + QLatin1Char(')'); # else // (resembling winver.exe): Windows 10 "Windows 10 Version 1809" @@ -3104,7 +3087,7 @@ QByteArray QSysInfo::machineUniqueId() if (len != -1) return QByteArray(buffer, len); } -#elif defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#elif defined(Q_OS_WIN) // Let's poke at the registry // ### Qt 6: Use new helpers from qwinregistry.cpp (once bootstrap builds are obsolete) HKEY key = NULL; @@ -3537,7 +3520,7 @@ QByteArray qgetenv(const char *varName) */ QString qEnvironmentVariable(const char *varName, const QString &defaultValue) { -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) const auto locker = qt_scoped_lock(environmentMutex); QVarLengthArray wname(int(strlen(varName)) + 1); for (int i = 0; i < wname.size(); ++i) // wname.size() is correct: will copy terminating null diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index bfbc4ce1e5..b5164d1062 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -507,13 +507,6 @@ static QString prefixFromQtCoreLibraryHelper(const QString &qtCoreLibraryPath) #endif #if defined(Q_OS_WIN) -#if defined(Q_OS_WINRT) -EXTERN_C IMAGE_DOS_HEADER __ImageBase; -static HMODULE getWindowsModuleHandle() -{ - return reinterpret_cast(&__ImageBase); -} -#else // Q_OS_WINRT static HMODULE getWindowsModuleHandle() { HMODULE hModule = NULL; @@ -522,7 +515,6 @@ static HMODULE getWindowsModuleHandle() (LPCTSTR)&QLibraryInfo::isDebugBuild, &hModule); return hModule; } -#endif // !Q_OS_WINRT #endif // Q_OS_WIN static QString getRelocatablePrefix() diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 2966e609e7..4e78062ba7 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -226,10 +226,6 @@ static bool isDefaultCategory(const char *category) */ static bool systemHasStderr() { -#if defined(Q_OS_WINRT) - return false; // WinRT has no stderr -#endif - return true; } @@ -268,7 +264,7 @@ static bool stderrHasConsoleAttached() if (qEnvironmentVariableIntValue("QT_ASSUME_STDERR_HAS_CONSOLE")) return true; -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) return GetConsoleWindow(); #elif defined(Q_OS_UNIX) # ifndef _PATH_TTY @@ -1851,10 +1847,7 @@ static void qt_message_print(QtMsgType msgType, const QMessageLogContext &contex static void qt_message_print(const QString &message) { -#if defined(Q_OS_WINRT) - win_outputDebugString_helper(message); - return; -#elif defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) +#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) if (!shouldLogToStderr()) { win_outputDebugString_helper(message); return; diff --git a/src/corelib/global/qoperatingsystemversion_win.cpp b/src/corelib/global/qoperatingsystemversion_win.cpp index 798d985a76..eb58b60788 100644 --- a/src/corelib/global/qoperatingsystemversion_win.cpp +++ b/src/corelib/global/qoperatingsystemversion_win.cpp @@ -46,50 +46,17 @@ QT_BEGIN_NAMESPACE -#ifdef Q_OS_WINRT -static inline HMODULE moduleHandleForFunction(LPCVOID address) -{ - // This is a widely used, decades-old technique for retrieving the handle - // of a module and is effectively equivalent to GetModuleHandleEx - // (which is unavailable on WinRT) - MEMORY_BASIC_INFORMATION mbi = { 0, 0, 0, 0, 0, 0, 0 }; - if (VirtualQuery(address, &mbi, sizeof(mbi)) == 0) - return 0; - return reinterpret_cast(mbi.AllocationBase); -} -#endif - static inline OSVERSIONINFOEX determineWinOsVersion() { OSVERSIONINFOEX result = { sizeof(OSVERSIONINFOEX), 0, 0, 0, 0, {'\0'}, 0, 0, 0, 0, 0}; #define GetProcAddressA GetProcAddress - - // GetModuleHandle is not supported in WinRT and linking to it at load time - // will not pass the Windows App Certification Kit... but it exists and is functional, - // so use some unusual but widely used techniques to get a pointer to it -#ifdef Q_OS_WINRT - // 1. Get HMODULE of kernel32.dll, using the address of some function exported by that DLL - HMODULE kernelModule = moduleHandleForFunction(reinterpret_cast(VirtualQuery)); - if (Q_UNLIKELY(!kernelModule)) - return result; - - // 2. Get pointer to GetModuleHandle so we can then load other arbitrary modules (DLLs) - typedef HMODULE(WINAPI *GetModuleHandleFunction)(LPCWSTR); - GetModuleHandleFunction pGetModuleHandle = reinterpret_cast( - GetProcAddressA(kernelModule, "GetModuleHandleW")); - if (Q_UNLIKELY(!pGetModuleHandle)) - return result; -#else #define pGetModuleHandle GetModuleHandleW -#endif HMODULE ntdll = pGetModuleHandle(L"ntdll.dll"); if (Q_UNLIKELY(!ntdll)) return result; - // NTSTATUS is not defined on WinRT - typedef LONG NTSTATUS; typedef NTSTATUS (NTAPI *RtlGetVersionFunction)(LPOSVERSIONINFO); // RtlGetVersion is documented public API but we must load it dynamically diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h index 8d65720850..f7bca43345 100644 --- a/src/corelib/global/qprocessordetection.h +++ b/src/corelib/global/qprocessordetection.h @@ -357,8 +357,7 @@ # define Q_BYTE_ORDER __BYTE_ORDER__ # elif defined(__BIG_ENDIAN__) || defined(_big_endian__) || defined(_BIG_ENDIAN) # define Q_BYTE_ORDER Q_BIG_ENDIAN -# elif defined(__LITTLE_ENDIAN__) || defined(_little_endian__) || defined(_LITTLE_ENDIAN) \ - || defined(WINAPI_FAMILY) // WinRT is always little-endian according to MSDN. +# elif defined(__LITTLE_ENDIAN__) || defined(_little_endian__) || defined(_LITTLE_ENDIAN) # define Q_BYTE_ORDER Q_LITTLE_ENDIAN # else # error "Unable to determine byte order!" diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 3dc024e301..e35fc21d98 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -167,19 +167,13 @@ struct QRandomGenerator::SystemGenerator return qMax(n, 0); // ignore any errors } -#elif defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#elif defined(Q_OS_WIN) qsizetype fillBuffer(void *buffer, qsizetype count) noexcept { auto RtlGenRandom = SystemFunction036; return RtlGenRandom(buffer, ULONG(count)) ? count: 0; } -#elif defined(Q_OS_WINRT) - qsizetype fillBuffer(void *, qsizetype) noexcept - { - // always use the fallback - return 0; - } -#endif // Q_OS_WINRT +#endif // Q_OS_WIN static SystemGenerator &self(); typedef quint32 result_type; diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h index ab023a6cb5..2afd84bcd3 100644 --- a/src/corelib/global/qsystemdetection.h +++ b/src/corelib/global/qsystemdetection.h @@ -54,7 +54,6 @@ WATCHOS - watchOS TVOS - tvOS WIN32 - Win32 (Windows 2000/XP/Vista/7 and Windows Server 2003/2008) - WINRT - WinRT (Windows Runtime) CYGWIN - Cygwin SOLARIS - Sun Solaris HPUX - HP-UX @@ -124,20 +123,7 @@ # define Q_OS_WIN32 # define Q_OS_WIN64 #elif !defined(SAG_COM) && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) -# if defined(WINAPI_FAMILY) -# ifndef WINAPI_FAMILY_PC_APP -# define WINAPI_FAMILY_PC_APP WINAPI_FAMILY_APP -# endif -# if defined(WINAPI_FAMILY_PHONE_APP) && WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP -# define Q_OS_WINRT -# elif WINAPI_FAMILY==WINAPI_FAMILY_PC_APP -# define Q_OS_WINRT -# else -# define Q_OS_WIN32 -# endif -# else # define Q_OS_WIN32 -# endif #elif defined(__sun) || defined(sun) # define Q_OS_SOLARIS #elif defined(hpux) || defined(__hpux) @@ -184,7 +170,7 @@ # error "Qt has not been ported to this OS - see http://www.qt-project.org/" #endif -#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINRT) +#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) # define Q_OS_WINDOWS # define Q_OS_WIN # if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -- cgit v1.2.3