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/.prev_CMakeLists.txt | 76 +-- src/corelib/CMakeLists.txt | 76 +-- src/corelib/configure.cmake | 5 +- src/corelib/configure.json | 5 +- src/corelib/corelib.pro | 2 +- 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 +- src/corelib/io/io.pri | 46 +- src/corelib/io/qdir.cpp | 15 +- src/corelib/io/qfileinfo.cpp | 2 +- src/corelib/io/qfileselector.cpp | 3 - src/corelib/io/qfilesystemengine_win.cpp | 185 +----- src/corelib/io/qfilesystementry.cpp | 14 - src/corelib/io/qfilesystemmetadata_p.h | 4 - src/corelib/io/qfilesystemwatcher.cpp | 8 +- src/corelib/io/qfilesystemwatcher_p.h | 4 +- src/corelib/io/qfilesystemwatcher_win.cpp | 10 - src/corelib/io/qfilesystemwatcher_win_p.h | 2 - src/corelib/io/qfsfileengine_win.cpp | 59 +- src/corelib/io/qlockfile_win.cpp | 21 - src/corelib/io/qprocess.cpp | 3 +- src/corelib/io/qsettings.cpp | 63 +- src/corelib/io/qsettings_p.h | 4 - src/corelib/io/qsettings_winrt.cpp | 690 --------------------- src/corelib/io/qstandardpaths_winrt.cpp | 138 ----- src/corelib/io/qstorageinfo_p.h | 2 +- src/corelib/io/qstorageinfo_stub.cpp | 67 -- src/corelib/io/qtemporaryfile.cpp | 9 +- src/corelib/kernel/kernel.pri | 28 +- src/corelib/kernel/qcoreapplication.cpp | 38 +- src/corelib/kernel/qcoreapplication_p.h | 2 +- src/corelib/kernel/qcoreapplication_win.cpp | 42 -- src/corelib/kernel/qcorecmdlineargs_p.h | 12 +- src/corelib/kernel/qeventdispatcher_winrt.cpp | 656 -------------------- src/corelib/kernel/qeventdispatcher_winrt_p.h | 113 ---- src/corelib/kernel/qfunctions_fake_env_p.h | 130 ---- src/corelib/kernel/qfunctions_p.h | 2 - src/corelib/kernel/qfunctions_winrt.cpp | 58 -- src/corelib/kernel/qfunctions_winrt.h | 252 -------- src/corelib/kernel/qfunctions_winrt_p.h | 184 ++++++ src/corelib/kernel/qsharedmemory_win.cpp | 13 - src/corelib/kernel/qsystemerror.cpp | 12 - src/corelib/kernel/qsystemsemaphore_win.cpp | 6 - src/corelib/kernel/qtestsupport_core.cpp | 4 +- src/corelib/kernel/qwineventnotifier.cpp | 21 - src/corelib/plugin/qlibrary_win.cpp | 17 - src/corelib/plugin/qsystemlibrary.cpp | 10 - src/corelib/text/qcollator_p.h | 3 - src/corelib/text/qlocale_win.cpp | 121 ---- src/corelib/text/qstringconverter.cpp | 16 - src/corelib/thread/qmutex_win.cpp | 4 - src/corelib/thread/qthread.cpp | 2 - src/corelib/thread/qthread_p.h | 13 - src/corelib/thread/qthread_win.cpp | 121 +--- src/corelib/thread/qwaitcondition_win.cpp | 6 - src/corelib/time/qdatetime.cpp | 3 - src/corelib/time/qtimezoneprivate_win.cpp | 132 ---- src/corelib/tools/qcommandlineparser.cpp | 14 +- 64 files changed, 343 insertions(+), 3325 deletions(-) delete mode 100644 src/corelib/io/qsettings_winrt.cpp delete mode 100644 src/corelib/io/qstandardpaths_winrt.cpp delete mode 100644 src/corelib/io/qstorageinfo_stub.cpp delete mode 100644 src/corelib/kernel/qeventdispatcher_winrt.cpp delete mode 100644 src/corelib/kernel/qeventdispatcher_winrt_p.h delete mode 100644 src/corelib/kernel/qfunctions_fake_env_p.h delete mode 100644 src/corelib/kernel/qfunctions_winrt.cpp delete mode 100644 src/corelib/kernel/qfunctions_winrt.h create mode 100644 src/corelib/kernel/qfunctions_winrt_p.h (limited to 'src/corelib') diff --git a/src/corelib/.prev_CMakeLists.txt b/src/corelib/.prev_CMakeLists.txt index 51bb15fc3c..59e670e5db 100644 --- a/src/corelib/.prev_CMakeLists.txt +++ b/src/corelib/.prev_CMakeLists.txt @@ -338,28 +338,23 @@ qt_extend_target(Core CONDITION WIN32 io/qfilesystemengine_win.cpp io/qfsfileengine_win.cpp io/qlockfile_win.cpp + io/qstandardpaths_win.cpp + io/qstorageinfo_win.cpp + io/qwindowspipereader.cpp io/qwindowspipereader_p.h + io/qwindowspipewriter.cpp io/qwindowspipewriter_p.h kernel/qcoreapplication_win.cpp kernel/qelapsedtimer_win.cpp + kernel/qeventdispatcher_win.cpp kernel/qeventdispatcher_win_p.h + kernel/qfunctions_winrt_p.h kernel/qsharedmemory_win.cpp kernel/qsystemsemaphore_win.cpp kernel/qwineventnotifier.cpp kernel/qwineventnotifier.h kernel/qwineventnotifier_p.h + kernel/qwinregistry.cpp kernel/qwinregistry_p.h plugin/qsystemlibrary.cpp plugin/qsystemlibrary_p.h thread/qatomic_msvc.h thread/qthread_win.cpp DEFINES -QT_NO_CAST_TO_ASCII - LIBRARIES - ws2_32 -) - -qt_extend_target(Core CONDITION WIN32 AND NOT WINRT - SOURCES - io/qstandardpaths_win.cpp - io/qstorageinfo_win.cpp - io/qwindowspipereader.cpp io/qwindowspipereader_p.h - io/qwindowspipewriter.cpp io/qwindowspipewriter_p.h - kernel/qeventdispatcher_win.cpp kernel/qeventdispatcher_win_p.h - kernel/qwinregistry.cpp kernel/qwinregistry_p.h LIBRARIES advapi32 kernel32 @@ -370,6 +365,7 @@ qt_extend_target(Core CONDITION WIN32 AND NOT WINRT uuid version winmm + ws2_32 PUBLIC_LIBRARIES mpr userenv @@ -413,27 +409,27 @@ qt_extend_target(Core CONDITION INTEGRITY --pending_instantiations=128 ) -#### Keys ignored in scope 15:.:.:corelib.pro:pathIsAbsolute(_ss_CMAKE_HOST_DATA_DIR): +#### Keys ignored in scope 14:.:.:corelib.pro:pathIsAbsolute(_ss_CMAKE_HOST_DATA_DIR): # CMAKE_HOST_DATA_DIR = "$$[QT_HOST_DATA/src]/" # CMAKE_HOST_DATA_DIR_IS_ABSOLUTE = "True" -#### Keys ignored in scope 16:.:.:corelib.pro:pathIsAbsolute(_ss_CMAKE_INSTALL_DATA_DIR): +#### Keys ignored in scope 15:.:.:corelib.pro:pathIsAbsolute(_ss_CMAKE_INSTALL_DATA_DIR): # CMAKE_INSTALL_DATA_DIR = "$$[QT_HOST_DATA]/" # CMAKE_INSTALL_DATA_DIR_IS_ABSOLUTE = "True" -#### Keys ignored in scope 21:.:global:global/global.pri:QT_CPU_FEATURES__ss_QT_ARCH___contains___f16c: +#### Keys ignored in scope 20:.:global:global/global.pri:QT_CPU_FEATURES__ss_QT_ARCH___contains___f16c: # f16c_cxx = "true" -#### Keys ignored in scope 23:.:global:global/global.pri:CLANG OR intel_icl OR ICC: +#### Keys ignored in scope 22:.:global:global/global.pri:CLANG OR intel_icl OR ICC: # f16c_cxx = "false" -#### Keys ignored in scope 25:.:global:global/global.pri:GCC AND f16c AND x86SimdAlways: +#### Keys ignored in scope 24:.:global:global/global.pri:GCC AND f16c AND x86SimdAlways: # f16c_cxx = "true" -#### Keys ignored in scope 27:.:global:global/global.pri:MSVC AND QT_CPU_FEATURES__ss_QT_ARCH___contains___avx: +#### Keys ignored in scope 26:.:global:global/global.pri:MSVC AND QT_CPU_FEATURES__ss_QT_ARCH___contains___avx: # f16c_cxx = "true" -#### Keys ignored in scope 28:.:global:global/global.pri:else: +#### Keys ignored in scope 27:.:global:global/global.pri:else: # f16c_cxx = "false" qt_extend_target(Core CONDITION _ss_f16c_cxx @@ -460,7 +456,7 @@ qt_extend_target(Core CONDITION LINUX AND NOT static global/minimum-linux_p.h ) -#### Keys ignored in scope 35:.:global:global/global.pri:precompile_header: +#### Keys ignored in scope 34:.:global:global/global.pri:precompile_header: # NO_PCH_ASM = "global/minimum-linux.S" # QMAKE_EXTRA_COMPILERS = "no_pch_assembler" # no_pch_assembler.commands = "$$QMAKE_CC" "-c" "$(CFLAGS)" "$(INCPATH)" "${QMAKE_FILE_IN}" "-o" "${QMAKE_FILE_OUT}" @@ -469,7 +465,7 @@ qt_extend_target(Core CONDITION LINUX AND NOT static # no_pch_assembler.name = "compiling[no_pch]" "${QMAKE_FILE_IN}" # no_pch_assembler.output = "${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${firstQMAKE_EXT_OBJ}" -#### Keys ignored in scope 36:.:global:global/global.pri:silent: +#### Keys ignored in scope 35:.:global:global/global.pri:silent: # no_pch_assembler.commands = "@echo" "compiling[no_pch]" "${QMAKE_FILE_IN}" "&&" qt_extend_target(Core CONDITION LINUX AND NOT precompile_header AND NOT static @@ -487,7 +483,7 @@ qt_extend_target(Core CONDITION QT_FEATURE_journald PkgConfig::Libsystemd ) -#### Keys ignored in scope 40:.:global:global/global.pri:GCC AND ltcg: +#### Keys ignored in scope 39:.:global:global/global.pri:GCC AND ltcg: # QMAKE_EXTRA_COMPILERS = "versiontagging_compiler" # versiontagging_compiler.commands = "$$QMAKE_CXX" "-c" "$(CXXFLAGS)" "$(INCPATH)" "-fno-lto" "-o" "${QMAKE_FILE_OUT}" "${QMAKE_FILE_IN}" # versiontagging_compiler.dependency_type = "TYPE_C" @@ -496,7 +492,7 @@ qt_extend_target(Core CONDITION QT_FEATURE_journald # versiontagging_compiler.output = "${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${firstQMAKE_EXT_OBJ}" # versiontagging_compiler.variable_out = "OBJECTS" -#### Keys ignored in scope 41:.:global:global/global.pri:silent: +#### Keys ignored in scope 40:.:global:global/global.pri:silent: # versiontagging_compiler.commands = "@echo" "compiling[versiontagging]" "${QMAKE_FILE_IN}" "&&" qt_extend_target(Core CONDITION NOT GCC OR NOT ltcg @@ -797,7 +793,7 @@ qt_extend_target(Core CONDITION QT_FEATURE_processenvironment io/qprocess.cpp io/qprocess.h io/qprocess_p.h ) -qt_extend_target(Core CONDITION QT_FEATURE_processenvironment AND WIN32 AND NOT WINRT +qt_extend_target(Core CONDITION QT_FEATURE_processenvironment AND WIN32 SOURCES io/qprocess_win.cpp ) @@ -812,16 +808,11 @@ qt_extend_target(Core CONDITION QT_FEATURE_settings io/qsettings.cpp io/qsettings.h io/qsettings_p.h ) -qt_extend_target(Core CONDITION QT_FEATURE_settings AND WIN32 AND NOT WINRT +qt_extend_target(Core CONDITION QT_FEATURE_settings AND WIN32 SOURCES io/qsettings_win.cpp ) -qt_extend_target(Core CONDITION QT_FEATURE_settings AND WINRT - SOURCES - io/qsettings_winrt.cpp -) - qt_extend_target(Core CONDITION APPLE AND QT_FEATURE_settings AND NOT NACL SOURCES io/qsettings_mac.cpp @@ -837,15 +828,6 @@ qt_extend_target(Core CONDITION QT_FEATURE_filesystemiterator AND WIN32 io/qfilesystemiterator_win.cpp ) -qt_extend_target(Core CONDITION WINRT - SOURCES - io/qstandardpaths_winrt.cpp - io/qstorageinfo_stub.cpp - kernel/qeventdispatcher_winrt.cpp kernel/qeventdispatcher_winrt_p.h - kernel/qfunctions_fake_env_p.h - kernel/qfunctions_winrt.cpp kernel/qfunctions_winrt.h -) - qt_extend_target(Core CONDITION QT_FEATURE_process AND UNIX SOURCES ../3rdparty/forkfd/forkfd.h @@ -1076,7 +1058,7 @@ qt_extend_target(Core CONDITION QT_FEATURE_mimetype mimetypes/qmimetypeparser.cpp mimetypes/qmimetypeparser_p.h ) -#### Keys ignored in scope 197:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype: +#### Keys ignored in scope 188:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype: # MIME_DATABASE = "mimetypes/mime/packages/freedesktop.org.xml" # OTHER_FILES = "$$MIME_DATABASE" @@ -1085,7 +1067,7 @@ qt_extend_target(Core CONDITION QT_FEATURE_mimetype AND QT_FEATURE_mimetype_data .rcc ) -#### Keys ignored in scope 198:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype_database: +#### Keys ignored in scope 189:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype_database: # QMAKE_EXTRA_COMPILERS = "mimedb" # mimedb.commands = "${QMAKE_FILE_IN}" ">" "${QMAKE_FILE_OUT}" # mimedb.depends = "$$PWD/mime/generate.pl" @@ -1093,23 +1075,23 @@ qt_extend_target(Core CONDITION QT_FEATURE_mimetype AND QT_FEATURE_mimetype_data # mimedb.output = "$$outpath/qmimeprovider_database.cpp" # mimedb.variable_out = "INCLUDED_SOURCES" -#### Keys ignored in scope 199:.:mimetypes:mimetypes/mimetypes.pri:ANDROID: +#### Keys ignored in scope 190:.:mimetypes:mimetypes/mimetypes.pri:ANDROID: # outpath = "$$outpath/$${QT_ARCH}" -#### Keys ignored in scope 201:.:mimetypes:mimetypes/mimetypes.pri:(CMAKE_BUILD_TYPE STREQUAL Debug): +#### Keys ignored in scope 192:.:mimetypes:mimetypes/mimetypes.pri:(CMAKE_BUILD_TYPE STREQUAL Debug): # outpath = "$$outpath/debug" -#### Keys ignored in scope 202:.:mimetypes:mimetypes/mimetypes.pri:else: +#### Keys ignored in scope 193:.:mimetypes:mimetypes/mimetypes.pri:else: # outpath = "$$outpath/release" -#### Keys ignored in scope 203:.:mimetypes:mimetypes/mimetypes.pri:MAKEFILE_GENERATOR___equals___MSVC.NET OR MAKEFILE_GENERATOR___equals___MSBUILD OR QMAKE_SH_ISEMPTY: +#### Keys ignored in scope 194:.:mimetypes:mimetypes/mimetypes.pri:MAKEFILE_GENERATOR___equals___MSVC.NET OR MAKEFILE_GENERATOR___equals___MSBUILD OR QMAKE_SH_ISEMPTY: # mimedb.commands = "cmd" "/c" "$$shell_path($$PWD/mime/generate.bat)" # mimedb.depends = "$$PWD/mime/generate.bat" "$$PWD/mime/hexdump.ps1" -#### Keys ignored in scope 204:.:mimetypes:mimetypes/mimetypes.pri:else: +#### Keys ignored in scope 195:.:mimetypes:mimetypes/mimetypes.pri:else: # mimedb.commands = "perl" "$${mimedb.depends}" -#### Keys ignored in scope 205:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_zstd: +#### Keys ignored in scope 196:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_zstd: # mimedb.commands = "--zstd" qt_extend_target(Core CONDITION WASM diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 269891f91a..1f832504d1 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -446,27 +446,22 @@ qt_extend_target(Core CONDITION WIN32 io/qfilesystemengine_win.cpp io/qfsfileengine_win.cpp io/qlockfile_win.cpp + io/qstandardpaths_win.cpp + io/qstorageinfo_win.cpp + io/qwindowspipereader.cpp io/qwindowspipereader_p.h + io/qwindowspipewriter.cpp io/qwindowspipewriter_p.h kernel/qcoreapplication_win.cpp kernel/qelapsedtimer_win.cpp + kernel/qeventdispatcher_win.cpp kernel/qeventdispatcher_win_p.h + kernel/qfunctions_winrt_p.h kernel/qsharedmemory_win.cpp kernel/qsystemsemaphore_win.cpp kernel/qwineventnotifier.cpp kernel/qwineventnotifier.h kernel/qwineventnotifier_p.h + kernel/qwinregistry.cpp kernel/qwinregistry_p.h plugin/qsystemlibrary.cpp plugin/qsystemlibrary_p.h thread/qatomic_msvc.h thread/qthread_win.cpp # DEFINES # special case: remove - LIBRARIES - ws2_32 -) - -qt_extend_target(Core CONDITION WIN32 AND NOT WINRT - SOURCES - io/qstandardpaths_win.cpp - io/qstorageinfo_win.cpp - io/qwindowspipereader.cpp io/qwindowspipereader_p.h - io/qwindowspipewriter.cpp io/qwindowspipewriter_p.h - kernel/qeventdispatcher_win.cpp kernel/qeventdispatcher_win_p.h - kernel/qwinregistry.cpp kernel/qwinregistry_p.h LIBRARIES advapi32 kernel32 @@ -477,6 +472,7 @@ qt_extend_target(Core CONDITION WIN32 AND NOT WINRT uuid version winmm + ws2_32 PUBLIC_LIBRARIES mpr userenv @@ -520,27 +516,27 @@ qt_extend_target(Core CONDITION INTEGRITY --pending_instantiations=128 ) -#### Keys ignored in scope 15:.:.:corelib.pro:pathIsAbsolute(_ss_CMAKE_HOST_DATA_DIR): +#### Keys ignored in scope 14:.:.:corelib.pro:pathIsAbsolute(_ss_CMAKE_HOST_DATA_DIR): # CMAKE_HOST_DATA_DIR = "$$[QT_HOST_DATA/src]/" # CMAKE_HOST_DATA_DIR_IS_ABSOLUTE = "True" -#### Keys ignored in scope 16:.:.:corelib.pro:pathIsAbsolute(_ss_CMAKE_INSTALL_DATA_DIR): +#### Keys ignored in scope 15:.:.:corelib.pro:pathIsAbsolute(_ss_CMAKE_INSTALL_DATA_DIR): # CMAKE_INSTALL_DATA_DIR = "$$[QT_HOST_DATA]/" # CMAKE_INSTALL_DATA_DIR_IS_ABSOLUTE = "True" -#### Keys ignored in scope 21:.:global:global/global.pri:QT_CPU_FEATURES__ss_QT_ARCH___contains___f16c: +#### Keys ignored in scope 20:.:global:global/global.pri:QT_CPU_FEATURES__ss_QT_ARCH___contains___f16c: # f16c_cxx = "true" -#### Keys ignored in scope 23:.:global:global/global.pri:CLANG OR intel_icl OR ICC: +#### Keys ignored in scope 22:.:global:global/global.pri:CLANG OR intel_icl OR ICC: # f16c_cxx = "false" -#### Keys ignored in scope 25:.:global:global/global.pri:GCC AND f16c AND x86SimdAlways: +#### Keys ignored in scope 24:.:global:global/global.pri:GCC AND f16c AND x86SimdAlways: # f16c_cxx = "true" -#### Keys ignored in scope 27:.:global:global/global.pri:MSVC AND QT_CPU_FEATURES__ss_QT_ARCH___contains___avx: +#### Keys ignored in scope 26:.:global:global/global.pri:MSVC AND QT_CPU_FEATURES__ss_QT_ARCH___contains___avx: # f16c_cxx = "true" -#### Keys ignored in scope 28:.:global:global/global.pri:else: +#### Keys ignored in scope 27:.:global:global/global.pri:else: # f16c_cxx = "false" # extend_target(Core CONDITION _ss_f16c_cxx ... # special case remove: Handled manually @@ -560,7 +556,7 @@ qt_extend_target(Core CONDITION LINUX AND NOT static global/minimum-linux_p.h ) -#### Keys ignored in scope 35:.:global:global/global.pri:precompile_header: +#### Keys ignored in scope 34:.:global:global/global.pri:precompile_header: # NO_PCH_ASM = "global/minimum-linux.S" # QMAKE_EXTRA_COMPILERS = "no_pch_assembler" # no_pch_assembler.commands = "$$QMAKE_CC" "-c" "$(CFLAGS)" "$(INCPATH)" "${QMAKE_FILE_IN}" "-o" "${QMAKE_FILE_OUT}" @@ -569,7 +565,7 @@ qt_extend_target(Core CONDITION LINUX AND NOT static # no_pch_assembler.name = "compiling[no_pch]" "${QMAKE_FILE_IN}" # no_pch_assembler.output = "${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${firstQMAKE_EXT_OBJ}" -#### Keys ignored in scope 36:.:global:global/global.pri:silent: +#### Keys ignored in scope 35:.:global:global/global.pri:silent: # no_pch_assembler.commands = "@echo" "compiling[no_pch]" "${QMAKE_FILE_IN}" "&&" qt_extend_target(Core CONDITION LINUX AND NOT precompile_header AND NOT static @@ -587,7 +583,7 @@ qt_extend_target(Core CONDITION QT_FEATURE_journald PkgConfig::Libsystemd ) -#### Keys ignored in scope 40:.:global:global/global.pri:GCC AND ltcg: +#### Keys ignored in scope 39:.:global:global/global.pri:GCC AND ltcg: # QMAKE_EXTRA_COMPILERS = "versiontagging_compiler" # versiontagging_compiler.commands = "$$QMAKE_CXX" "-c" "$(CXXFLAGS)" "$(INCPATH)" "-fno-lto" "-o" "${QMAKE_FILE_OUT}" "${QMAKE_FILE_IN}" # versiontagging_compiler.dependency_type = "TYPE_C" @@ -596,7 +592,7 @@ qt_extend_target(Core CONDITION QT_FEATURE_journald # versiontagging_compiler.output = "${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${firstQMAKE_EXT_OBJ}" # versiontagging_compiler.variable_out = "OBJECTS" -#### Keys ignored in scope 41:.:global:global/global.pri:silent: +#### Keys ignored in scope 40:.:global:global/global.pri:silent: # versiontagging_compiler.commands = "@echo" "compiling[versiontagging]" "${QMAKE_FILE_IN}" "&&" qt_extend_target(Core CONDITION NOT GCC OR NOT ltcg @@ -897,7 +893,7 @@ qt_extend_target(Core CONDITION QT_FEATURE_processenvironment io/qprocess.cpp io/qprocess.h io/qprocess_p.h ) -qt_extend_target(Core CONDITION QT_FEATURE_processenvironment AND WIN32 AND NOT WINRT +qt_extend_target(Core CONDITION QT_FEATURE_processenvironment AND WIN32 SOURCES io/qprocess_win.cpp ) @@ -912,16 +908,11 @@ qt_extend_target(Core CONDITION QT_FEATURE_settings io/qsettings.cpp io/qsettings.h io/qsettings_p.h ) -qt_extend_target(Core CONDITION QT_FEATURE_settings AND WIN32 AND NOT WINRT +qt_extend_target(Core CONDITION QT_FEATURE_settings AND WIN32 SOURCES io/qsettings_win.cpp ) -qt_extend_target(Core CONDITION QT_FEATURE_settings AND WINRT - SOURCES - io/qsettings_winrt.cpp -) - qt_extend_target(Core CONDITION APPLE AND QT_FEATURE_settings AND NOT NACL SOURCES io/qsettings_mac.cpp @@ -937,15 +928,6 @@ qt_extend_target(Core CONDITION QT_FEATURE_filesystemiterator AND WIN32 io/qfilesystemiterator_win.cpp ) -qt_extend_target(Core CONDITION WINRT - SOURCES - io/qstandardpaths_winrt.cpp - io/qstorageinfo_stub.cpp - kernel/qeventdispatcher_winrt.cpp kernel/qeventdispatcher_winrt_p.h - kernel/qfunctions_fake_env_p.h - kernel/qfunctions_winrt.cpp kernel/qfunctions_winrt.h -) - qt_extend_target(Core CONDITION QT_FEATURE_process AND UNIX SOURCES ../3rdparty/forkfd/forkfd.h @@ -1176,7 +1158,7 @@ qt_extend_target(Core CONDITION QT_FEATURE_mimetype mimetypes/qmimetypeparser.cpp mimetypes/qmimetypeparser_p.h ) -#### Keys ignored in scope 197:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype: +#### Keys ignored in scope 188:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype: # MIME_DATABASE = "mimetypes/mime/packages/freedesktop.org.xml" # OTHER_FILES = "$$MIME_DATABASE" @@ -1187,7 +1169,7 @@ qt_extend_target(Core CONDITION QT_FEATURE_mimetype #) # special case end -#### Keys ignored in scope 198:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype_database: +#### Keys ignored in scope 189:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype_database: # QMAKE_EXTRA_COMPILERS = "mimedb" # mimedb.commands = "${QMAKE_FILE_IN}" ">" "${QMAKE_FILE_OUT}" # mimedb.depends = "$$PWD/mime/generate.pl" @@ -1195,23 +1177,23 @@ qt_extend_target(Core CONDITION QT_FEATURE_mimetype # mimedb.output = "$$outpath/qmimeprovider_database.cpp" # mimedb.variable_out = "INCLUDED_SOURCES" -#### Keys ignored in scope 199:.:mimetypes:mimetypes/mimetypes.pri:ANDROID: +#### Keys ignored in scope 190:.:mimetypes:mimetypes/mimetypes.pri:ANDROID: # outpath = "$$outpath/$${QT_ARCH}" -#### Keys ignored in scope 201:.:mimetypes:mimetypes/mimetypes.pri:(CMAKE_BUILD_TYPE STREQUAL Debug): +#### Keys ignored in scope 192:.:mimetypes:mimetypes/mimetypes.pri:(CMAKE_BUILD_TYPE STREQUAL Debug): # outpath = "$$outpath/debug" -#### Keys ignored in scope 202:.:mimetypes:mimetypes/mimetypes.pri:else: +#### Keys ignored in scope 193:.:mimetypes:mimetypes/mimetypes.pri:else: # outpath = "$$outpath/release" -#### Keys ignored in scope 203:.:mimetypes:mimetypes/mimetypes.pri:MAKEFILE_GENERATOR___equals___MSVC.NET OR MAKEFILE_GENERATOR___equals___MSBUILD OR QMAKE_SH_ISEMPTY: +#### Keys ignored in scope 194:.:mimetypes:mimetypes/mimetypes.pri:MAKEFILE_GENERATOR___equals___MSVC.NET OR MAKEFILE_GENERATOR___equals___MSBUILD OR QMAKE_SH_ISEMPTY: # mimedb.commands = "cmd" "/c" "$$shell_path($$PWD/mime/generate.bat)" # mimedb.depends = "$$PWD/mime/generate.bat" "$$PWD/mime/hexdump.ps1" -#### Keys ignored in scope 204:.:mimetypes:mimetypes/mimetypes.pri:else: +#### Keys ignored in scope 195:.:mimetypes:mimetypes/mimetypes.pri:else: # mimedb.commands = "perl" "$${mimedb.depends}" -#### Keys ignored in scope 205:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_zstd: +#### Keys ignored in scope 196:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_zstd: # mimedb.commands = "--zstd" # Resources: # special case begin diff --git a/src/corelib/configure.cmake b/src/corelib/configure.cmake index a601ebb437..5df72d869e 100644 --- a/src/corelib/configure.cmake +++ b/src/corelib/configure.cmake @@ -788,14 +788,14 @@ qt_feature("process" PUBLIC SECTION "File I/O" LABEL "QProcess" PURPOSE "Supports external process invocation." - CONDITION QT_FEATURE_processenvironment AND ( QT_FEATURE_thread OR NOT UNIX ) AND NOT WINRT AND NOT UIKIT AND NOT INTEGRITY AND NOT VXWORKS AND NOT rtems + CONDITION QT_FEATURE_processenvironment AND ( QT_FEATURE_thread OR NOT UNIX ) AND NOT UIKIT AND NOT INTEGRITY AND NOT VXWORKS AND NOT rtems ) qt_feature_definition("process" "QT_NO_PROCESS" NEGATE VALUE "1") qt_feature("processenvironment" PUBLIC SECTION "File I/O" LABEL "QProcessEnvironment" PURPOSE "Provides a higher-level abstraction of environment variables." - CONDITION NOT WINRT AND NOT INTEGRITY AND NOT rtems + CONDITION NOT INTEGRITY AND NOT rtems ) qt_feature("temporaryfile" PUBLIC SECTION "File I/O" @@ -820,7 +820,6 @@ qt_feature("filesystemwatcher" PUBLIC SECTION "File I/O" LABEL "QFileSystemWatcher" PURPOSE "Provides an interface for monitoring files and directories for modifications." - CONDITION NOT WINRT ) qt_feature_definition("filesystemwatcher" "QT_NO_FILESYSTEMWATCHER" NEGATE VALUE "1") qt_feature("filesystemiterator" PUBLIC diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 4d34089295..67c01bd8a9 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -895,14 +895,14 @@ "label": "QProcess", "purpose": "Supports external process invocation.", "section": "File I/O", - "condition": "features.processenvironment && (features.thread || !config.unix) && !config.winrt && !config.uikit && !config.integrity && !config.vxworks && !config.rtems", + "condition": "features.processenvironment && (features.thread || !config.unix) && !config.uikit && !config.integrity && !config.vxworks && !config.rtems", "output": [ "publicFeature", "feature" ] }, "processenvironment": { "label": "QProcessEnvironment", "purpose": "Provides a higher-level abstraction of environment variables.", "section": "File I/O", - "condition": "!config.winrt && !config.integrity && !config.rtems", + "condition": "!config.integrity && !config.rtems", "output": [ "publicFeature" ] }, "temporaryfile": { @@ -928,7 +928,6 @@ "label": "QFileSystemWatcher", "purpose": "Provides an interface for monitoring files and directories for modifications.", "section": "File I/O", - "condition": "!config.winrt", "output": [ "publicFeature", "feature" ] }, "filesystemiterator": { diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index 3430154d13..efeba221c5 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -52,7 +52,7 @@ include(platform/platform.pri) win32 { QMAKE_USE_PRIVATE += ws2_32 - !winrt: QMAKE_USE_PRIVATE += advapi32 kernel32 ole32 shell32 uuid user32 winmm + QMAKE_USE_PRIVATE += advapi32 kernel32 ole32 shell32 uuid user32 winmm } darwin { 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) diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 97b7f3970c..c062d9948b 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -111,7 +111,7 @@ qtConfig(processenvironment) { io/qprocess.h \ io/qprocess_p.h - win32:!winrt: \ + win32: \ SOURCES += io/qprocess_win.cpp else: unix: \ SOURCES += io/qprocess_unix.cpp @@ -125,11 +125,7 @@ qtConfig(settings) { io/qsettings_p.h win32 { - !winrt { - SOURCES += io/qsettings_win.cpp - } else { - SOURCES += io/qsettings_winrt.cpp - } + SOURCES += io/qsettings_win.cpp } else: darwin:!nacl { SOURCES += io/qsettings_mac.cpp } @@ -137,32 +133,26 @@ qtConfig(settings) { } win32 { - SOURCES += io/qfsfileengine_win.cpp - SOURCES += io/qlockfile_win.cpp - SOURCES += io/qfilesystemengine_win.cpp + SOURCES += io/qfsfileengine_win.cpp + SOURCES += io/qlockfile_win.cpp + SOURCES += io/qfilesystemengine_win.cpp - qtConfig(filesystemiterator) { - SOURCES += io/qfilesystemiterator_win.cpp - } + qtConfig(filesystemiterator) { + SOURCES += io/qfilesystemiterator_win.cpp + } - !winrt { - HEADERS += \ - io/qwindowspipereader_p.h \ - io/qwindowspipewriter_p.h + HEADERS += \ + io/qwindowspipereader_p.h \ + io/qwindowspipewriter_p.h - SOURCES += \ - io/qstandardpaths_win.cpp \ - io/qstorageinfo_win.cpp \ - io/qwindowspipereader.cpp \ - io/qwindowspipewriter.cpp + SOURCES += \ + io/qstandardpaths_win.cpp \ + io/qstorageinfo_win.cpp \ + io/qwindowspipereader.cpp \ + io/qwindowspipewriter.cpp - LIBS += -lmpr -luserenv - QMAKE_USE_PRIVATE += netapi32 - } else { - SOURCES += \ - io/qstandardpaths_winrt.cpp \ - io/qstorageinfo_stub.cpp - } + LIBS += -lmpr -luserenv + QMAKE_USE_PRIVATE += netapi32 } else:unix { SOURCES += \ io/qfsfileengine_unix.cpp \ diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 368ad648e0..647f6746a5 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -83,7 +83,7 @@ static QString driveSpec(const QString &path) #endif enum { -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) OSSupportsUncPaths = true #else OSSupportsUncPaths = false @@ -100,11 +100,6 @@ static int rootLength(const QString &name, bool allowUncPaths) const int nextSlash = name.indexOf(QLatin1Char('/'), 2); return nextSlash >= 0 ? nextSlash + 1 : len; } -#if defined(Q_OS_WINRT) - const QString rootPath = QDir::rootPath(); // rootPath contains the trailing slash - if (name.startsWith(rootPath, Qt::CaseInsensitive)) - return rootPath.size(); -#endif // Q_OS_WINRT #if defined(Q_OS_WIN) if (len >= 2 && name.at(1) == QLatin1Char(':')) { // Handle a possible drive letter @@ -196,11 +191,7 @@ inline void QDirPrivate::setPath(const QString &path) if (p.endsWith(QLatin1Char('/')) && p.length() > 1 #if defined(Q_OS_WIN) -# if defined (Q_OS_WINRT) - && (!(p.toLower() == QDir::rootPath().toLower())) -# else && (!(p.length() == 3 && p.at(1).unicode() == ':' && p.at(0).isLetter())) -# endif #endif ) { p.truncate(p.length() - 1); @@ -2373,11 +2364,7 @@ static QString qt_cleanPath(const QString &path, bool *ok) // Strip away last slash except for root directories if (ret.length() > 1 && ret.endsWith(QLatin1Char('/'))) { #if defined (Q_OS_WIN) -# if defined(Q_OS_WINRT) - if (!((ret.length() == 3 || ret.length() == QDir::rootPath().length()) && ret.at(1) == QLatin1Char(':'))) -# else if (!(ret.length() == 3 && ret.at(1) == QLatin1Char(':'))) -# endif #endif ret.chop(1); } diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 824215d1d9..f33f03262f 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -1178,7 +1178,7 @@ bool QFileInfo::isRoot() const return false; if (d->fileEngine == nullptr) { if (d->fileEntry.isRoot()) { -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) //the path is a drive root, but the drive may not exist //for backward compatibility, return true only if the drive exists if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::ExistsAttribute)) diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp index 0c42a98b37..1a58da1e18 100644 --- a/src/corelib/io/qfileselector.cpp +++ b/src/corelib/io/qfileselector.cpp @@ -346,9 +346,6 @@ QStringList QFileSelectorPrivate::platformSelectors() #if defined(Q_OS_WIN) ret << QStringLiteral("windows"); ret << QSysInfo::kernelType(); // "winnt" -# if defined(Q_OS_WINRT) - ret << QStringLiteral("winrt"); -# endif #elif defined(Q_OS_UNIX) ret << QStringLiteral("unix"); # if !defined(Q_OS_ANDROID) && !defined(Q_OS_QNX) diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index a4f47cbf24..4c1b9f87c2 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -61,33 +61,16 @@ #include #include #include -#ifndef Q_OS_WINRT -# include -# include -# include -# include -# include -#endif +#include +#include +#include +#include +#include #include #include #include -#ifndef Q_OS_WINRT -# define SECURITY_WIN32 -# include -#else // !Q_OS_WINRT -# include "qstandardpaths.h" -# include "qthreadstorage.h" -# include -# include -# include -# include - -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -using namespace ABI::Windows::Foundation; -using namespace ABI::Windows::Storage; -using namespace ABI::Windows::ApplicationModel; -#endif // Q_OS_WINRT +#define SECURITY_WIN32 +#include #ifndef SPI_GETPLATFORMTYPE #define SPI_GETPLATFORMTYPE 257 @@ -153,11 +136,11 @@ typedef struct _REPARSE_DATA_BUFFER { # define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS) #endif -#if defined(Q_OS_WINRT) || defined(QT_BOOTSTRAPPED) +#if defined(QT_BOOTSTRAPPED) # define QT_FEATURE_fslibs -1 #else # define QT_FEATURE_fslibs 1 -#endif // Q_OS_WINRT +#endif // QT_BOOTSTRAPPED #if QT_CONFIG(fslibs) #include @@ -291,7 +274,6 @@ static inline bool toFileTime(const QDateTime &date, FILETIME *fileTime) static QString readSymLink(const QFileSystemEntry &link) { QString result; -#if !defined(Q_OS_WINRT) HANDLE handle = CreateFile((wchar_t*)link.nativeFilePath().utf16(), FILE_READ_EA, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, @@ -346,9 +328,6 @@ static QString readSymLink(const QFileSystemEntry &link) } #endif // QT_CONFIG(fslibs) } -#else - Q_UNUSED(link); -#endif // Q_OS_WINRT return result; } @@ -416,11 +395,7 @@ static inline bool getFindData(QString path, WIN32_FIND_DATA &findData) // can't handle drives if (!path.endsWith(QLatin1Char(':'))) { -#ifndef Q_OS_WINRT HANDLE hFind = ::FindFirstFile((wchar_t*)path.utf16(), &findData); -#else - HANDLE hFind = ::FindFirstFileEx((const wchar_t*)path.utf16(), FindExInfoStandard, &findData, FindExSearchNameMatch, NULL, 0); -#endif if (hFind != INVALID_HANDLE_VALUE) { ::FindClose(hFind); return true; @@ -531,7 +506,6 @@ private: bool QFileSystemEngine::uncListSharesOnServer(const QString &server, QStringList *list) { DWORD res = ERROR_NOT_SUPPORTED; -#ifndef Q_OS_WINRT SHARE_INFO_1 *BufPtr, *p; DWORD er = 0, tr = 0, resume = 0, i; do { @@ -546,10 +520,6 @@ bool QFileSystemEngine::uncListSharesOnServer(const QString &server, QStringList } NetApiBufferFree(BufPtr); } while (res == ERROR_MORE_DATA); -#else - Q_UNUSED(server); - Q_UNUSED(list); -#endif return res == ERROR_SUCCESS; } @@ -615,16 +585,6 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path) } if (retLen != 0) absPath = QString::fromWCharArray(buf.data(), retLen); -# if defined(Q_OS_WINRT) - // Win32 returns eg C:/ as root directory with a trailing /. - // WinRT returns the sandbox root without /. - // Also C:/../.. returns C:/ on Win32, while for WinRT it steps outside the package - // and goes beyond package root. Hence force the engine to stay inside - // the package. - const QString rootPath = QDir::toNativeSeparators(QDir::rootPath()); - if (absPath.size() < rootPath.size() && rootPath.startsWith(absPath)) - absPath = rootPath; -# endif // Q_OS_WINRT // This is really ugly, but GetFullPathName strips off whitespace at the end. // If you for instance write ". " in the lineedit of QFileDialog, @@ -652,7 +612,6 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + entry.filePath()); } -#ifndef Q_OS_WINRT // The path should be absolute at this point. // From the docs : // Absolute paths begin with the directory separator "/" @@ -665,7 +624,6 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) // Force uppercase drive letters. ret[0] = ret.at(0).toUpper(); } -#endif // !Q_OS_WINRT return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath()); } @@ -681,7 +639,6 @@ typedef struct _FILE_ID_INFO { // File ID for Windows up to version 7 and FAT32 drives static inline QByteArray fileId(HANDLE handle) { -#ifndef Q_OS_WINRT BY_HANDLE_FILE_INFORMATION info; if (GetFileInformationByHandle(handle, &info)) { char buffer[sizeof "01234567:0123456701234567"]; @@ -691,10 +648,6 @@ static inline QByteArray fileId(HANDLE handle) info.nFileIndexLow); return buffer; } -#else // !Q_OS_WINRT - Q_UNUSED(handle); - Q_UNIMPLEMENTED(); -#endif // Q_OS_WINRT return QByteArray(); } @@ -727,23 +680,10 @@ QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry) QByteArray result; -#ifndef Q_OS_WINRT const HANDLE handle = CreateFile((wchar_t*)entry.nativeFilePath().utf16(), 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); -#else // !Q_OS_WINRT - CREATEFILE2_EXTENDED_PARAMETERS params; - params.dwSize = sizeof(params); - params.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; - params.dwFileFlags = FILE_FLAG_BACKUP_SEMANTICS; - params.dwSecurityQosFlags = SECURITY_ANONYMOUS; - params.lpSecurityAttributes = NULL; - params.hTemplateFile = NULL; - const HANDLE handle = - CreateFile2((const wchar_t*)entry.nativeFilePath().utf16(), 0, - FILE_SHARE_READ, OPEN_EXISTING, ¶ms); -#endif // Q_OS_WINRT if (handle != INVALID_HANDLE_VALUE) { result = id(handle); CloseHandle(handle); @@ -994,7 +934,6 @@ static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaDa { bool entryExists = false; DWORD fileAttrib = 0; -#if !defined(Q_OS_WINRT) if (fname.isDriveRoot()) { // a valid drive ?? const UINT oldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); @@ -1006,7 +945,6 @@ static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaDa entryExists = true; } } else { -#endif const QString &path = fname.nativeFilePath(); bool is_dir = false; if (path.startsWith(QLatin1String("\\\\?\\UNC"))) { @@ -1037,9 +975,7 @@ static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaDa fileAttrib = FILE_ATTRIBUTE_DIRECTORY; entryExists = true; } -#if !defined(Q_OS_WINRT) } -#endif if (entryExists) data.fillFromFileAttribute(fileAttrib); return entryExists; @@ -1078,34 +1014,12 @@ bool QFileSystemEngine::fillMetaData(HANDLE fHandle, QFileSystemMetaData &data, { data.entryFlags &= ~what; clearWinStatData(data); -#ifndef Q_OS_WINRT BY_HANDLE_FILE_INFORMATION fileInfo; UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); if (GetFileInformationByHandle(fHandle , &fileInfo)) { data.fillFromFindInfo(fileInfo); } SetErrorMode(oldmode); -#else // !Q_OS_WINRT - FILE_BASIC_INFO fileBasicInfo; - if (GetFileInformationByHandleEx(fHandle, FileBasicInfo, &fileBasicInfo, sizeof(fileBasicInfo))) { - data.fillFromFileAttribute(fileBasicInfo.FileAttributes); - data.birthTime_.dwHighDateTime = fileBasicInfo.CreationTime.HighPart; - data.birthTime_.dwLowDateTime = fileBasicInfo.CreationTime.LowPart; - data.changeTime_.dwHighDateTime = fileBasicInfo.ChangeTime.HighPart; - data.changeTime_.dwLowDateTime = fileBasicInfo.ChangeTime.LowPart; - data.lastAccessTime_.dwHighDateTime = fileBasicInfo.LastAccessTime.HighPart; - data.lastAccessTime_.dwLowDateTime = fileBasicInfo.LastAccessTime.LowPart; - data.lastWriteTime_.dwHighDateTime = fileBasicInfo.LastWriteTime.HighPart; - data.lastWriteTime_.dwLowDateTime = fileBasicInfo.LastWriteTime.LowPart; - if (!(data.fileAttribute_ & FILE_ATTRIBUTE_DIRECTORY)) { - FILE_STANDARD_INFO fileStandardInfo; - if (GetFileInformationByHandleEx(fHandle, FileStandardInfo, &fileStandardInfo, sizeof(fileStandardInfo))) - data.size_ = fileStandardInfo.EndOfFile.QuadPart; - } else - data.size_ = 0; - data.knownFlagsMask |= QFileSystemMetaData::Times | QFileSystemMetaData::SizeAttribute; - } -#endif // Q_OS_WINRT return data.hasFlags(what); } @@ -1138,9 +1052,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM } if (what & QFileSystemMetaData::WinStatFlags) { -#ifndef Q_OS_WINRT UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); -#endif clearWinStatData(data); WIN32_FIND_DATA findData; // The memory structure for WIN32_FIND_DATA is same as WIN32_FILE_ATTRIBUTE_DATA @@ -1153,15 +1065,11 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM } else { if (!tryFindFallback(fname, data)) if (!tryDriveUNCFallback(fname, data)) { -#ifndef Q_OS_WINRT SetErrorMode(oldmode); -#endif return false; } } -#ifndef Q_OS_WINRT SetErrorMode(oldmode); -#endif } if (what & QFileSystemMetaData::Permissions) @@ -1201,16 +1109,7 @@ static bool isDirPath(const QString &dirPath, bool *existed) path += QLatin1Char('\\'); const QString longPath = QFSFileEnginePrivate::longFileName(path); -#ifndef Q_OS_WINRT DWORD fileAttrib = ::GetFileAttributes(reinterpret_cast(longPath.utf16())); -#else // Q_OS_WINRT - DWORD fileAttrib = INVALID_FILE_ATTRIBUTES; - WIN32_FILE_ATTRIBUTE_DATA data; - if (::GetFileAttributesEx(reinterpret_cast(longPath.utf16()), - GetFileExInfoStandard, &data)) { - fileAttrib = data.dwFileAttributes; - } -#endif // Q_OS_WINRT if (fileAttrib == INVALID_FILE_ATTRIBUTES) { int errorCode = GetLastError(); if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) { @@ -1314,36 +1213,10 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo //static QString QFileSystemEngine::rootPath() { -#if defined(Q_OS_WINRT) - // We specify the package root as root directory - QString ret = QLatin1String("/"); - // Get package location - ComPtr statics; - if (FAILED(GetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_Package).Get(), &statics))) - return ret; - ComPtr package; - if (FAILED(statics->get_Current(&package))) - return ret; - ComPtr installedLocation; - if (FAILED(package->get_InstalledLocation(&installedLocation))) - return ret; - - ComPtr item; - if (FAILED(installedLocation.As(&item))) - return ret; - - HString finalWinPath; - if (FAILED(item->get_Path(finalWinPath.GetAddressOf()))) - return ret; - - const QString qtWinPath = QDir::fromNativeSeparators(QString::fromWCharArray(finalWinPath.GetRawBuffer(nullptr))); - ret = qtWinPath.endsWith(QLatin1Char('/')) ? qtWinPath : qtWinPath + QLatin1Char('/'); -#else QString ret = QString::fromLatin1(qgetenv("SystemDrive")); if (ret.isEmpty()) ret = QLatin1String("c:"); ret.append(QLatin1Char('/')); -#endif return ret; } @@ -1391,7 +1264,6 @@ QString QFileSystemEngine::homePath() QString QFileSystemEngine::tempPath() { QString ret; -#ifndef Q_OS_WINRT wchar_t tempPath[MAX_PATH]; const DWORD len = GetTempPath(MAX_PATH, tempPath); if (len) { // GetTempPath() can return short names, expand. @@ -1406,24 +1278,6 @@ QString QFileSystemEngine::tempPath() ret.chop(1); ret = QDir::fromNativeSeparators(ret); } -#else // !Q_OS_WINRT - ComPtr applicationDataStatics; - if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Storage_ApplicationData).Get(), &applicationDataStatics))) - return ret; - ComPtr applicationData; - if (FAILED(applicationDataStatics->get_Current(&applicationData))) - return ret; - ComPtr tempFolder; - if (FAILED(applicationData->get_TemporaryFolder(&tempFolder))) - return ret; - ComPtr tempFolderItem; - if (FAILED(tempFolder.As(&tempFolderItem))) - return ret; - HString path; - if (FAILED(tempFolderItem->get_Path(path.GetAddressOf()))) - return ret; - ret = QDir::fromNativeSeparators(QString::fromWCharArray(path.GetRawBuffer(nullptr))); -#endif // Q_OS_WINRT if (ret.isEmpty()) { ret = QLatin1String("C:/tmp"); } else if (ret.length() >= 2 && ret[1] == QLatin1Char(':')) @@ -1478,17 +1332,8 @@ bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSy //static bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error) { -#ifndef Q_OS_WINRT bool ret = ::CopyFile((wchar_t*)source.nativeFilePath().utf16(), (wchar_t*)target.nativeFilePath().utf16(), true) != 0; -#else // !Q_OS_WINRT - COPYFILE2_EXTENDED_PARAMETERS copyParams = { - sizeof(copyParams), COPY_FILE_FAIL_IF_EXISTS, NULL, NULL, NULL - }; - HRESULT hres = ::CopyFile2((const wchar_t*)source.nativeFilePath().utf16(), - (const wchar_t*)target.nativeFilePath().utf16(), ©Params); - bool ret = SUCCEEDED(hres); -#endif // Q_OS_WINRT if(!ret) error = QSystemError(::GetLastError(), QSystemError::NativeError); return ret; @@ -1500,13 +1345,8 @@ bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSy Q_CHECK_FILE_NAME(source, false); Q_CHECK_FILE_NAME(target, false); -#ifndef Q_OS_WINRT bool ret = ::MoveFile((wchar_t*)source.nativeFilePath().utf16(), (wchar_t*)target.nativeFilePath().utf16()) != 0; -#else // !Q_OS_WINRT - bool ret = ::MoveFileEx((const wchar_t*)source.nativeFilePath().utf16(), - (const wchar_t*)target.nativeFilePath().utf16(), 0) != 0; -#endif // Q_OS_WINRT if(!ret) error = QSystemError(::GetLastError(), QSystemError::NativeError); return ret; @@ -1547,7 +1387,6 @@ bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QSystemError & bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source, QFileSystemEntry &newLocation, QSystemError &error) { -#ifndef Q_OS_WINRT // we need the "display name" of the file, so can't use nativeAbsoluteFilePath const QString sourcePath = QDir::toNativeSeparators(absoluteName(source).filePath()); @@ -1626,12 +1465,6 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source, } return true; -#else // Q_OS_WINRT - Q_UNUSED(source); - Q_UNUSED(newLocation); - Q_UNUSED(error); - return false; -#endif } //static diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index 3ff90bd0a3..3c8a85291a 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -166,16 +166,6 @@ void QFileSystemEntry::resolveNativeFilePath() const m_nativeFilePath = QDir::toNativeSeparators(m_filePath); #else m_nativeFilePath = QFile::encodeName(QDir::toNativeSeparators(m_filePath)); -#endif -#ifdef Q_OS_WINRT - while (m_nativeFilePath.startsWith(QLatin1Char('\\'))) - m_nativeFilePath.remove(0,1); - if (m_nativeFilePath.isEmpty()) - m_nativeFilePath.append(QLatin1Char('.')); - // WinRT/MSVC2015 allows a maximum of 256 characters for a filepath - // unless //?/ is prepended which extends the rule to have a maximum - // of 256 characters in the filename plus the preprending path - m_nativeFilePath.prepend("\\\\?\\"); #endif } } @@ -302,13 +292,9 @@ bool QFileSystemEntry::isDriveRoot() const bool QFileSystemEntry::isDriveRootPath(const QString &path) { -#ifndef Q_OS_WINRT return (path.length() == 3 && path.at(0).isLetter() && path.at(1) == QLatin1Char(':') && path.at(2) == QLatin1Char('/')); -#else // !Q_OS_WINRT - return path == QDir::rootPath(); -#endif // !Q_OS_WINRT } #endif // Q_OS_WIN diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index 3154658e5c..dbd89f5903 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -235,9 +235,7 @@ public: #if defined(Q_OS_WIN) inline void fillFromFileAttribute(DWORD fileAttribute, bool isDriveRoot = false); inline void fillFromFindData(WIN32_FIND_DATA &findData, bool setLinkType = false, bool isDriveRoot = false); -# ifndef Q_OS_WINRT inline void fillFromFindInfo(BY_HANDLE_FILE_INFORMATION &fileInfo); -# endif #endif private: friend class QFileSystemEngine; @@ -372,7 +370,6 @@ inline void QFileSystemMetaData::fillFromFindData(WIN32_FIND_DATA &findData, boo } } -#ifndef Q_OS_WINRT inline void QFileSystemMetaData::fillFromFindInfo(BY_HANDLE_FILE_INFORMATION &fileInfo) { fillFromFileAttribute(fileInfo.dwFileAttributes); @@ -388,7 +385,6 @@ inline void QFileSystemMetaData::fillFromFindInfo(BY_HANDLE_FILE_INFORMATION &fi } knownFlagsMask |= Times | SizeAttribute; } -#endif // !Q_OS_WINRT #endif // Q_OS_WIN QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp index 96d9210c1c..a5e83ac11f 100644 --- a/src/corelib/io/qfilesystemwatcher.cpp +++ b/src/corelib/io/qfilesystemwatcher.cpp @@ -105,7 +105,7 @@ void QFileSystemWatcherPrivate::init() SIGNAL(directoryChanged(QString,bool)), q, SLOT(_q_directoryChanged(QString,bool))); -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) QObject::connect(static_cast(native), &QWindowsFileSystemWatcherEngine::driveLockForRemoval, q, [this] (const QString &p) { _q_winDriveLockForRemoval(p); }); @@ -115,7 +115,7 @@ void QFileSystemWatcherPrivate::init() QObject::connect(static_cast(native), &QWindowsFileSystemWatcherEngine::driveRemoved, q, [this] (const QString &p) { _q_winDriveRemoved(p); }); -#endif // !Q_OS_WINRT +#endif // Q_OS_WIN } } @@ -162,7 +162,7 @@ void QFileSystemWatcherPrivate::_q_directoryChanged(const QString &path, bool re emit q->directoryChanged(path, QFileSystemWatcher::QPrivateSignal()); } -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) void QFileSystemWatcherPrivate::_q_winDriveLockForRemoval(const QString &path) { @@ -201,7 +201,7 @@ void QFileSystemWatcherPrivate::_q_winDriveRemoved(const QString &path) if (!path.isEmpty()) temporarilyRemovedPaths.remove(path.at(0)); } -#endif // Q_OS_WIN && !Q_OS_WINRT +#endif // Q_OS_WIN /*! \class QFileSystemWatcher diff --git a/src/corelib/io/qfilesystemwatcher_p.h b/src/corelib/io/qfilesystemwatcher_p.h index 1997ff6c86..cecfe03ff5 100644 --- a/src/corelib/io/qfilesystemwatcher_p.h +++ b/src/corelib/io/qfilesystemwatcher_p.h @@ -108,14 +108,14 @@ public: void _q_fileChanged(const QString &path, bool removed); void _q_directoryChanged(const QString &path, bool removed); -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) void _q_winDriveLockForRemoval(const QString &); void _q_winDriveLockForRemovalFailed(const QString &); void _q_winDriveRemoved(const QString &); private: QHash temporarilyRemovedPaths; -#endif // Q_OS_WIN && !Q_OS_WINRT +#endif // Q_OS_WIN }; diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp index 2f0a209b76..cc04288de5 100644 --- a/src/corelib/io/qfilesystemwatcher_win.cpp +++ b/src/corelib/io/qfilesystemwatcher_win.cpp @@ -52,7 +52,6 @@ #include -#ifndef Q_OS_WINRT # include # include # include @@ -61,7 +60,6 @@ # include # include # include -#endif // !Q_OS_WINRT QT_BEGIN_NAMESPACE @@ -85,7 +83,6 @@ static Qt::HANDLE createChangeNotification(const QString &path, uint flags) return result; } -#ifndef Q_OS_WINRT /////////// // QWindowsRemovableDriveListener // Listen for the various WM_DEVICECHANGE message indicating drive addition/removal @@ -330,7 +327,6 @@ void QWindowsRemovableDriveListener::addPath(const QString &p) m_removableDrives.push_back(re); } -#endif // !Q_OS_WINRT /////////// // QWindowsFileSystemWatcherEngine @@ -343,7 +339,6 @@ QWindowsFileSystemWatcherEngine::Handle::Handle() QWindowsFileSystemWatcherEngine::QWindowsFileSystemWatcherEngine(QObject *parent) : QFileSystemWatcherEngine(parent) { -#ifndef Q_OS_WINRT if (QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance()) { m_driveListener = new QWindowsRemovableDriveListener(this); eventDispatcher->installNativeEventFilter(m_driveListener); @@ -360,7 +355,6 @@ QWindowsFileSystemWatcherEngine::QWindowsFileSystemWatcherEngine(QObject *parent qWarning("QFileSystemWatcher: Removable drive notification will not work" " if there is no QCoreApplication instance."); } -#endif // !Q_OS_WINRT } QWindowsFileSystemWatcherEngine::~QWindowsFileSystemWatcherEngine() @@ -524,14 +518,12 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, } } -#ifndef Q_OS_WINRT if (Q_LIKELY(m_driveListener)) { for (const QString &path : paths) { if (!unhandled.contains(path)) m_driveListener->addPath(path); } } -#endif // !Q_OS_WINRT return unhandled; } @@ -763,6 +755,4 @@ void QWindowsFileSystemWatcherEngineThread::wakeup() QT_END_NAMESPACE -#ifndef Q_OS_WINRT # include "qfilesystemwatcher_win.moc" -#endif diff --git a/src/corelib/io/qfilesystemwatcher_win_p.h b/src/corelib/io/qfilesystemwatcher_win_p.h index 9d74ca3f61..138b6badf2 100644 --- a/src/corelib/io/qfilesystemwatcher_win_p.h +++ b/src/corelib/io/qfilesystemwatcher_win_p.h @@ -126,9 +126,7 @@ signals: private: QList threads; -#ifndef Q_OS_WINRT QWindowsRemovableDriveListener *m_driveListener = nullptr; -#endif }; class QFileSystemWatcherPathKey : public QString diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index dd4882a2bc..6b1ab5739e 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -53,18 +53,14 @@ #include #include #include -#ifndef Q_OS_WINRT -# include -# include -#endif +#include +#include #include #include #include #include -#ifndef Q_OS_WINRT -# define SECURITY_WIN32 -# include -#endif +#define SECURITY_WIN32 +#include #ifndef PATH_MAX #define PATH_MAX FILENAME_MAX @@ -88,16 +84,12 @@ QString QFSFileEnginePrivate::longFileName(const QString &path) return path; QString absPath = QFileSystemEngine::nativeAbsoluteFilePath(path); -#if !defined(Q_OS_WINRT) QString prefix = QLatin1String("\\\\?\\"); if (isUncPath(absPath)) { prefix.append(QLatin1String("UNC\\")); // "\\\\?\\UNC\\" absPath.remove(0, 2); } return prefix + absPath; -#else - return absPath; -#endif } /* @@ -123,7 +115,6 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) ? OPEN_ALWAYS : OPEN_EXISTING; // Create the file handle. -#ifndef Q_OS_WINRT SECURITY_ATTRIBUTES securityAtts = { sizeof(SECURITY_ATTRIBUTES), NULL, FALSE }; fileHandle = CreateFile((const wchar_t*)fileEntry.nativeFilePath().utf16(), accessRights, @@ -132,13 +123,6 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) creationDisp, FILE_ATTRIBUTE_NORMAL, NULL); -#else // !Q_OS_WINRT - fileHandle = CreateFile2((const wchar_t*)fileEntry.nativeFilePath().utf16(), - accessRights, - shareMode, - creationDisp, - NULL); -#endif // Q_OS_WINRT // Bail out on error. if (fileHandle == INVALID_HANDLE_VALUE) { @@ -428,7 +412,6 @@ int QFSFileEnginePrivate::nativeHandle() const */ bool QFSFileEnginePrivate::nativeIsSequential() const { -#if !defined(Q_OS_WINRT) HANDLE handle = fileHandle; if (fh || fd != -1) handle = (HANDLE)_get_osfhandle(fh ? QT_FILENO(fh) : fd); @@ -438,9 +421,6 @@ bool QFSFileEnginePrivate::nativeIsSequential() const DWORD fileType = GetFileType(handle); return (fileType == FILE_TYPE_CHAR) || (fileType == FILE_TYPE_PIPE); -#else - return false; -#endif } bool QFSFileEngine::caseSensitive() const @@ -450,7 +430,6 @@ bool QFSFileEngine::caseSensitive() const QString QFSFileEngine::currentPath(const QString &fileName) { -#if !defined(Q_OS_WINRT) QString ret; //if filename is a drive: then get the pwd of that drive if (fileName.length() >= 2 && @@ -469,13 +448,8 @@ QString QFSFileEngine::currentPath(const QString &fileName) if (ret.length() >= 2 && ret[1] == QLatin1Char(':')) ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters. return ret; -#else // !Q_OS_WINRT - Q_UNUSED(fileName); - return QFileSystemEngine::currentPath().filePath(); -#endif // Q_OS_WINRT } -#if !defined(Q_OS_WINRT) // cf QStorageInfo::isReady static inline bool isDriveReady(const wchar_t *path) { @@ -485,12 +459,10 @@ static inline bool isDriveReady(const wchar_t *path) || GetVolumeInformation(path, nullptr, 0, nullptr, nullptr, &fileSystemFlags, nullptr, 0) == TRUE; } -#endif // !Q_OS_WINRT QFileInfoList QFSFileEngine::drives() { QFileInfoList ret; -#if !defined(Q_OS_WINRT) const UINT oldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); quint32 driveBits = (quint32) GetLogicalDrives() & 0x3ffffff; wchar_t driveName[] = L"A:\\"; @@ -503,10 +475,6 @@ QFileInfoList QFSFileEngine::drives() } ::SetErrorMode(oldErrorMode); return ret; -#else // !Q_OS_WINRT - ret.append(QFileInfo(QLatin1String("/"))); - return ret; -#endif // Q_OS_WINRT } bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) const @@ -529,7 +497,6 @@ bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) cons bool QFSFileEngine::link(const QString &newName) { -#if !defined(Q_OS_WINRT) bool ret = false; QString linkName = newName; @@ -574,11 +541,6 @@ bool QFSFileEngine::link(const QString &newName) CoUninitialize(); return ret; -#else // !Q_OS_WINRT - Q_UNUSED(newName); - Q_UNIMPLEMENTED(); - return false; -#endif // Q_OS_WINRT } /*! @@ -891,11 +853,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, // first create the file mapping handle DWORD protection = (openMode & QIODevice::WriteOnly) ? PAGE_READWRITE : PAGE_READONLY; -#ifndef Q_OS_WINRT mapHandle = ::CreateFileMapping(handle, 0, protection, 0, 0, 0); -#else - mapHandle = ::CreateFileMappingFromApp(handle, 0, protection, 0, 0); -#endif if (mapHandle == NULL) { q->setError(QFile::PermissionsError, qt_error_string()); #ifdef Q_USE_DEPRECATED_MAP_API @@ -908,24 +866,15 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, DWORD offsetHi = offset >> 32; DWORD offsetLo = offset & Q_UINT64_C(0xffffffff); SYSTEM_INFO sysinfo; -#ifndef Q_OS_WINRT ::GetSystemInfo(&sysinfo); -#else - ::GetNativeSystemInfo(&sysinfo); -#endif DWORD mask = sysinfo.dwAllocationGranularity - 1; DWORD extra = offset & mask; if (extra) offsetLo &= ~mask; // attempt to create the map -#ifndef Q_OS_WINRT LPVOID mapAddress = ::MapViewOfFile(mapHandle, access, offsetHi, offsetLo, size + extra); -#else - LPVOID mapAddress = ::MapViewOfFileFromApp(mapHandle, access, - (ULONG64(offsetHi) << 32) + offsetLo, size + extra); -#endif if (mapAddress) { uchar *address = extra + static_cast(mapAddress); maps[address] = extra; diff --git a/src/corelib/io/qlockfile_win.cpp b/src/corelib/io/qlockfile_win.cpp index 277f8d4230..77cdf66694 100644 --- a/src/corelib/io/qlockfile_win.cpp +++ b/src/corelib/io/qlockfile_win.cpp @@ -65,7 +65,6 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys() // but Windows doesn't allow recreating it while this handle is open anyway, // so this would only create confusion (can't lock, but no lock file to read from). const DWORD dwShareMode = FILE_SHARE_READ; -#ifndef Q_OS_WINRT SECURITY_ATTRIBUTES securityAtts = { sizeof(SECURITY_ATTRIBUTES), NULL, FALSE }; HANDLE fh = CreateFile((const wchar_t*)fileEntry.nativeFilePath().utf16(), GENERIC_READ | GENERIC_WRITE, @@ -74,13 +73,6 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys() CREATE_NEW, // error if already exists FILE_ATTRIBUTE_NORMAL, NULL); -#else // !Q_OS_WINRT - HANDLE fh = CreateFile2((const wchar_t*)fileEntry.nativeFilePath().utf16(), - GENERIC_READ | GENERIC_WRITE, - dwShareMode, - CREATE_NEW, // error if already exists - NULL); -#endif // Q_OS_WINRT if (fh == INVALID_HANDLE_VALUE) { const DWORD lastError = GetLastError(); switch (lastError) { @@ -118,9 +110,6 @@ bool QLockFilePrivate::removeStaleLock() bool QLockFilePrivate::isProcessRunning(qint64 pid, const QString &appname) { - // On WinRT there seems to be no way of obtaining information about other - // processes due to sandboxing -#ifndef Q_OS_WINRT HANDLE procHandle = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid); if (!procHandle) return false; @@ -137,17 +126,11 @@ bool QLockFilePrivate::isProcessRunning(qint64 pid, const QString &appname) if (!processName.isEmpty() && processName != appname) return false; // PID got reused by a different application. -#else // !Q_OS_WINRT - Q_UNUSED(pid); - Q_UNUSED(appname); -#endif // Q_OS_WINRT - return true; } QString QLockFilePrivate::processNameByPid(qint64 pid) { -#if !defined(Q_OS_WINRT) typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD); HMODULE hPsapi = LoadLibraryA("psapi"); @@ -179,10 +162,6 @@ QString QLockFilePrivate::processNameByPid(qint64 pid) if (i >= 0) name.truncate(i); return name; -#else - Q_UNUSED(pid); - return QString(); -#endif } void QLockFile::unlock() diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 854752069e..633777fd5c 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -489,8 +489,7 @@ void QProcessPrivate::Channel::clear() You can also call error() to find the type of error that occurred last, and state() to find the current process state. - \note QProcess is not supported on VxWorks, iOS, tvOS, watchOS, - or the Universal Windows Platform. + \note QProcess is not supported on VxWorks, iOS, tvOS, or watchOS. \section1 Communicating via Channels diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index a15dbb772f..5d84713a67 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -78,19 +78,7 @@ #ifdef Q_OS_WIN // for homedirpath reading from registry # include -# ifndef Q_OS_WINRT -# include -# endif -#endif - -#ifdef Q_OS_WINRT -#include -#include -#include -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -using namespace ABI::Windows::Foundation; -using namespace ABI::Windows::Storage; +# include #endif #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_ANDROID) @@ -286,7 +274,7 @@ after_loop: return result; } -// see also qsettings_win.cpp, qsettings_winrt.cpp and qsettings_mac.cpp +// see also qsettings_win.cpp and qsettings_mac.cpp #if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) && !defined(Q_OS_WASM) QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format, QSettings::Scope scope, @@ -945,7 +933,7 @@ void QConfFileSettingsPrivate::initAccess() sync(); // loads the files the first time } -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) static QString windowsConfigPath(const KNOWNFOLDERID &type) { QString result; @@ -966,44 +954,7 @@ static QString windowsConfigPath(const KNOWNFOLDERID &type) return result; } -#elif defined(Q_OS_WINRT) // Q_OS_WIN && !Q_OS_WINRT - -enum ConfigPathType { - ConfigPath_CommonAppData, - ConfigPath_UserAppData -}; - -static QString windowsConfigPath(ConfigPathType type) -{ - static QString result; - while (result.isEmpty()) { - ComPtr applicationDataStatics; - if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Storage_ApplicationData).Get(), &applicationDataStatics))) - return result; - ComPtr applicationData; - if (FAILED(applicationDataStatics->get_Current(&applicationData))) - return result; - ComPtr localFolder; - if (FAILED(applicationData->get_LocalFolder(&localFolder))) - return result; - ComPtr localFolderItem; - if (FAILED(localFolder.As(&localFolderItem))) - return result; - HString path; - if (FAILED(localFolderItem->get_Path(path.GetAddressOf()))) - return result; - result = QString::fromWCharArray(path.GetRawBuffer(nullptr)); - } - - switch (type) { - case ConfigPath_CommonAppData: - return result + QLatin1String("\\qt-common"); - case ConfigPath_UserAppData: - return result + QLatin1String("\\qt-user"); - } - return result; -} -#endif // Q_OS_WINRT +#endif // Q_OS_WIN static inline int pathHashKey(QSettings::Format format, QSettings::Scope scope) { @@ -1056,14 +1007,8 @@ static std::unique_lock initDefaultPaths(std::unique_lockinsert(pathHashKey(QSettings::IniFormat, QSettings::UserScope), Path(roamingAppDataFolder + QDir::separator(), false)); pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::SystemScope), diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h index 8ddebd2359..548fcb591d 100644 --- a/src/corelib/io/qsettings_p.h +++ b/src/corelib/io/qsettings_p.h @@ -72,10 +72,6 @@ QT_BEGIN_NAMESPACE #define QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER #endif -#if defined(Q_OS_WINRT) -#define QT_QTSETTINGS_FORGET_ORIGINAL_KEY_ORDER -#endif - // used in testing framework #define QSETTINGS_P_H_VERSION 3 diff --git a/src/corelib/io/qsettings_winrt.cpp b/src/corelib/io/qsettings_winrt.cpp deleted file mode 100644 index a208262ab4..0000000000 --- a/src/corelib/io/qsettings_winrt.cpp +++ /dev/null @@ -1,690 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsettings.h" - -#include "qsettings_p.h" -#include "qvector.h" -#include "qmap.h" -#include "qdebug.h" -#include "qfunctions_winrt.h" - -#include -#include -#include -#include - -using namespace ABI::Windows::ApplicationModel; -using namespace ABI::Windows::Storage; -using namespace ABI::Windows::Foundation; -using namespace ABI::Windows::Foundation::Collections; -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; - -typedef ITypedEventHandler DataHandler; -typedef Collections::IKeyValuePair ContainerItem; -typedef Collections::IIterable ContainerIterable; -typedef Collections::IIterator ContainerIterator; - -typedef Collections::IKeyValuePair ValueItem; -typedef Collections::IIterable ValueIterable; -typedef Collections::IIterator ValueIterator; - -QT_BEGIN_NAMESPACE - -static IApplicationDataContainer *subContainer(IApplicationDataContainer *parent, const QString &name) -{ - ComPtr> childrenContainer; - HRESULT hr = parent->get_Containers(&childrenContainer); - if (FAILED(hr)) - return 0; - - ComPtr< ContainerIterable > iterable; - ComPtr< ContainerIterator > iterator; - - hr = childrenContainer.As(&iterable); - if (FAILED(hr)) - return 0; - - hr = iterable->First(&iterator); - if (FAILED(hr)) - return 0; - boolean current; - hr = iterator->get_HasCurrent(¤t); - if (FAILED(hr)) - return 0; - - while (SUCCEEDED(hr) && current) { - ComPtr item; - hr = iterator->get_Current(&item); - if (FAILED(hr)) - return 0; - - HString key; - hr = item->get_Key(key.GetAddressOf()); - if (FAILED(hr)) - continue; - QString subName = QString::fromWCharArray(key.GetRawBuffer(nullptr)); - if (name == subName) { - IApplicationDataContainer *container; - hr = item->get_Value(&container); - return SUCCEEDED(hr) ? container : 0; - } - hr = iterator->MoveNext(¤t); - } - - return 0; -} - -static QStringList subContainerNames(IApplicationDataContainer *container, bool recursive = false) -{ - QStringList result; - ComPtr> childrenContainer; - HRESULT hr = container->get_Containers(&childrenContainer); - if (FAILED(hr)) - return result; - - ComPtr< ContainerIterable > iterable; - ComPtr< ContainerIterator > iterator; - - hr = childrenContainer.As(&iterable); - if (FAILED(hr)) - return result; - - hr = iterable->First(&iterator); - if (FAILED(hr)) - return result; - boolean current; - hr = iterator->get_HasCurrent(¤t); - if (FAILED(hr)) - return result; - - while (SUCCEEDED(hr) && current) { - ComPtr item; - hr = iterator->get_Current(&item); - if (FAILED(hr)) - return result; - - HString key; - hr = item->get_Key(key.GetAddressOf()); - if (SUCCEEDED(hr)) { - QString subName = QString::fromWCharArray(key.GetRawBuffer(nullptr)); - result.append(subName); - if (recursive) { - ComPtr sub = subContainer(container, subName); - QStringList subSubNames = subContainerNames(sub.Get(), recursive); - for (int i = 0; i < subSubNames.size(); ++i) - subSubNames[i] = subName + QLatin1Char('/') + subSubNames[i]; - result.append(subSubNames); - } - hr = iterator->MoveNext(¤t); - } - } - return result; -} - -static QStringList keyNames(IApplicationDataContainer *container) { - HRESULT hr; - QStringList result; - ComPtr values; - hr = container->get_Values(&values); - if (FAILED(hr)) - return result; - - ComPtr> settingsMap; - - hr = values.As(&settingsMap); - if (FAILED(hr)) - return result; - - ComPtr> mapView; - hr = settingsMap->GetView(&mapView); - if (FAILED(hr)) - return result; - - ComPtr< ValueIterable > iterable; - ComPtr< ValueIterator > iterator; - - hr = mapView.As(&iterable); - if (FAILED(hr)) - return result; - - boolean current = false; - hr = iterable->First(&iterator); - if (FAILED(hr)) - return result; - hr = iterator->get_HasCurrent(¤t); - if (FAILED(hr)) - return result; - - while (SUCCEEDED(hr) && current){ - ComPtr item; - hr = iterator->get_Current(&item); - if (FAILED(hr)) - return result; - - HString key; - hr = item->get_Key(key.GetAddressOf()); - if (SUCCEEDED(hr)) { - result += QString::fromWCharArray(key.GetRawBuffer(nullptr)); - hr = iterator->MoveNext(¤t); - } - } - return result; -} - -static IApplicationDataContainer *createSubContainer(IApplicationDataContainer *parent, const QString &name) -{ - HStringReference childGroupNativeName((const wchar_t*)name.utf16(), name.size()); - - IApplicationDataContainer *result = subContainer(parent, name); - if (!result) - parent->CreateContainer(childGroupNativeName.Get(), ApplicationDataCreateDisposition_Always, &result); - return result; -} - -#define PROP_CASE_TO_VARIANT(TYPE, VARTYPE, QTYPE) \ - case PropertyType_##TYPE: { \ - VARTYPE v; \ - value->Get##TYPE(&v); \ - result.setValue( QTYPE(v) ); \ - break; \ - } - -static QVariant propertyValueToQVariant(IPropertyValue *value) -{ - QVariant result; - PropertyType type; - value->get_Type(&type); - switch (type) { - PROP_CASE_TO_VARIANT(Boolean, boolean, bool) - PROP_CASE_TO_VARIANT(UInt8, UINT8, quint8) - PROP_CASE_TO_VARIANT(Int16, INT16, qint16) - PROP_CASE_TO_VARIANT(UInt16, UINT16, quint16) - PROP_CASE_TO_VARIANT(Int32, INT32, qint32) - PROP_CASE_TO_VARIANT(UInt32, UINT32, quint32) - PROP_CASE_TO_VARIANT(Int64, INT64, qint64) - PROP_CASE_TO_VARIANT(UInt64, UINT64, quint64) - PROP_CASE_TO_VARIANT(Single, FLOAT, float) - PROP_CASE_TO_VARIANT(Double, DOUBLE, double) - case PropertyType_StringArray: { - UINT32 size; - HSTRING *content; - value->GetStringArray(&size, &content); - QStringList list; - // The last item is assumed to be added by us - for (UINT32 i = 0; i < size - 1; ++i) { - QString s = QString::fromWCharArray(WindowsGetStringRawBuffer(content[i], nullptr)); - list.append(s); - } - result = QSettingsPrivate::stringListToVariantList(list); - break; - } - case PropertyType_String: { - HString v; - value->GetString(v.GetAddressOf()); - result = QSettingsPrivate::stringToVariant(QString::fromWCharArray(v.GetRawBuffer(nullptr))); - break; - } - default: { - UINT32 size; - BYTE *arr; - value->GetUInt8Array(&size, &arr); - QByteArray data = QByteArray::fromRawData((const char*)arr, size); - QString s; - if (size) { - // We assume this is our qt stored data like on other platforms - // as well. QList and others are converted to byte arrays - s = QString::fromWCharArray((const wchar_t *)data.constData(), data.size() / 2); - result = QSettingsPrivate::stringToVariant(s); - } - break; - } - } - return result; -} - -class QWinRTSettingsPrivate : public QSettingsPrivate -{ -public: - QWinRTSettingsPrivate(QSettings::Scope scope, const QString &organization, - const QString &application); - QWinRTSettingsPrivate(const QString &rKey); - ~QWinRTSettingsPrivate(); - - void remove(const QString &uKey) override; - void set(const QString &uKey, const QVariant &value) override; - bool get(const QString &uKey, QVariant *value) const override; - QStringList children(const QString &uKey, ChildSpec spec) const override; - void clear() override; - void sync() override; - void flush() override; - bool isWritable() const override; - QString fileName() const override; - -private: - void init(QSettings::Scope scope); - IApplicationDataContainer *getContainer(IApplicationDataContainer *parent, const QString &group, bool create = false) const; - void clearContainerMaps(); - - HRESULT onDataChanged(IApplicationData*, IInspectable*); - - ComPtr applicationData; - QVector> readContainers; - ComPtr writeContainer; - EventRegistrationToken dataChangedToken; -}; - -QWinRTSettingsPrivate::QWinRTSettingsPrivate(QSettings::Scope scope, const QString &organization, - const QString &application) - : QSettingsPrivate(QSettings::NativeFormat, scope, organization, application) - , writeContainer(0) -{ - init(scope); -} - -QWinRTSettingsPrivate::QWinRTSettingsPrivate(const QString &rPath) - : QSettingsPrivate(QSettings::NativeFormat, QSettings::UserScope, rPath, QString()) - , writeContainer(0) -{ - init(QSettings::UserScope); -} - -QWinRTSettingsPrivate::~QWinRTSettingsPrivate() -{ - clearContainerMaps(); -} - -void QWinRTSettingsPrivate::remove(const QString &uKey) -{ - int lastIndex = uKey.lastIndexOf(QLatin1Char('/')); - QString groupName = (lastIndex > 0) ? uKey.left(lastIndex) : QString(); - QString groupKey = uKey.mid(lastIndex + 1); - - ComPtr container = getContainer(writeContainer.Get(), groupName, false); - if (!container) - return; - - HRESULT hr; - ComPtr values; - hr = container->get_Values(&values); - if (FAILED(hr)) - return; - - ComPtr> settingsMap; - - hr = values.As(&settingsMap); - if (FAILED(hr)) - return; - - HStringReference ref((const wchar_t*)groupKey.utf16(), groupKey.size()); - hr = settingsMap->Remove(ref.Get()); - - // groupKey can be a container as well - hr = container->DeleteContainer(ref.Get()); - init(scope); -} - -void QWinRTSettingsPrivate::set(const QString &uKey, const QVariant &value) -{ - int lastIndex = uKey.lastIndexOf(QLatin1Char('/')); - QString groupName = (lastIndex > 0) ? uKey.left(lastIndex) : QString(); - QString groupKey = uKey.mid(lastIndex + 1); - - ComPtr container = getContainer(writeContainer.Get(), groupName, true); - - ComPtr values; - HRESULT hr = container->get_Values(&values); - if (FAILED(hr)) { - qErrnoWarning(hr, "Could not access Windows container values"); - setStatus(QSettings::AccessError); - return; - } - - ComPtr> settingsMap; - hr = values.As(&settingsMap); - if (FAILED(hr)) { - setStatus(QSettings::AccessError); - return; - } - - ComPtr valueStatics; - hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Foundation_PropertyValue).Get(), &valueStatics); - if (FAILED(hr)) { - setStatus(QSettings::AccessError); - return; - } - - ComPtr val; - - switch (value.type()) { - case QVariant::List: - case QVariant::StringList: { - QStringList l = variantListToStringList(value.toList()); - QStringList::const_iterator it = l.constBegin(); - bool containsNull = false; - for (; it != l.constEnd(); ++it) { - if ((*it).length() == 0 || it->contains(QChar::Null)) { - // We can only store as binary - containsNull = true; - break; - } - } - - if (containsNull) { - // Store binary - const QString s = variantToString(value); - hr = valueStatics->CreateUInt8Array(s.length() * 2, (BYTE*) s.utf16(), &val); - } else { - // Store as native string list - int size = l.size(); - HSTRING *nativeHandleList = new HSTRING[size+1]; - for (int i = 0; i < size; ++i) - hr = WindowsCreateString((const wchar_t*)l[i].utf16(), l[i].size(), &nativeHandleList[i]); - // Add end marker - hr = WindowsCreateString((const wchar_t*)L"\0\0@", 3, &nativeHandleList[size]); - hr = valueStatics->CreateStringArray(size + 1 , nativeHandleList, &val); - for (int i = 0; i < size; ++i) - hr = WindowsDeleteString(nativeHandleList[i]); - delete [] nativeHandleList; - } - break; - } - case QVariant::Bool: - hr = valueStatics->CreateBoolean(boolean(value.toBool()), &val); - break; - case QVariant::Int: - hr = valueStatics->CreateInt32(INT32(value.toInt()), &val); - break; - case QVariant::UInt: - hr = valueStatics->CreateUInt32(UINT32(value.toUInt()), &val); - break; - case QVariant::LongLong: - hr = valueStatics->CreateInt64(INT64(value.toLongLong()), &val); - break; - case QVariant::ULongLong: - hr = valueStatics->CreateUInt64(UINT64(value.toULongLong()), &val); - break; - default: { - const QString s = variantToString(value); - if (s.contains(QChar::Null)) { - hr = valueStatics->CreateUInt8Array(s.length() * 2, (BYTE*) s.utf16(), &val); - } else { - HStringReference ref((const wchar_t*)s.utf16(), s.size()); - hr = valueStatics->CreateString(ref.Get(), &val); - } - - break; - } - } - - RETURN_VOID_IF_FAILED("QSettings: Could not save QVariant value into IInspectable"); - - HStringReference key((const wchar_t*)groupKey.utf16(), groupKey.size()); - boolean rep; - - hr = settingsMap->Insert(key.Get(), val.Get(), &rep); - RETURN_VOID_IF_FAILED("QSettings: Could not store value"); -} - -bool QWinRTSettingsPrivate::get(const QString &uKey, QVariant *value) const -{ - int lastIndex = uKey.lastIndexOf(QLatin1Char('/')); - QString groupName = (lastIndex > 0) ? uKey.left(lastIndex) : QString(); - QString groupKey = uKey.mid(lastIndex + 1); - - HRESULT hr; - - for (int i = 0; i < readContainers.size(); ++i) { - ComPtr container = const_cast(this)->getContainer(readContainers.at(i).Get(), groupName); - - if (!container) - continue; - - ComPtr values; - hr = container->get_Values(&values); - if (FAILED(hr)) - continue; - - ComPtr> settingsMap; - hr = values.As(&settingsMap); - if (FAILED(hr)) - continue; - - HStringReference key((const wchar_t*)groupKey.utf16(), groupKey.size()); - boolean exists; - - hr = settingsMap.Get()->HasKey(key.Get(), &exists); - if (FAILED(hr)) - continue; - - if (!exists) { - if (!fallbacks) - break; - else - continue; - } - - if (value) { - ComPtr val; - hr = settingsMap->Lookup(key.Get(), &val); - if (FAILED(hr)) - return false; - - ComPtr pVal; - hr = val.As(&pVal); - if (FAILED(hr)) - return false; - - *value = propertyValueToQVariant(pVal.Get()); - } - return true; - } - setStatus(QSettings::AccessError); - return false; -} - -QStringList QWinRTSettingsPrivate::children(const QString &uKey, ChildSpec spec) const -{ - QStringList result; - for (int i = 0; i < readContainers.size(); ++i) { - ComPtr container = getContainer(readContainers.at(i).Get(), uKey, false); - if (!container.Get()) - continue; - - // Get Keys in this container - if (spec == AllKeys || spec == ChildKeys) - result += keyNames(container.Get()); - - // Get Subcontainer(s) - if (spec == AllKeys || spec == ChildGroups) { - const QStringList subContainerList = subContainerNames(container.Get(), spec == AllKeys); - - if (spec == AllKeys) { - for (const QString &item : subContainerList) { - const QString subChildren = uKey.isEmpty() ? item : (uKey + QLatin1Char('/') + item); - const QStringList subResult = children(subChildren, ChildKeys); - for (const QString &subItem : subResult) - result += item + QLatin1Char('/') + subItem; - } - } - - if (spec == ChildGroups) - result += subContainerList; - } - - } - result.removeDuplicates(); - return result; -} - -void QWinRTSettingsPrivate::clear() -{ - ComPtr container; - HRESULT hr; - if (scope == QSettings::UserScope) - hr = applicationData->get_LocalSettings(&container); - else - hr = applicationData->get_RoamingSettings(&container); - - RETURN_VOID_IF_FAILED("Could not access settings container"); - - QString containerName = applicationName.isEmpty() ? organizationName : applicationName; - HStringReference containerNativeName((const wchar_t*)containerName.utf16(), containerName.size()); - - hr = container->DeleteContainer(containerNativeName.Get()); - RETURN_VOID_IF_FAILED("Could not delete Container"); - - init(scope); -} - -void QWinRTSettingsPrivate::sync() -{ - // No native sync available -} - -void QWinRTSettingsPrivate::flush() -{ - // No native flush available -} - -QString QWinRTSettingsPrivate::fileName() const -{ - Q_UNIMPLEMENTED(); - return QString(); -} - -HRESULT QWinRTSettingsPrivate::onDataChanged(IApplicationData *, IInspectable *) -{ - // This only happens, if roaming data is changed by the OS. - // To ensure sanity we clean up the map and start from scratch - init(scope); - return S_OK; -} - -void QWinRTSettingsPrivate::init(QSettings::Scope scope) -{ - clearContainerMaps(); - - ComPtr applicationDataStatics; - HRESULT hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Storage_ApplicationData).Get(), &applicationDataStatics); - if (FAILED(hr)) { - qErrnoWarning(hr, "Could not access Storage Factory"); - setStatus(QSettings::AccessError); - return; - } - - hr = applicationDataStatics->get_Current(&applicationData); - if (FAILED(hr)) { - qErrnoWarning(hr, "Could not access application data statics"); - setStatus(QSettings::AccessError); - return; - } - - const QString organizationString = organizationName.isEmpty() ? QLatin1String("OrganizationDefaults") : organizationName; - ComPtr localContainer; - if (scope == QSettings::UserScope && SUCCEEDED(applicationData->get_LocalSettings(&localContainer))) { - if (!applicationName.isEmpty()) - readContainers.append(createSubContainer(localContainer.Get(), applicationName)); - readContainers.append(createSubContainer(localContainer.Get(), organizationString)); - } - - ComPtr roamingContainer; - if (SUCCEEDED(applicationData->get_RoamingSettings(&roamingContainer))) { - if (!applicationName.isEmpty()) - readContainers.append(createSubContainer(roamingContainer.Get(), applicationName)); - readContainers.append(createSubContainer(roamingContainer.Get(), organizationString)); - } - - ComPtr writeRootContainer = (scope == QSettings::UserScope) ? localContainer : roamingContainer; - if (!applicationName.isEmpty()) - writeContainer = createSubContainer(writeRootContainer.Get(), applicationName); - else - writeContainer = createSubContainer(writeRootContainer.Get(), organizationString); - - hr = applicationData->add_DataChanged(Callback(this, &QWinRTSettingsPrivate::onDataChanged).Get(), &dataChangedToken); -} - -IApplicationDataContainer *QWinRTSettingsPrivate::getContainer(IApplicationDataContainer *parent, const QString &group, bool create) const -{ - IApplicationDataContainer *current = parent; - if (group.isEmpty()) - return current; - const QStringList groupPath = group.split(QLatin1Char('/'), Qt::SkipEmptyParts); - - for (const QString &subGroup : groupPath) { - ComPtr sub = subContainer(current, subGroup); - if (!sub && create) - sub = createSubContainer(current, subGroup); - if (!sub) - return 0; // Something seriously went wrong - current = sub.Detach(); - } - return current; -} - -void QWinRTSettingsPrivate::clearContainerMaps() -{ - readContainers.clear(); - writeContainer.Reset(); -} - -bool QWinRTSettingsPrivate::isWritable() const -{ - return true; -} - -QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format, QSettings::Scope scope, - const QString &organization, const QString &application) -{ - if (format == QSettings::NativeFormat) - return new QWinRTSettingsPrivate(scope, organization, application); - else - return new QConfFileSettingsPrivate(format, scope, organization, application); -} - -QSettingsPrivate *QSettingsPrivate::create(const QString &fileName, QSettings::Format format) -{ - if (format == QSettings::NativeFormat) - return new QWinRTSettingsPrivate(fileName); - else - return new QConfFileSettingsPrivate(fileName, format); -} - -QT_END_NAMESPACE diff --git a/src/corelib/io/qstandardpaths_winrt.cpp b/src/corelib/io/qstandardpaths_winrt.cpp deleted file mode 100644 index a7de15472e..0000000000 --- a/src/corelib/io/qstandardpaths_winrt.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qstandardpaths.h" - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -using namespace ABI::Windows::Foundation; -using namespace ABI::Windows::Storage; -using namespace ABI::Windows::ApplicationModel; - -#ifndef QT_NO_STANDARDPATHS - -QT_BEGIN_NAMESPACE - -static QString convertCharArray(const wchar_t *path) -{ - return QDir::fromNativeSeparators(QString::fromWCharArray(path)); -} - -QString QStandardPaths::writableLocation(StandardLocation type) -{ - QString result; - - switch (type) { - case ConfigLocation: // same as AppLocalDataLocation, on Windows - case GenericConfigLocation: // same as GenericDataLocation, on Windows - case AppConfigLocation: - case AppDataLocation: - case AppLocalDataLocation: - case GenericDataLocation: { - ComPtr applicationDataStatics; - if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Storage_ApplicationData).Get(), &applicationDataStatics))) - break; - ComPtr applicationData; - if (FAILED(applicationDataStatics->get_Current(&applicationData))) - break; - ComPtr settingsFolder; - if (FAILED(applicationData->get_LocalFolder(&settingsFolder))) - break; - ComPtr settingsFolderItem; - if (FAILED(settingsFolder.As(&settingsFolderItem))) - break; - HString path; - if (FAILED(settingsFolderItem->get_Path(path.GetAddressOf()))) - break; - result = convertCharArray(path.GetRawBuffer(nullptr)); - if (isTestModeEnabled()) - result += QLatin1String("/qttest"); - break; - } - case CacheLocation: - return writableLocation(AppLocalDataLocation) + QLatin1String("/cache"); - - case GenericCacheLocation: - return writableLocation(GenericDataLocation) + QLatin1String("/cache"); - - case TempLocation: - result = QDir::tempPath(); - break; - - case ApplicationsLocation: - case DesktopLocation: - case FontsLocation: - case HomeLocation: - case RuntimeLocation: - // these are read-only - break; - - case DocumentsLocation: - case MusicLocation: - case MoviesLocation: - case PicturesLocation: - case DownloadLocation: - default: - Q_UNIMPLEMENTED(); - } - return result; - -} - -QStringList QStandardPaths::standardLocations(StandardLocation type) -{ - const QString writable = writableLocation(type); - return writable.isEmpty() ? QStringList() : QStringList(writable); -} - -QT_END_NAMESPACE - -#endif // QT_NO_STANDARDPATHS diff --git a/src/corelib/io/qstorageinfo_p.h b/src/corelib/io/qstorageinfo_p.h index ec5bb785e3..421e364311 100644 --- a/src/corelib/io/qstorageinfo_p.h +++ b/src/corelib/io/qstorageinfo_p.h @@ -71,7 +71,7 @@ public: static QStorageInfo root(); protected: -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) void retrieveVolumeInfo(); void retrieveDiskFreeSpace(); #elif defined(Q_OS_MAC) diff --git a/src/corelib/io/qstorageinfo_stub.cpp b/src/corelib/io/qstorageinfo_stub.cpp deleted file mode 100644 index a312b9dc89..0000000000 --- a/src/corelib/io/qstorageinfo_stub.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Ivan Komissarov -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qstorageinfo_p.h" - -QT_BEGIN_NAMESPACE - -void QStorageInfoPrivate::initRootPath() -{ - Q_UNIMPLEMENTED(); - rootPath = QString(); -} - -void QStorageInfoPrivate::doStat() -{ - Q_UNIMPLEMENTED(); -} - -QList QStorageInfoPrivate::mountedVolumes() -{ - Q_UNIMPLEMENTED(); - return QList(); -} - -QStorageInfo QStorageInfoPrivate::root() -{ - Q_UNIMPLEMENTED(); - return QStorageInfo(); -} - -QT_END_NAMESPACE diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index c016a622c7..e6a160c3b2 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -219,17 +219,10 @@ static bool createFileFromTemplate(NativeFileHandle &file, QTemporaryFileName &t const DWORD shareMode = (flags & QTemporaryFileEngine::Win32NonShared) ? 0u : (FILE_SHARE_READ | FILE_SHARE_WRITE); -# ifndef Q_OS_WINRT file = CreateFile((const wchar_t *)path.constData(), GENERIC_READ | GENERIC_WRITE, shareMode, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); -# else // !Q_OS_WINRT - file = CreateFile2((const wchar_t *)path.constData(), - GENERIC_READ | GENERIC_WRITE, - shareMode, CREATE_NEW, - NULL); -# endif // Q_OS_WINRT if (file != INVALID_HANDLE_VALUE) return true; @@ -380,7 +373,7 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) return false; } -#if !defined(Q_OS_WIN) || defined(Q_OS_WINRT) +#if !defined(Q_OS_WIN) d->closeFileHandle = true; #endif diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri index 76609894ba..fc48ef430e 100644 --- a/src/corelib/kernel/kernel.pri +++ b/src/corelib/kernel/kernel.pri @@ -88,27 +88,15 @@ win32 { kernel/qsystemsemaphore_win.cpp HEADERS += \ kernel/qwineventnotifier.h \ - kernel/qwineventnotifier_p.h - - winrt { - SOURCES += kernel/qeventdispatcher_winrt.cpp - HEADERS += kernel/qeventdispatcher_winrt_p.h - } else { - SOURCES += kernel/qeventdispatcher_win.cpp \ - kernel/qwinregistry.cpp - HEADERS += kernel/qeventdispatcher_win_p.h \ - kernel/qwinregistry_p.h - } - - !winrt: LIBS_PRIVATE += -lversion -} + kernel/qwineventnotifier_p.h \ + kernel/qfunctions_winrt_p.h -winrt { - SOURCES += \ - kernel/qfunctions_winrt.cpp - HEADERS += \ - kernel/qfunctions_fake_env_p.h \ - kernel/qfunctions_winrt.h + SOURCES += kernel/qeventdispatcher_win.cpp \ + kernel/qwinregistry.cpp + HEADERS += kernel/qeventdispatcher_win_p.h \ + kernel/qwinregistry_p.h + + LIBS_PRIVATE += -lversion } mac { diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 43f641244b..a3414b3edc 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -87,16 +87,7 @@ # include "qeventdispatcher_unix_p.h" #endif #ifdef Q_OS_WIN -# ifdef Q_OS_WINRT -# include "qeventdispatcher_winrt_p.h" -# include "qfunctions_winrt.h" -# include -# include - using namespace ABI::Windows::ApplicationModel::Core; - using namespace Microsoft::WRL; -# else -# include "qeventdispatcher_win_p.h" -# endif +#include "qeventdispatcher_win_p.h" #endif #endif // QT_NO_QOBJECT @@ -397,7 +388,7 @@ Q_GLOBAL_STATIC(QCoreApplicationData, coreappdata) static bool quitLockRefEnabled = true; #endif -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) // Check whether the command line arguments match those passed to main() // by comparing to the global __argv/__argc (MS extension). // Deep comparison is required since argv/argc is rebuilt by WinMain for @@ -423,7 +414,7 @@ static inline bool contains(int argc, char **argv, const char *needle) } return false; } -#endif // Q_OS_WIN && !Q_OS_WINRT +#endif // Q_OS_WIN QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint flags) : @@ -432,7 +423,7 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint #endif argc(aargc) , argv(aargv) -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) , origArgc(0) , origArgv(nullptr) #endif @@ -451,13 +442,13 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint argc = 0; argv = const_cast(&empty); } -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) if (!isArgvModified(argc, argv)) { origArgc = argc; origArgv = new char *[argc]; std::copy(argv, argv + argc, QT_MAKE_CHECKED_ARRAY_ITERATOR(origArgv, argc)); } -#endif // Q_OS_WIN && !Q_OS_WINRT +#endif // Q_OS_WIN #ifndef QT_NO_QOBJECT QCoreApplicationPrivate::is_app_closing = false; @@ -467,10 +458,6 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint qFatal("FATAL: The application binary appears to be running setuid, this is a security hole."); # endif // Q_OS_UNIX -#ifdef Q_OS_WINRT - QThreadData::setMainThread(); -#endif - QThread *cur = QThread::currentThread(); // note: this may end up setting theMainThread! if (cur != theMainThread.loadAcquire()) qWarning("WARNING: QApplication was not created in the main() thread."); @@ -482,7 +469,7 @@ QCoreApplicationPrivate::~QCoreApplicationPrivate() #ifndef QT_NO_QOBJECT cleanupThreadData(); #endif -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) delete [] origArgv; #endif QCoreApplicationPrivate::clearApplicationFilePath(); @@ -570,10 +557,6 @@ void QCoreApplicationPrivate::appendApplicationPathToLibraryPaths() coreappdata()->app_libpaths.reset(app_libpaths = new QStringList); QString app_location = QCoreApplication::applicationFilePath(); app_location.truncate(app_location.lastIndexOf(QLatin1Char('/'))); -#ifdef Q_OS_WINRT - if (app_location.isEmpty()) - app_location.append(QLatin1Char('/')); -#endif app_location = QDir(app_location).canonicalPath(); if (QFile::exists(app_location) && !app_libpaths->contains(app_location)) app_libpaths->append(app_location); @@ -2466,7 +2449,7 @@ QStringList QCoreApplication::arguments() char ** const av = self->d_func()->argv; list.reserve(ac); -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) // On Windows, it is possible to pass Unicode arguments on // the command line. To restore those, we split the command line // and filter out arguments that were deleted by derived application @@ -2483,7 +2466,7 @@ QStringList QCoreApplication::arguments() } return list; } // Fall back to rebuilding from argv/argc when a modified argv was passed. -#endif // defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#endif // defined(Q_OS_WIN) for (int a = 0; a < ac; ++a) { list << QString::fromLocal8Bit(av[a]); @@ -2622,9 +2605,6 @@ QString QCoreApplication::applicationName() \row \li Windows (classic desktop) \li PRODUCTVERSION parameter of the VERSIONINFO resource - \row - \li Universal Windows Platform - \li version attribute of the application package manifest \row \li macOS, iOS, tvOS, watchOS \li CFBundleVersion property of the information property list diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 9d2fde619c..cb3a5a8a4f 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -154,7 +154,7 @@ public: int &argc; char **argv; -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) int origArgc; char **origArgv; // store unmodified arguments for QCoreApplication::arguments() #endif diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp index 824c0535ed..a0fbf97838 100644 --- a/src/corelib/kernel/qcoreapplication_win.cpp +++ b/src/corelib/kernel/qcoreapplication_win.cpp @@ -53,16 +53,6 @@ #include #include -#ifdef Q_OS_WINRT -#include -#include -#include -#include -using namespace ABI::Windows::ApplicationModel; -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -#endif - QT_BEGIN_NAMESPACE Q_CORE_EXPORT QString qAppFileName() // get application file name @@ -105,33 +95,6 @@ QString QCoreApplicationPrivate::appVersion() const { QString applicationVersion; #ifndef QT_BOOTSTRAPPED -# ifdef Q_OS_WINRT - HRESULT hr; - - ComPtr packageFactory; - hr = RoGetActivationFactory( - HString::MakeReference(RuntimeClass_Windows_ApplicationModel_Package).Get(), - IID_PPV_ARGS(&packageFactory)); - RETURN_IF_FAILED("Failed to create package instance", return QString()); - - ComPtr package; - packageFactory->get_Current(&package); - RETURN_IF_FAILED("Failed to get current application package", return QString()); - - ComPtr packageId; - package->get_Id(&packageId); - RETURN_IF_FAILED("Failed to get current application package ID", return QString()); - - PackageVersion version; - packageId->get_Version(&version); - RETURN_IF_FAILED("Failed to get current application package version", return QString()); - - applicationVersion = QStringLiteral("%1.%2.%3.%4") - .arg(version.Major) - .arg(version.Minor) - .arg(version.Build) - .arg(version.Revision); -# else const QString appFileName = qAppFileName(); QVarLengthArray buffer(appFileName.size() + 1); buffer[appFileName.toWCharArray(buffer.data())] = 0; @@ -154,13 +117,10 @@ QString QCoreApplicationPrivate::appVersion() const } } } -# endif #endif return applicationVersion; } -#ifndef Q_OS_WINRT - #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) Q_CORE_EXPORT HINSTANCE qWinAppInst() // get Windows app handle { @@ -913,8 +873,6 @@ QDebug operator<<(QDebug dbg, const MSG &msg) #endif // QT_NO_QOBJECT -#endif // !defined(Q_OS_WINRT) - #ifndef QT_NO_QOBJECT void QCoreApplicationPrivate::removePostedTimerEvent(QObject *object, int timerId) { diff --git a/src/corelib/kernel/qcorecmdlineargs_p.h b/src/corelib/kernel/qcorecmdlineargs_p.h index 33445a1625..b9f1ef6317 100644 --- a/src/corelib/kernel/qcorecmdlineargs_p.h +++ b/src/corelib/kernel/qcorecmdlineargs_p.h @@ -82,17 +82,7 @@ static inline QStringList qWinCmdArgs(const QString &cmdLine) return result; } -#elif defined(Q_OS_WINRT) // Q_OS_WIN32 - -static inline QStringList qCmdLineArgs(int argc, char *argv[]) -{ - QStringList args; - for (int i = 0; i != argc; ++i) - args += QString::fromLocal8Bit(argv[i]); - return args; -} - -#endif // Q_OS_WINRT +#endif // Q_OS_WIN32 QT_END_NAMESPACE diff --git a/src/corelib/kernel/qeventdispatcher_winrt.cpp b/src/corelib/kernel/qeventdispatcher_winrt.cpp deleted file mode 100644 index f7a1f969a8..0000000000 --- a/src/corelib/kernel/qeventdispatcher_winrt.cpp +++ /dev/null @@ -1,656 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qeventdispatcher_winrt_p.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -using namespace ABI::Windows::System::Threading; -using namespace ABI::Windows::Foundation; -using namespace ABI::Windows::Foundation::Collections; -using namespace ABI::Windows::UI::Core; -using namespace ABI::Windows::ApplicationModel::Core; - -QT_BEGIN_NAMESPACE - -#define INTERRUPT_HANDLE 0 -#define INVALID_TIMER_ID -1 - -struct WinRTTimerInfo : public QAbstractEventDispatcher::TimerInfo { - WinRTTimerInfo(int timerId = INVALID_TIMER_ID, int interval = 0, Qt::TimerType timerType = Qt::CoarseTimer, - QObject *obj = 0, quint64 tt = 0) : - QAbstractEventDispatcher::TimerInfo(timerId, interval, timerType), - inEvent(false), object(obj), targetTime(tt) - { - } - - bool inEvent; - QObject *object; - quint64 targetTime; -}; - -class AgileDispatchedHandler : public RuntimeClass, IDispatchedHandler, IAgileObject> -{ -public: - AgileDispatchedHandler(const std::function &delegate) - : delegate(delegate) - { - } - - HRESULT __stdcall Invoke() - { - return delegate(); - } - -private: - std::function delegate; -}; - -class QWorkHandler : public IWorkItemHandler -{ -public: - QWorkHandler(const std::function &delegate) - : m_delegate(delegate) - { - } - - STDMETHODIMP Invoke(ABI::Windows::Foundation::IAsyncAction *operation) - { - HRESULT res = m_delegate(); - Q_UNUSED(operation); - return res; - } - - STDMETHODIMP QueryInterface(REFIID riid, void FAR* FAR* ppvObj) - { - if (riid == IID_IUnknown || riid == IID_IWorkItemHandler) { - *ppvObj = this; - AddRef(); - return NOERROR; - } - *ppvObj = NULL; - return ResultFromScode(E_NOINTERFACE); - } - - STDMETHODIMP_(ULONG) AddRef(void) - { - return ++m_refs; - } - - STDMETHODIMP_(ULONG) Release(void) - { - if (--m_refs == 0) { - delete this; - return 0; - } - return m_refs; - } - -private: - std::function m_delegate; - ULONG m_refs{0}; -}; - -class QEventDispatcherWinRTPrivate : public QAbstractEventDispatcherPrivate -{ - Q_DECLARE_PUBLIC(QEventDispatcherWinRT) - -public: - QEventDispatcherWinRTPrivate(); - ~QEventDispatcherWinRTPrivate(); - -private: - QHash timerIdToObject; - QVector timerInfos; - mutable QMutex timerInfoLock; - QHash timerHandleToId; - QHash timerIdToHandle; - QHash timerIdToCancelHandle; - - void addTimer(int id, int interval, Qt::TimerType type, QObject *obj, - HANDLE handle, HANDLE cancelHandle) - { - // Zero timer events do not need these handles. - if (interval > 0) { - timerHandleToId.insert(handle, id); - timerIdToHandle.insert(id, handle); - timerIdToCancelHandle.insert(id, cancelHandle); - } - - const quint64 targetTime = qt_msectime() + interval; - const WinRTTimerInfo info(id, interval, type, obj, targetTime); - QMutexLocker locker(&timerInfoLock); - if (id >= timerInfos.size()) - timerInfos.resize(id + 1); - timerInfos[id] = info; - timerIdToObject.insert(id, obj); - } - - bool removeTimer(int id) - { - QMutexLocker locker(&timerInfoLock); - if (id >= timerInfos.size()) - return false; - - WinRTTimerInfo &info = timerInfos[id]; - if (info.timerId == INVALID_TIMER_ID) - return false; - - if (info.interval > 0 && (!timerIdToHandle.contains(id) || !timerIdToCancelHandle.contains(id))) - return false; - - info.timerId = INVALID_TIMER_ID; - - // Remove invalid timerinfos from the vector's end, if the timer with the highest id was removed - int lastTimer = timerInfos.size() - 1; - while (lastTimer >= 0 && timerInfos.at(lastTimer).timerId == INVALID_TIMER_ID) - --lastTimer; - if (lastTimer >= 0 && lastTimer != timerInfos.size() - 1) - timerInfos.resize(lastTimer + 1); - timerIdToObject.remove(id); - // ... remove handle from all lists - if (info.interval > 0) { - HANDLE handle = timerIdToHandle.take(id); - timerHandleToId.remove(handle); - SetEvent(timerIdToCancelHandle.take(id)); - } - return true; - } -}; - -QEventDispatcherWinRT::QEventDispatcherWinRT(QObject *parent) - : QAbstractEventDispatcher(*new QEventDispatcherWinRTPrivate, parent) -{ -} - -QEventDispatcherWinRT::QEventDispatcherWinRT(QEventDispatcherWinRTPrivate &dd, QObject *parent) - : QAbstractEventDispatcher(dd, parent) -{ } - -QEventDispatcherWinRT::~QEventDispatcherWinRT() -{ -} - -HRESULT QEventDispatcherWinRT::runOnXamlThread(const std::function &delegate, bool waitForRun) -{ - static __declspec(thread) ICoreDispatcher *dispatcher = nullptr; - HRESULT hr; - if (!dispatcher) { - ComPtr application; - hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(), - IID_PPV_ARGS(&application)); - ComPtr view; - hr = application->get_MainView(&view); - if (SUCCEEDED(hr) && view) { - ComPtr window; - hr = view->get_CoreWindow(&window); - Q_ASSERT_SUCCEEDED(hr); - if (!window) { - // In case the application is launched via activation - // there might not be a main view (eg ShareTarget). - // Hence iterate through the available views and try to find - // a dispatcher in there - ComPtr> appViews; - hr = application->get_Views(&appViews); - Q_ASSERT_SUCCEEDED(hr); - quint32 count; - hr = appViews->get_Size(&count); - Q_ASSERT_SUCCEEDED(hr); - for (quint32 i = 0; i < count; ++i) { - hr = appViews->GetAt(i, &view); - Q_ASSERT_SUCCEEDED(hr); - hr = view->get_CoreWindow(&window); - Q_ASSERT_SUCCEEDED(hr); - if (window) { - hr = window->get_Dispatcher(&dispatcher); - Q_ASSERT_SUCCEEDED(hr); - if (dispatcher) - break; - } - } - } else { - hr = window->get_Dispatcher(&dispatcher); - Q_ASSERT_SUCCEEDED(hr); - } - } - } - - if (Q_UNLIKELY(!dispatcher)) { - // In case the application is launched in a way that has no UI and - // also does not allow to create one, e.g. as a background task. - // Features like network operations do still work, others might cause - // errors in that case. - ComPtr tpStatics; - hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_System_Threading_ThreadPool).Get(), - IID_PPV_ARGS(&tpStatics)); - ComPtr op; - hr = tpStatics.Get()->RunAsync(new QWorkHandler(delegate), &op); - if (FAILED(hr) || !waitForRun) - return hr; - return QWinRTFunctions::await(op); - } - - boolean onXamlThread; - hr = dispatcher->get_HasThreadAccess(&onXamlThread); - Q_ASSERT_SUCCEEDED(hr); - if (onXamlThread) // Already there - return delegate(); - - ComPtr op; - hr = dispatcher->RunAsync(CoreDispatcherPriority_Normal, Make(delegate).Get(), &op); - if (FAILED(hr) || !waitForRun) - return hr; - return QWinRTFunctions::await(op); -} - -HRESULT QEventDispatcherWinRT::runOnMainThread(const std::function &delegate, int timeout) -{ - if (QThread::currentThread() == QCoreApplication::instance()->thread()) - return delegate(); - - struct State { - QSemaphore semaphore; - HRESULT result; - }; - - const auto state = std::make_shared(); - - QMetaObject::invokeMethod(QCoreApplication::instance(), [delegate, state]() { - const QSemaphoreReleaser releaser{state->semaphore}; - state->result = delegate(); - }, nullptr); - - return state->semaphore.tryAcquire(1, timeout) ? state->result : E_FAIL; -} - -bool QEventDispatcherWinRT::processEvents(QEventLoop::ProcessEventsFlags flags) -{ - Q_D(QEventDispatcherWinRT); - - DWORD waitTime = 0; - do { - // Additional user events have to be handled before timer events, but the function may not - // return yet. - const bool userEventsSent = sendPostedEvents(flags); - - const QVector timerHandles = d->timerIdToHandle.values().toVector(); - if (waitTime) - emit aboutToBlock(); - bool timerEventsSent = false; - DWORD waitResult = WaitForMultipleObjectsEx(timerHandles.count(), timerHandles.constData(), FALSE, waitTime, TRUE); - while (waitResult >= WAIT_OBJECT_0 && waitResult < WAIT_OBJECT_0 + timerHandles.count()) { - timerEventsSent = true; - const HANDLE handle = timerHandles.value(waitResult - WAIT_OBJECT_0); - ResetEvent(handle); - const int timerId = d->timerHandleToId.value(handle); - if (timerId == INTERRUPT_HANDLE) - break; - - { - QMutexLocker locker(&d->timerInfoLock); - - WinRTTimerInfo &info = d->timerInfos[timerId]; - Q_ASSERT(info.timerId != INVALID_TIMER_ID); - - QCoreApplication::postEvent(this, new QTimerEvent(timerId)); - - // Update timer's targetTime - const quint64 targetTime = qt_msectime() + info.interval; - info.targetTime = targetTime; - } - waitResult = WaitForMultipleObjectsEx(timerHandles.count(), timerHandles.constData(), FALSE, 0, TRUE); - } - emit awake(); - if (timerEventsSent || userEventsSent) - return true; - - // We cannot wait infinitely like on other platforms, as - // WaitForMultipleObjectsEx might not return. - // For instance win32 uses MsgWaitForMultipleObjects to hook - // into the native event loop, while WinRT handles those - // via callbacks. - waitTime = 1; - } while (flags & QEventLoop::WaitForMoreEvents); - return false; -} - -bool QEventDispatcherWinRT::sendPostedEvents(QEventLoop::ProcessEventsFlags flags) -{ - Q_UNUSED(flags); - if (hasPendingEvents()) { - QCoreApplication::sendPostedEvents(); - return true; - } - return false; -} - -bool QEventDispatcherWinRT::hasPendingEvents() -{ - return qGlobalPostedEventsCount(); -} - -void QEventDispatcherWinRT::registerSocketNotifier(QSocketNotifier *notifier) -{ - Q_UNUSED(notifier); - Q_UNIMPLEMENTED(); -} -void QEventDispatcherWinRT::unregisterSocketNotifier(QSocketNotifier *notifier) -{ - Q_UNUSED(notifier); - Q_UNIMPLEMENTED(); -} - -void QEventDispatcherWinRT::registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object) -{ - Q_UNUSED(timerType); - - if (timerId < 1 || interval < 0 || !object) { -#ifndef QT_NO_DEBUG - qWarning("QEventDispatcherWinRT::registerTimer: invalid arguments"); -#endif - return; - } else if (object->thread() != thread() || thread() != QThread::currentThread()) { -#ifndef QT_NO_DEBUG - qWarning("QEventDispatcherWinRT::registerTimer: timers cannot be started from another thread"); -#endif - return; - } - - Q_D(QEventDispatcherWinRT); - // Don't use timer factory for zero-delay timers - if (interval == 0u) { - d->addTimer(timerId, interval, timerType, object, INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE); - QCoreApplication::postEvent(this, new QTimerEvent(timerId)); - return; - } - - TimeSpan period; - // TimeSpan is based on 100-nanosecond units - period.Duration = qMax(qint64(1), qint64(interval) * 10000); - const HANDLE handle = CreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, SYNCHRONIZE | EVENT_MODIFY_STATE); - const HANDLE cancelHandle = CreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, SYNCHRONIZE|EVENT_MODIFY_STATE); - HRESULT hr = runOnXamlThread([cancelHandle, handle, period]() { - static ComPtr timerFactory; - HRESULT hr; - if (!timerFactory) { - hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_System_Threading_ThreadPoolTimer).Get(), - &timerFactory); - Q_ASSERT_SUCCEEDED(hr); - } - IThreadPoolTimer *timer; - hr = timerFactory->CreatePeriodicTimerWithCompletion( - Callback([handle, cancelHandle](IThreadPoolTimer *timer) { - DWORD cancelResult = WaitForSingleObjectEx(cancelHandle, 0, TRUE); - if (cancelResult == WAIT_OBJECT_0) { - timer->Cancel(); - return S_OK; - } - if (!SetEvent(handle)) { - Q_ASSERT_X(false, "QEventDispatcherWinRT::registerTimer", - "SetEvent should never fail here"); - return S_OK; - } - return S_OK; - }).Get(), period, - Callback([handle, cancelHandle](IThreadPoolTimer *) { - CloseHandle(handle); - CloseHandle(cancelHandle); - return S_OK; - }).Get(), &timer); - RETURN_HR_IF_FAILED("Failed to create periodic timer"); - return hr; - }, false); - if (FAILED(hr)) { - CloseHandle(handle); - CloseHandle(cancelHandle); - return; - } - d->addTimer(timerId, interval, timerType, object, handle, cancelHandle); -} - -bool QEventDispatcherWinRT::unregisterTimer(int timerId) -{ - if (timerId < 1) { -#ifndef QT_NO_DEBUG - qWarning("QEventDispatcherWinRT::unregisterTimer: invalid argument"); -#endif - return false; - } - if (thread() != QThread::currentThread()) { -#ifndef QT_NO_DEBUG - qWarning("QEventDispatcherWinRT::unregisterTimer: timers cannot be stopped from another thread"); -#endif - return false; - } - - // As we post all timer events internally, they have to pe removed to prevent stray events - QCoreApplicationPrivate::removePostedTimerEvent(this, timerId); - Q_D(QEventDispatcherWinRT); - return d->removeTimer(timerId); -} - -bool QEventDispatcherWinRT::unregisterTimers(QObject *object) -{ - if (!object) { -#ifndef QT_NO_DEBUG - qWarning("QEventDispatcherWinRT::unregisterTimers: invalid argument"); -#endif - return false; - } - QThread *currentThread = QThread::currentThread(); - if (object->thread() != thread() || thread() != currentThread) { -#ifndef QT_NO_DEBUG - qWarning("QEventDispatcherWinRT::unregisterTimers: timers cannot be stopped from another thread"); -#endif - return false; - } - - Q_D(QEventDispatcherWinRT); - const auto timerIds = d->timerIdToObject.keys(); // ### FIXME: iterate over hash directly? But unregisterTimer() modifies the hash! - for (int id : timerIds) { - if (d->timerIdToObject.value(id) == object) - unregisterTimer(id); - } - - return true; -} - -QList QEventDispatcherWinRT::registeredTimers(QObject *object) const -{ - if (!object) { -#ifndef QT_NO_DEBUG - qWarning("QEventDispatcherWinRT:registeredTimers: invalid argument"); -#endif - return QList(); - } - - Q_D(const QEventDispatcherWinRT); - QMutexLocker locker(&d->timerInfoLock); - QList timerInfos; - for (const WinRTTimerInfo &info : d->timerInfos) { - if (info.object == object && info.timerId != INVALID_TIMER_ID) - timerInfos.append(info); - } - return timerInfos; -} - -bool QEventDispatcherWinRT::registerEventNotifier(QWinEventNotifier *notifier) -{ - Q_UNUSED(notifier); - Q_UNIMPLEMENTED(); - return false; -} - -void QEventDispatcherWinRT::unregisterEventNotifier(QWinEventNotifier *notifier) -{ - Q_UNUSED(notifier); - Q_UNIMPLEMENTED(); -} - -int QEventDispatcherWinRT::remainingTime(int timerId) -{ - if (timerId < 1) { -#ifndef QT_NO_DEBUG - qWarning("QEventDispatcherWinRT::remainingTime: invalid argument"); -#endif - return -1; - } - - Q_D(QEventDispatcherWinRT); - QMutexLocker locker(&d->timerInfoLock); - const WinRTTimerInfo timerInfo = d->timerInfos.at(timerId); - if (timerInfo.timerId == INVALID_TIMER_ID) { -#ifndef QT_NO_DEBUG - qWarning("QEventDispatcherWinRT::remainingTime: timer id %d not found", timerId); -#endif - return -1; - } - - const quint64 currentTime = qt_msectime(); - if (currentTime < timerInfo.targetTime) { - // time to wait - return timerInfo.targetTime - currentTime; - } else { - return 0; - } - - return -1; -} - -void QEventDispatcherWinRT::wakeUp() -{ -} - -void QEventDispatcherWinRT::interrupt() -{ - Q_D(QEventDispatcherWinRT); - SetEvent(d->timerIdToHandle.value(INTERRUPT_HANDLE)); -} - -void QEventDispatcherWinRT::flush() -{ -} - -void QEventDispatcherWinRT::startingUp() -{ -} - -void QEventDispatcherWinRT::closingDown() -{ -} - -bool QEventDispatcherWinRT::event(QEvent *e) -{ - Q_D(QEventDispatcherWinRT); - switch (e->type()) { - case QEvent::Timer: { - QTimerEvent *timerEvent = static_cast(e); - const int id = timerEvent->timerId(); - - QMutexLocker locker(&d->timerInfoLock); - - Q_ASSERT(id < d->timerInfos.size()); - WinRTTimerInfo &info = d->timerInfos[id]; - Q_ASSERT(info.timerId != INVALID_TIMER_ID); - - if (info.inEvent) // but don't allow event to recurse - break; - info.inEvent = true; - - QObject *timerObj = d->timerIdToObject.value(id); - locker.unlock(); - - QTimerEvent te(id); - QCoreApplication::sendEvent(timerObj, &te); - - locker.relock(); - - // The timer might have been removed in the meanwhile. If the timer was - // the last one in the list, id is bigger than the list's size. - // Otherwise, the id will just be set to INVALID_TIMER_ID. - if (id >= d->timerInfos.size() || info.timerId == INVALID_TIMER_ID) - break; - - if (info.interval == 0 && info.inEvent) { - // post the next zero timer event as long as the timer was not restarted - QCoreApplication::postEvent(this, new QTimerEvent(id)); - } - info.inEvent = false; - } - default: - break; - } - return QAbstractEventDispatcher::event(e); -} - -QEventDispatcherWinRTPrivate::QEventDispatcherWinRTPrivate() -{ - const bool isGuiThread = QCoreApplication::instance() && - QThread::currentThread() == QCoreApplication::instance()->thread(); - CoInitializeEx(NULL, isGuiThread ? COINIT_APARTMENTTHREADED : COINIT_MULTITHREADED); - HANDLE interruptHandle = CreateEventEx(NULL, NULL, NULL, SYNCHRONIZE|EVENT_MODIFY_STATE); - timerIdToHandle.insert(INTERRUPT_HANDLE, interruptHandle); - timerHandleToId.insert(interruptHandle, INTERRUPT_HANDLE); - timerInfos.reserve(256); -} - -QEventDispatcherWinRTPrivate::~QEventDispatcherWinRTPrivate() -{ - CloseHandle(timerIdToHandle.value(INTERRUPT_HANDLE)); - CoUninitialize(); -} - -QT_END_NAMESPACE diff --git a/src/corelib/kernel/qeventdispatcher_winrt_p.h b/src/corelib/kernel/qeventdispatcher_winrt_p.h deleted file mode 100644 index 2672f11123..0000000000 --- a/src/corelib/kernel/qeventdispatcher_winrt_p.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QEVENTDISPATCHER_WINRT_P_H -#define QEVENTDISPATCHER_WINRT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include "QtCore/qabstracteventdispatcher.h" - -#include - -#include - -QT_BEGIN_NAMESPACE - -quint64 qt_msectime(); - -class QEventDispatcherWinRTPrivate; - -class Q_CORE_EXPORT QEventDispatcherWinRT : public QAbstractEventDispatcher -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QEventDispatcherWinRT) - -public: - explicit QEventDispatcherWinRT(QObject *parent = 0); - ~QEventDispatcherWinRT(); - - static HRESULT runOnXamlThread(const std::function &delegate, bool waitForRun = true); - static HRESULT runOnMainThread(const std::function &delegate, int timeout = 100); - - bool processEvents(QEventLoop::ProcessEventsFlags flags); - bool hasPendingEvents(); - - void registerSocketNotifier(QSocketNotifier *notifier); - void unregisterSocketNotifier(QSocketNotifier *notifier); - - void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object); - bool unregisterTimer(int timerId); - bool unregisterTimers(QObject *object); - QList registeredTimers(QObject *object) const; - - int remainingTime(int timerId); - - bool registerEventNotifier(QWinEventNotifier *notifier); - void unregisterEventNotifier(QWinEventNotifier *notifier); - - void wakeUp(); - void interrupt(); - void flush(); - - void startingUp(); - void closingDown(); - -protected: - QEventDispatcherWinRT(QEventDispatcherWinRTPrivate &dd, QObject *parent = 0); - - virtual bool sendPostedEvents(QEventLoop::ProcessEventsFlags flags); - bool event(QEvent *); - int activateTimers(); -}; - -QT_END_NAMESPACE - -#endif // QEVENTDISPATCHER_WINRT_P_H diff --git a/src/corelib/kernel/qfunctions_fake_env_p.h b/src/corelib/kernel/qfunctions_fake_env_p.h deleted file mode 100644 index 68d17ed4a1..0000000000 --- a/src/corelib/kernel/qfunctions_fake_env_p.h +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFUNCTIONS_FAKE_ENV_P_H -#define QFUNCTIONS_FAKE_ENV_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qbytearray.h" -#include "qvector.h" - -QT_BEGIN_NAMESPACE - -// Environment ------------------------------------------------------ -struct Variable { - Variable() { } - - Variable(const QByteArray &name, const QByteArray &value) - : name(name), value(value) { } - - QByteArray name; - QByteArray value; -}; - -Q_DECLARE_TYPEINFO(Variable, Q_MOVABLE_TYPE); - -struct NameEquals { - typedef bool result_type; - const char *name; - explicit NameEquals(const char *name) noexcept : name(name) {} - result_type operator()(const Variable &other) const noexcept - { return qstrcmp(other.name, name) == 0; } -}; - -#ifndef Q_CLANG_QDOC -Q_GLOBAL_STATIC(QVector, qt_app_environment) -#endif - -errno_t qt_fake_getenv_s(size_t *sizeNeeded, char *buffer, size_t bufferSize, const char *varName) -{ - if (!sizeNeeded) - return EINVAL; - - QVector::const_iterator end = qt_app_environment->constEnd(); - QVector::const_iterator iterator = std::find_if(qt_app_environment->constBegin(), - end, - NameEquals(varName)); - if (iterator == end) { - if (buffer) - buffer[0] = '\0'; - return ENOENT; - } - - const int size = iterator->value.size() + 1; - if (bufferSize < size_t(size)) { - *sizeNeeded = size; - return ERANGE; - } - - qstrcpy(buffer, iterator->value.constData()); - return 0; -} - -errno_t qt_fake__putenv_s(const char *varName, const char *value) -{ - QVector::iterator end = qt_app_environment->end(); - QVector::iterator iterator = std::find_if(qt_app_environment->begin(), - end, - NameEquals(varName)); - if (!value || !*value) { - if (iterator != end) - qt_app_environment->erase(iterator); - } else { - if (iterator == end) - qt_app_environment->append(Variable(varName, value)); - else - iterator->value = value; - } - - return 0; -} - -QT_END_NAMESPACE - -#endif // QFUNCTIONS_FAKE_ENV_P_H diff --git a/src/corelib/kernel/qfunctions_p.h b/src/corelib/kernel/qfunctions_p.h index 715c553dc5..6744146aa8 100644 --- a/src/corelib/kernel/qfunctions_p.h +++ b/src/corelib/kernel/qfunctions_p.h @@ -57,8 +57,6 @@ # include "QtCore/qfunctions_vxworks.h" #elif defined(Q_OS_NACL) # include "QtCore/qfunctions_nacl.h" -#elif defined(Q_OS_WINRT) -# include "QtCore/qfunctions_winrt.h" #endif #endif diff --git a/src/corelib/kernel/qfunctions_winrt.cpp b/src/corelib/kernel/qfunctions_winrt.cpp deleted file mode 100644 index 6b7e79806f..0000000000 --- a/src/corelib/kernel/qfunctions_winrt.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qfunctions_winrt.h" - -#ifdef Q_OS_WINRT - -#include "qfunctions_fake_env_p.h" - -QT_BEGIN_NAMESPACE - -void qt_winrt_tzset() -{ -} - -void qt_winrt__tzset() -{ -} - -QT_END_NAMESPACE - -#endif // Q_OS_WINRT diff --git a/src/corelib/kernel/qfunctions_winrt.h b/src/corelib/kernel/qfunctions_winrt.h deleted file mode 100644 index d0c44be683..0000000000 --- a/src/corelib/kernel/qfunctions_winrt.h +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFUNCTIONS_WINRT_H -#define QFUNCTIONS_WINRT_H - -#include - -#ifdef Q_OS_WIN - -#include -#include -#include -#include -#include - -// Convenience macros for handling HRESULT values -#define RETURN_IF_FAILED(msg, ret) \ - if (FAILED(hr)) { \ - qErrnoWarning(hr, msg); \ - ret; \ - } - -#define RETURN_IF_FAILED_WITH_ARGS(msg, ret, ...) \ - if (FAILED(hr)) { \ - qErrnoWarning(hr, msg, __VA_ARGS__); \ - ret; \ - } - -#define RETURN_HR_IF_FAILED(msg) RETURN_IF_FAILED(msg, return hr) -#define RETURN_OK_IF_FAILED(msg) RETURN_IF_FAILED(msg, return S_OK) -#define RETURN_FALSE_IF_FAILED(msg) RETURN_IF_FAILED(msg, return false) -#define RETURN_VOID_IF_FAILED(msg) RETURN_IF_FAILED(msg, return) -#define RETURN_HR_IF_FAILED_WITH_ARGS(msg, ...) RETURN_IF_FAILED_WITH_ARGS(msg, return hr, __VA_ARGS__) -#define RETURN_OK_IF_FAILED_WITH_ARGS(msg, ...) RETURN_IF_FAILED_WITH_ARGS(msg, return S_OK, __VA_ARGS__) -#define RETURN_FALSE_IF_FAILED_WITH_ARGS(msg, ...) RETURN_IF_FAILED_WITH_ARGS(msg, return false, __VA_ARGS__) -#define RETURN_VOID_IF_FAILED_WITH_ARGS(msg, ...) RETURN_IF_FAILED_WITH_ARGS(msg, return, __VA_ARGS__) - -#define Q_ASSERT_SUCCEEDED(hr) \ - Q_ASSERT_X(SUCCEEDED(hr), Q_FUNC_INFO, qPrintable(qt_error_string(hr))); - -#ifdef Q_OS_WINRT - -QT_BEGIN_NAMESPACE - -#ifdef QT_BUILD_CORE_LIB -#endif - -// Environment ------------------------------------------------------ -errno_t qt_fake_getenv_s(size_t*, char*, size_t, const char*); -errno_t qt_fake__putenv_s(const char*, const char*); -void qt_winrt_tzset(); -void qt_winrt__tzset(); - -QT_END_NAMESPACE - -// As Windows Runtime lacks some standard functions used in Qt, these got -// reimplemented. Other projects do this as well. Inline functions are used -// that there is a central place to disable functions for newer versions if -// they get available. There are no defines used anymore, because this -// will break member functions of classes which are called like these -// functions. -// The other declarations available in this file are being used per -// define inside qplatformdefs.h of the corresponding WinRT mkspec. - -#define generate_inline_return_func0(funcname, returntype) \ - inline returntype funcname() \ - { \ - return QT_PREPEND_NAMESPACE(qt_winrt_##funcname)(); \ - } -#define generate_inline_return_func1(funcname, returntype, param1) \ - inline returntype funcname(param1 p1) \ - { \ - return QT_PREPEND_NAMESPACE(qt_winrt_##funcname)(p1); \ - } -#define generate_inline_return_func2(funcname, returntype, prependnamespace, param1, param2) \ - inline returntype funcname(param1 p1, param2 p2) \ - { \ - return QT_PREPEND_NAMESPACE(prependnamespace##funcname)(p1, p2); \ - } -#define generate_inline_return_func3(funcname, returntype, param1, param2, param3) \ - inline returntype funcname(param1 p1, param2 p2, param3 p3) \ - { \ - return QT_PREPEND_NAMESPACE(qt_winrt_##funcname)(p1, p2, p3); \ - } -#define generate_inline_return_func4(funcname, returntype, prependnamespace, param1, param2, param3, param4) \ - inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4) \ - { \ - return QT_PREPEND_NAMESPACE(prependnamespace##funcname)(p1, p2, p3, p4); \ - } -#define generate_inline_return_func5(funcname, returntype, param1, param2, param3, param4, param5) \ - inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \ - { \ - return QT_PREPEND_NAMESPACE(qt_winrt_##funcname)(p1, p2, p3, p4, p5); \ - } -#define generate_inline_return_func6(funcname, returntype, param1, param2, param3, param4, param5, param6) \ - inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \ - { \ - return QT_PREPEND_NAMESPACE(qt_winrt_##funcname)(p1, p2, p3, p4, p5, p6); \ - } -#define generate_inline_return_func7(funcname, returntype, param1, param2, param3, param4, param5, param6, param7) \ - inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6, param7 p7) \ - { \ - return QT_PREPEND_NAMESPACE(qt_winrt_##funcname)(p1, p2, p3, p4, p5, p6, p7); \ - } - -typedef unsigned (__stdcall *StartAdressExFunc)(void *); -typedef void(*StartAdressFunc)(void *); -typedef int ( __cdecl *CompareFunc ) (const void *, const void *) ; - -generate_inline_return_func4(getenv_s, errno_t, qt_fake_, size_t *, char *, size_t, const char *) -generate_inline_return_func2(_putenv_s, errno_t, qt_fake_, const char *, const char *) -generate_inline_return_func0(tzset, void) -generate_inline_return_func0(_tzset, void) - -namespace Microsoft { - namespace WRL { - template class ComPtr; - } -} - -QT_BEGIN_NAMESPACE - -namespace QWinRTFunctions { - -// Synchronization methods -enum AwaitStyle -{ - YieldThread = 0, - ProcessThreadEvents = 1, - ProcessMainThreadEvents = 2 -}; - -template -static inline HRESULT _await_impl(const Microsoft::WRL::ComPtr &asyncOp, AwaitStyle awaitStyle, uint timeout) -{ - Microsoft::WRL::ComPtr asyncInfo; - HRESULT hr = asyncOp.As(&asyncInfo); - if (FAILED(hr)) - return hr; - - AsyncStatus status; - QElapsedTimer t; - if (timeout) - t.start(); - switch (awaitStyle) { - case ProcessMainThreadEvents: - while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == AsyncStatus::Started) { - QCoreApplication::processEvents(); - if (timeout && t.hasExpired(timeout)) - return ERROR_TIMEOUT; - } - break; - case ProcessThreadEvents: - if (QAbstractEventDispatcher *dispatcher = QThread::currentThread()->eventDispatcher()) { - while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == AsyncStatus::Started) { - dispatcher->processEvents(QEventLoop::AllEvents); - if (timeout && t.hasExpired(timeout)) - return ERROR_TIMEOUT; - } - break; - } - // fall through - default: - case YieldThread: - while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == AsyncStatus::Started) { - QThread::yieldCurrentThread(); - if (timeout && t.hasExpired(timeout)) - return ERROR_TIMEOUT; - } - break; - } - - if (FAILED(hr) || status != AsyncStatus::Completed) { - HRESULT ec; - hr = asyncInfo->get_ErrorCode(&ec); - if (FAILED(hr)) - return hr; - hr = asyncInfo->Close(); - if (FAILED(hr)) - return hr; - return ec; - } - - return hr; -} - -template -static inline HRESULT await(const Microsoft::WRL::ComPtr &asyncOp, AwaitStyle awaitStyle = YieldThread, uint timeout = 0) -{ - HRESULT hr = _await_impl(asyncOp, awaitStyle, timeout); - if (FAILED(hr)) - return hr; - - return asyncOp->GetResults(); -} - -template -static inline HRESULT await(const Microsoft::WRL::ComPtr &asyncOp, U *results, AwaitStyle awaitStyle = YieldThread, uint timeout = 0) -{ - HRESULT hr = _await_impl(asyncOp, awaitStyle, timeout); - if (FAILED(hr)) - return hr; - - return asyncOp->GetResults(results); -} - -} // QWinRTFunctions - -QT_END_NAMESPACE - -#endif // Q_OS_WINRT - -#endif // Q_OS_WIN - -#endif // QFUNCTIONS_WINRT_H diff --git a/src/corelib/kernel/qfunctions_winrt_p.h b/src/corelib/kernel/qfunctions_winrt_p.h new file mode 100644 index 0000000000..aa32747bc8 --- /dev/null +++ b/src/corelib/kernel/qfunctions_winrt_p.h @@ -0,0 +1,184 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFUNCTIONS_WINRT_P_H +#define QFUNCTIONS_WINRT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#if defined(Q_OS_WIN) && defined(Q_CC_MSVC) + +#include +#include +#include +#include +#include + +#include +#include + +// Convenience macros for handling HRESULT values +#define RETURN_IF_FAILED(msg, ret) \ + if (FAILED(hr)) { \ + qErrnoWarning(hr, msg); \ + ret; \ + } + +#define RETURN_IF_FAILED_WITH_ARGS(msg, ret, ...) \ + if (FAILED(hr)) { \ + qErrnoWarning(hr, msg, __VA_ARGS__); \ + ret; \ + } + +#define RETURN_HR_IF_FAILED(msg) RETURN_IF_FAILED(msg, return hr) +#define RETURN_OK_IF_FAILED(msg) RETURN_IF_FAILED(msg, return S_OK) +#define RETURN_FALSE_IF_FAILED(msg) RETURN_IF_FAILED(msg, return false) +#define RETURN_VOID_IF_FAILED(msg) RETURN_IF_FAILED(msg, return) +#define RETURN_HR_IF_FAILED_WITH_ARGS(msg, ...) RETURN_IF_FAILED_WITH_ARGS(msg, return hr, __VA_ARGS__) +#define RETURN_OK_IF_FAILED_WITH_ARGS(msg, ...) RETURN_IF_FAILED_WITH_ARGS(msg, return S_OK, __VA_ARGS__) +#define RETURN_FALSE_IF_FAILED_WITH_ARGS(msg, ...) RETURN_IF_FAILED_WITH_ARGS(msg, return false, __VA_ARGS__) +#define RETURN_VOID_IF_FAILED_WITH_ARGS(msg, ...) RETURN_IF_FAILED_WITH_ARGS(msg, return, __VA_ARGS__) + +#define Q_ASSERT_SUCCEEDED(hr) \ + Q_ASSERT_X(SUCCEEDED(hr), Q_FUNC_INFO, qPrintable(qt_error_string(hr))); + +QT_BEGIN_NAMESPACE + +namespace QWinRTFunctions { + +// Synchronization methods +enum AwaitStyle +{ + YieldThread = 0, + ProcessThreadEvents = 1, + ProcessMainThreadEvents = 2 +}; + +template +static inline HRESULT _await_impl(const Microsoft::WRL::ComPtr &asyncOp, AwaitStyle awaitStyle, uint timeout) +{ + Microsoft::WRL::ComPtr asyncInfo; + HRESULT hr = asyncOp.As(&asyncInfo); + if (FAILED(hr)) + return hr; + + AsyncStatus status; + QElapsedTimer t; + if (timeout) + t.start(); + switch (awaitStyle) { + case ProcessMainThreadEvents: + while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == AsyncStatus::Started) { + QCoreApplication::processEvents(); + if (timeout && t.hasExpired(timeout)) + return ERROR_TIMEOUT; + } + break; + case ProcessThreadEvents: + if (QAbstractEventDispatcher *dispatcher = QThread::currentThread()->eventDispatcher()) { + while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == AsyncStatus::Started) { + dispatcher->processEvents(QEventLoop::AllEvents); + if (timeout && t.hasExpired(timeout)) + return ERROR_TIMEOUT; + } + break; + } + // fall through + default: + case YieldThread: + while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == AsyncStatus::Started) { + QThread::yieldCurrentThread(); + if (timeout && t.hasExpired(timeout)) + return ERROR_TIMEOUT; + } + break; + } + + if (FAILED(hr) || status != AsyncStatus::Completed) { + HRESULT ec; + hr = asyncInfo->get_ErrorCode(&ec); + if (FAILED(hr)) + return hr; + hr = asyncInfo->Close(); + if (FAILED(hr)) + return hr; + return ec; + } + + return hr; +} + +template +static inline HRESULT await(const Microsoft::WRL::ComPtr &asyncOp, AwaitStyle awaitStyle = YieldThread, uint timeout = 0) +{ + HRESULT hr = _await_impl(asyncOp, awaitStyle, timeout); + if (FAILED(hr)) + return hr; + + return asyncOp->GetResults(); +} + +template +static inline HRESULT await(const Microsoft::WRL::ComPtr &asyncOp, U *results, AwaitStyle awaitStyle = YieldThread, uint timeout = 0) +{ + HRESULT hr = _await_impl(asyncOp, awaitStyle, timeout); + if (FAILED(hr)) + return hr; + + return asyncOp->GetResults(results); +} + +} // QWinRTFunctions + +QT_END_NAMESPACE + +#endif // Q_OS_WIN && Q_CC_MSVC + +#endif // QFUNCTIONS_WINRT_P_H diff --git a/src/corelib/kernel/qsharedmemory_win.cpp b/src/corelib/kernel/qsharedmemory_win.cpp index 02de2339a5..cbf31bcb2f 100644 --- a/src/corelib/kernel/qsharedmemory_win.cpp +++ b/src/corelib/kernel/qsharedmemory_win.cpp @@ -101,12 +101,8 @@ HANDLE QSharedMemoryPrivate::handle() errorString = QSharedMemory::tr("%1: unable to make key").arg(function); return 0; } -#if defined(Q_OS_WINRT) - hand = OpenFileMappingFromApp(FILE_MAP_ALL_ACCESS, FALSE, reinterpret_cast(nativeKey.utf16())); -#else hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, reinterpret_cast(nativeKey.utf16())); -#endif if (!hand) { setErrorString(function); return 0; @@ -136,13 +132,8 @@ bool QSharedMemoryPrivate::create(int size) } // Create the file mapping. -#if defined(Q_OS_WINRT) - hand = CreateFileMappingFromApp(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, size, - reinterpret_cast(nativeKey.utf16())); -#else hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size, reinterpret_cast(nativeKey.utf16())); -#endif setErrorString(function); // hand is valid when it already exists unlike unix so explicitly check @@ -153,11 +144,7 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode) { // Grab a pointer to the memory block int permissions = (mode == QSharedMemory::ReadOnly ? FILE_MAP_READ : FILE_MAP_ALL_ACCESS); -#if defined(Q_OS_WINRT) - memory = (void *)MapViewOfFileFromApp(handle(), permissions, 0, 0); -#else memory = (void *)MapViewOfFile(handle(), permissions, 0, 0, 0); -#endif if (0 == memory) { setErrorString(QLatin1String("QSharedMemory::attach")); cleanHandle(); diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp index a735e12925..6a250f5f3a 100644 --- a/src/corelib/kernel/qsystemerror.cpp +++ b/src/corelib/kernel/qsystemerror.cpp @@ -76,7 +76,6 @@ namespace { static QString windowsErrorString(int errorCode) { QString ret; -#ifndef Q_OS_WINRT wchar_t *string = 0; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, NULL, @@ -87,17 +86,6 @@ static QString windowsErrorString(int errorCode) NULL); ret = QString::fromWCharArray(string); LocalFree((HLOCAL)string); -#else - wchar_t errorString[1024]; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - errorCode, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPWSTR)&errorString, - sizeof(errorString)/sizeof(wchar_t), - NULL); - ret = QString::fromWCharArray(errorString); -#endif // Q_OS_WINRT if (ret.isEmpty() && errorCode == ERROR_MOD_NOT_FOUND) ret = QString::fromLatin1("The specified module could not be found."); diff --git a/src/corelib/kernel/qsystemsemaphore_win.cpp b/src/corelib/kernel/qsystemsemaphore_win.cpp index 2b35803291..d19476db4a 100644 --- a/src/corelib/kernel/qsystemsemaphore_win.cpp +++ b/src/corelib/kernel/qsystemsemaphore_win.cpp @@ -85,14 +85,8 @@ HANDLE QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode) // Create it if it doesn't already exists. if (semaphore == 0) { -#if defined(Q_OS_WINRT) - semaphore = CreateSemaphoreEx(0, initialValue, MAXLONG, - reinterpret_cast(fileName.utf16()), - 0, SEMAPHORE_ALL_ACCESS); -#else semaphore = CreateSemaphore(0, initialValue, MAXLONG, reinterpret_cast(fileName.utf16())); -#endif if (semaphore == NULL) setErrorString(QLatin1String("QSystemSemaphore::handle")); } diff --git a/src/corelib/kernel/qtestsupport_core.cpp b/src/corelib/kernel/qtestsupport_core.cpp index 428ebbd652..928c8021bc 100644 --- a/src/corelib/kernel/qtestsupport_core.cpp +++ b/src/corelib/kernel/qtestsupport_core.cpp @@ -49,9 +49,7 @@ Q_CORE_EXPORT void QTestPrivate::qSleep(int ms) { Q_ASSERT(ms > 0); -#if defined(Q_OS_WINRT) - WaitForSingleObjectEx(GetCurrentThread(), ms, true); -#elif defined(Q_OS_WIN) +#if defined(Q_OS_WIN) Sleep(uint(ms)); #else struct timespec ts = { time_t(ms / 1000), (ms % 1000) * 1000 * 1000 }; diff --git a/src/corelib/kernel/qwineventnotifier.cpp b/src/corelib/kernel/qwineventnotifier.cpp index 0c574e9a4b..b306e3aba1 100644 --- a/src/corelib/kernel/qwineventnotifier.cpp +++ b/src/corelib/kernel/qwineventnotifier.cpp @@ -39,11 +39,7 @@ #include "qwineventnotifier_p.h" -#ifdef Q_OS_WINRT -#include "qeventdispatcher_winrt_p.h" -#else #include "qeventdispatcher_win_p.h" -#endif #include "qcoreapplication.h" #include @@ -235,21 +231,6 @@ bool QWinEventNotifier::event(QEvent * e) return false; } -#if defined(Q_OS_WINRT) - -bool QWinEventNotifierPrivate::registerWaitObject() -{ - Q_UNIMPLEMENTED(); - return false; -} - -void QWinEventNotifierPrivate::unregisterWaitObject() -{ - Q_UNIMPLEMENTED(); -} - -#else // defined(Q_OS_WINRT) - static void CALLBACK wfsoCallback(void *context, BOOLEAN /*ignore*/) { QWinEventNotifierPrivate *nd = reinterpret_cast(context); @@ -287,6 +268,4 @@ void QWinEventNotifierPrivate::unregisterWaitObject() qErrnoWarning("QWinEventNotifier: UnregisterWaitEx failed."); } -#endif // !defined(Q_OS_WINRT) - QT_END_NAMESPACE diff --git a/src/corelib/plugin/qlibrary_win.cpp b/src/corelib/plugin/qlibrary_win.cpp index ef58724be8..ef1b389adc 100644 --- a/src/corelib/plugin/qlibrary_win.cpp +++ b/src/corelib/plugin/qlibrary_win.cpp @@ -63,10 +63,8 @@ QStringList QLibraryPrivate::prefixes_sys() bool QLibraryPrivate::load_sys() { -#ifndef Q_OS_WINRT //avoid 'Bad Image' message box UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); -#endif // We make the following attempts at locating the library: // // Windows @@ -91,22 +89,11 @@ bool QLibraryPrivate::load_sys() attempts.prepend(fileName); else attempts.append(fileName); -#ifdef Q_OS_WINRT - if (fileName.startsWith(QLatin1Char('/'))) - attempts.prepend(QDir::rootPath() + fileName); -#endif locker.unlock(); Handle hnd = nullptr; for (const QString &attempt : qAsConst(attempts)) { -#ifndef Q_OS_WINRT hnd = LoadLibrary(reinterpret_cast(QDir::toNativeSeparators(attempt).utf16())); -#else // Q_OS_WINRT - QString path = QDir::toNativeSeparators(QDir::current().relativeFilePath(attempt)); - hnd = LoadPackagedLibrary(reinterpret_cast(path.utf16()), 0); - if (hnd) - qualifiedFileName = attempt; -#endif // !Q_OS_WINRT // If we have a handle or the last error is something other than "unable // to find the module", then bail out @@ -114,9 +101,7 @@ bool QLibraryPrivate::load_sys() break; } -#ifndef Q_OS_WINRT SetErrorMode(oldmode); -#endif locker.relock(); if (!hnd) { errorString = QLibrary::tr("Cannot load library %1: %2").arg( @@ -125,7 +110,6 @@ bool QLibraryPrivate::load_sys() // Query the actual name of the library that was loaded errorString.clear(); -#ifndef Q_OS_WINRT wchar_t buffer[MAX_PATH]; ::GetModuleFileName(hnd, buffer, MAX_PATH); @@ -147,7 +131,6 @@ bool QLibraryPrivate::load_sys() Q_ASSERT(!ok || hmod == hnd); Q_UNUSED(ok); } -#endif // !Q_OS_WINRT } pHnd.storeRelaxed(hnd); return (pHnd != nullptr); diff --git a/src/corelib/plugin/qsystemlibrary.cpp b/src/corelib/plugin/qsystemlibrary.cpp index 1a88476596..fe6760c8d8 100644 --- a/src/corelib/plugin/qsystemlibrary.cpp +++ b/src/corelib/plugin/qsystemlibrary.cpp @@ -72,14 +72,6 @@ QT_BEGIN_NAMESPACE -#if defined(Q_OS_WINRT) -HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirectory /* = true */) -{ - Q_UNUSED(onlySystemDirectory); - return ::LoadPackagedLibrary(libraryName, 0); -} -#else - #if !defined(QT_BOOTSTRAPPED) extern QString qAppFileName(); #endif @@ -129,6 +121,4 @@ HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirect } -#endif // Q_OS_WINRT - QT_END_NAMESPACE diff --git a/src/corelib/text/qcollator_p.h b/src/corelib/text/qcollator_p.h index 444ae06a99..304c7135e1 100644 --- a/src/corelib/text/qcollator_p.h +++ b/src/corelib/text/qcollator_p.h @@ -79,9 +79,6 @@ const CollatorType NoCollator = 0; typedef QString CollatorKeyType; typedef int CollatorType; const CollatorType NoCollator = 0; -# ifdef Q_OS_WINRT -# define USE_COMPARESTRINGEX -# endif #else // posix - ignores CollatorType collator, only handles system locale typedef QVector CollatorKeyType; diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp index a6582236d5..9af37cb8d0 100644 --- a/src/corelib/text/qlocale_win.cpp +++ b/src/corelib/text/qlocale_win.cpp @@ -51,32 +51,11 @@ # include #endif -#ifdef Q_OS_WINRT -#include - -#include -#include -#include -#include -#endif // Q_OS_WINRT - QT_BEGIN_NAMESPACE -#ifndef Q_OS_WINRT static QByteArray getWinLocaleName(LCID id = LOCALE_USER_DEFAULT); static QString winIso639LangName(LCID id = LOCALE_USER_DEFAULT); static QString winIso3116CtryName(LCID id = LOCALE_USER_DEFAULT); -#else // !Q_OS_WINRT -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -using namespace ABI::Windows::Foundation; -using namespace ABI::Windows::System::UserProfile; - -static QByteArray getWinLocaleName(LPWSTR id = LOCALE_NAME_USER_DEFAULT); -static const char *winLangCodeToIsoName(int code); -static QString winIso639LangName(LPWSTR id = LOCALE_NAME_USER_DEFAULT); -static QString winIso3116CtryName(LPWSTR id = LOCALE_NAME_USER_DEFAULT); -#endif // Q_OS_WINRT #ifndef QT_NO_SYSTEMLOCALE @@ -141,11 +120,7 @@ private: }; // cached values: -#ifndef Q_OS_WINRT LCID lcid; -#else - WCHAR lcName[LOCALE_NAME_MAX_LENGTH]; -#endif SubstitutionType substitutionType; QString zero; // cached value for zeroDigit() @@ -170,47 +145,27 @@ Q_GLOBAL_STATIC(QSystemLocalePrivate, systemLocalePrivate) QSystemLocalePrivate::QSystemLocalePrivate() : substitutionType(SUnknown) { -#ifndef Q_OS_WINRT lcid = GetUserDefaultLCID(); -#else - GetUserDefaultLocaleName(lcName, LOCALE_NAME_MAX_LENGTH); -#endif } inline int QSystemLocalePrivate::getCurrencyFormat(DWORD flags, LPCWSTR value, const CURRENCYFMTW *format, LPWSTR data, int size) { -#ifndef Q_OS_WINRT return GetCurrencyFormat(lcid, flags, value, format, data, size); -#else - return GetCurrencyFormatEx(lcName, flags, value, format, data, size); -#endif } inline int QSystemLocalePrivate::getDateFormat(DWORD flags, const SYSTEMTIME * date, LPCWSTR format, LPWSTR data, int size) { -#ifndef Q_OS_WINRT return GetDateFormat(lcid, flags, date, format, data, size); -#else - return GetDateFormatEx(lcName, flags, date, format, data, size, NULL); -#endif } inline int QSystemLocalePrivate::getTimeFormat(DWORD flags, const SYSTEMTIME *date, LPCWSTR format, LPWSTR data, int size) { -#ifndef Q_OS_WINRT return GetTimeFormat(lcid, flags, date, format, data, size); -#else - return GetTimeFormatEx(lcName, flags, date, format, data, size); -#endif } inline int QSystemLocalePrivate::getLocaleInfo(LCTYPE type, LPWSTR data, int size) { -#ifndef Q_OS_WINRT return GetLocaleInfo(lcid, type, data, size); -#else - return GetLocaleInfoEx(lcName, type, data, size); -#endif } template @@ -646,7 +601,6 @@ QVariant QSystemLocalePrivate::toCurrencyString(const QSystemLocale::CurrencyToS QVariant QSystemLocalePrivate::uiLanguages() { -#ifndef Q_OS_WINRT unsigned long cnt = 0; QVarLengthArray buf(64); # if !defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE) // Not present in MinGW 4.9/bootstrap builds. @@ -672,35 +626,6 @@ QVariant QSystemLocalePrivate::uiLanguages() str += s.size() + 1; } return result; -#else // !Q_OS_WINRT - QStringList result; - - ComPtr preferences; - HRESULT hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_System_UserProfile_GlobalizationPreferences).Get(), &preferences); - if (FAILED(hr)) { - qWarning("Could not obtain ApplicationLanguagesStatic"); - return QStringList(); - } - - ComPtr > languageList; - // Languages is a ranked list of "long names" (e.g. en-US) of preferred languages - hr = preferences->get_Languages(&languageList); - Q_ASSERT_SUCCEEDED(hr); - unsigned int size; - hr = languageList->get_Size(&size); - Q_ASSERT_SUCCEEDED(hr); - result.reserve(size); - for (unsigned int i = 0; i < size; ++i) { - HString language; - hr = languageList->GetAt(i, language.GetAddressOf()); - Q_ASSERT_SUCCEEDED(hr); - UINT32 length; - PCWSTR rawString = language.GetRawBuffer(&length); - result << QString::fromWCharArray(rawString, length); - } - - return result; -#endif // Q_OS_WINRT } QVariant QSystemLocalePrivate::nativeLanguageName() @@ -716,11 +641,7 @@ QVariant QSystemLocalePrivate::nativeCountryName() void QSystemLocalePrivate::update() { -#ifndef Q_OS_WINRT lcid = GetUserDefaultLCID(); -#else - GetUserDefaultLocaleName(lcName, LOCALE_NAME_MAX_LENGTH); -#endif substitutionType = SUnknown; zero.resize(0); } @@ -1061,11 +982,7 @@ LCID qt_inIsoNametoLCID(const char *name) } -#ifndef Q_OS_WINRT static QString winIso639LangName(LCID id) -#else -static QString winIso639LangName(LPWSTR id) -#endif { QString result; @@ -1073,11 +990,7 @@ static QString winIso639LangName(LPWSTR id) // the language code QString lang_code; wchar_t out[256]; -#ifndef Q_OS_WINRT if (GetLocaleInfo(id, LOCALE_ILANGUAGE, out, 255)) -#else - if (GetLocaleInfoEx(id, LOCALE_ILANGUAGE, out, 255)) -#endif lang_code = QString::fromWCharArray(out); if (!lang_code.isEmpty()) { @@ -1100,47 +1013,27 @@ static QString winIso639LangName(LPWSTR id) return result; // not one of the problematic languages - do the usual lookup -#ifndef Q_OS_WINRT if (GetLocaleInfo(id, LOCALE_SISO639LANGNAME, out, 255)) -#else - if (GetLocaleInfoEx(id, LOCALE_SISO639LANGNAME, out, 255)) -#endif result = QString::fromWCharArray(out); return result; } -#ifndef Q_OS_WINRT static QString winIso3116CtryName(LCID id) -#else -static QString winIso3116CtryName(LPWSTR id) -#endif { QString result; wchar_t out[256]; -#ifndef Q_OS_WINRT if (GetLocaleInfo(id, LOCALE_SISO3166CTRYNAME, out, 255)) -#else - if (GetLocaleInfoEx(id, LOCALE_SISO3166CTRYNAME, out, 255)) -#endif result = QString::fromWCharArray(out); return result; } -#ifndef Q_OS_WINRT static QByteArray getWinLocaleName(LCID id) -#else -static QByteArray getWinLocaleName(LPWSTR id) -#endif { QByteArray result; -#ifndef Q_OS_WINRT if (id == LOCALE_USER_DEFAULT) { -#else - if (QString::fromWCharArray(id) == QString::fromWCharArray(LOCALE_NAME_USER_DEFAULT)) { -#endif static QByteArray langEnvVar = qgetenv("LANG"); result = langEnvVar; QString lang, script, cntry; @@ -1155,16 +1048,8 @@ static QByteArray getWinLocaleName(LPWSTR id) } } -#ifndef Q_OS_WINRT if (id == LOCALE_USER_DEFAULT) id = GetUserDefaultLCID(); -#else // !Q_OS_WINRT - WCHAR lcName[LOCALE_NAME_MAX_LENGTH]; - if (QString::fromWCharArray(id) == QString::fromWCharArray(LOCALE_NAME_USER_DEFAULT)) { - GetUserDefaultLocaleName(lcName, LOCALE_NAME_MAX_LENGTH); - id = lcName; - } -#endif // Q_OS_WINRT QString resultusage = winIso639LangName(id); QString country = winIso3116CtryName(id); if (!country.isEmpty()) @@ -1175,13 +1060,7 @@ static QByteArray getWinLocaleName(LPWSTR id) Q_CORE_EXPORT QLocale qt_localeFromLCID(LCID id) { -#ifndef Q_OS_WINRT return QLocale(QString::fromLatin1(getWinLocaleName(id))); -#else // !Q_OS_WINRT - WCHAR name[LOCALE_NAME_MAX_LENGTH]; - LCIDToLocaleName(id, name, LOCALE_NAME_MAX_LENGTH, 0); - return QLocale(QString::fromLatin1(getWinLocaleName(name))); -#endif // Q_OS_WINRT } QT_END_NAMESPACE diff --git a/src/corelib/text/qstringconverter.cpp b/src/corelib/text/qstringconverter.cpp index 43ebde6449..d1b3055bd4 100644 --- a/src/corelib/text/qstringconverter.cpp +++ b/src/corelib/text/qstringconverter.cpp @@ -1115,7 +1115,6 @@ static QString convertToUnicodeCharByChar(const char *chars, qsizetype length, Q state->remainingChars = 0; } const char *mb = mbcs; -#if !defined(Q_OS_WINRT) const char *next = 0; QString s; while ((next = CharNextExA(CP_ACP, mb, 0)) != mb) { @@ -1134,21 +1133,6 @@ static QString convertToUnicodeCharByChar(const char *chars, qsizetype length, Q } mb = next; } -#else - QString s; - size_t size = mbstowcs(NULL, mb, length); - if (size == size_t(-1)) { - Q_ASSERT("Error in CE TextCodec"); - return QString(); - } - wchar_t* ws = new wchar_t[size + 2]; - ws[size +1] = 0; - ws[size] = 0; - size = mbstowcs(ws, mb, length); - for (size_t i = 0; i < size; i++) - s.append(QChar(ws[i])); - delete [] ws; -#endif delete [] mbcs; return s; } diff --git a/src/corelib/thread/qmutex_win.cpp b/src/corelib/thread/qmutex_win.cpp index e221bc89cb..73673cd5fb 100644 --- a/src/corelib/thread/qmutex_win.cpp +++ b/src/corelib/thread/qmutex_win.cpp @@ -46,11 +46,7 @@ QT_BEGIN_NAMESPACE QMutexPrivate::QMutexPrivate() { -#ifndef Q_OS_WINRT event = CreateEvent(0, FALSE, FALSE, 0); -#else - event = CreateEventEx(0, NULL, 0, EVENT_ALL_ACCESS); -#endif if (!event) qWarning("QMutexData::QMutexData: Cannot create event"); diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index d575253408..36e9b2a7a2 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -184,9 +184,7 @@ QThreadPrivate::QThreadPrivate(QThreadData *d) #if defined (Q_OS_WIN) handle = 0; -# ifndef Q_OS_WINRT id = 0; -# endif waiters = 0; terminationEnabled = true; terminatePending = false; diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index b2d1628e6e..9255b05104 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -67,16 +67,6 @@ #include #include -#ifdef Q_OS_WINRT -namespace ABI { - namespace Windows { - namespace Foundation { - struct IAsyncAction; - } - } -} -#endif // Q_OS_WINRT - QT_BEGIN_NAMESPACE class QAbstractEventDispatcher; @@ -246,9 +236,6 @@ public: ~QThreadData(); static Q_AUTOTEST_EXPORT QThreadData *current(bool createIfNecessary = true); -#ifdef Q_OS_WINRT - static void setMainThread(); -#endif static void clearCurrentThreadData(); static QThreadData *get2(QThread *thread) { Q_ASSERT_X(thread != nullptr, "QThread", "internal error"); return thread->d_func()->data; } diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index 00d67b3a00..78c4d8d672 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -46,49 +46,19 @@ #include #include -#ifndef Q_OS_WINRT #include -#else -#include -#endif #include -#ifndef Q_OS_WINRT -# ifndef _MT -# define _MT -# endif // _MT -# include -#endif // Q_OS_WINRT +#ifndef _MT +# define _MT +#endif // _MT +#include QT_BEGIN_NAMESPACE #if QT_CONFIG(thread) -#ifdef Q_OS_WINRT -inline DWORD qWinRTTlsAlloc() { - return FlsAlloc(0); -} - -inline bool qWinRTTlsFree(DWORD dwTlsIndex) { - return FlsFree(dwTlsIndex); -} - -inline LPVOID qWinRTTlsGetValue(DWORD dwTlsIndex) { - return FlsGetValue(dwTlsIndex); -} - -inline bool qWinRTTlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue) { - return FlsSetValue(dwTlsIndex, lpTlsValue); -} - -#define TlsAlloc qWinRTTlsAlloc -#define TlsFree qWinRTTlsFree -#define TlsSetValue qWinRTTlsSetValue -#define TlsGetValue qWinRTTlsGetValue - -#endif // Q_OS_WINRT - void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread); DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID); @@ -142,15 +112,9 @@ QThreadData *QThreadData::current(bool createIfNecessary) threadData->isAdopted = true; threadData->threadId.storeRelaxed(reinterpret_cast(quintptr(GetCurrentThreadId()))); -#ifndef Q_OS_WINRT if (!QCoreApplicationPrivate::theMainThread) { QCoreApplicationPrivate::theMainThread = threadData->thread.loadRelaxed(); } else { -#else - // for winrt the main thread is set explicitly in QCoreApplication's constructor as the - // native main thread (Xaml thread) is not Qt's main thread. - { -#endif HANDLE realHandle = INVALID_HANDLE_VALUE; DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), @@ -165,33 +129,6 @@ QThreadData *QThreadData::current(bool createIfNecessary) return threadData; } -#ifdef Q_OS_WINRT -void QThreadData::setMainThread() -{ - Q_ASSERT(!QCoreApplicationPrivate::theMainThread); - qt_create_tls(); - QThreadData *threadData = reinterpret_cast(TlsGetValue(qt_current_thread_data_tls_index)); - if (!threadData) { - threadData = new QThreadData; - // This needs to be called prior to new AdoptedThread() to - // avoid recursion. - TlsSetValue(qt_current_thread_data_tls_index, threadData); - QT_TRY { - threadData->thread = new QAdoptedThread(threadData); - } QT_CATCH(...) { - TlsSetValue(qt_current_thread_data_tls_index, 0); - threadData->deref(); - threadData = 0; - QT_RETHROW; - } - threadData->deref(); - threadData->isAdopted = true; - threadData->threadId.storeRelaxed(reinterpret_cast(quintptr(GetCurrentThreadId()))); - } - QCoreApplicationPrivate::theMainThread = threadData->thread.loadRelaxed(); -} -#endif - void QAdoptedThread::init() { d_func()->handle = GetCurrentThread(); @@ -225,11 +162,7 @@ void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread) // Start watcher thread if it is not already running. if (qt_adopted_thread_watcher_id == 0) { if (qt_adopted_thread_wakeup == 0) { -#ifndef Q_OS_WINRT qt_adopted_thread_wakeup = CreateEvent(0, false, false, 0); -#else - qt_adopted_thread_wakeup = CreateEventEx(0, NULL, 0, EVENT_ALL_ACCESS); -#endif qt_adopted_thread_handles.prepend(qt_adopted_thread_wakeup); } @@ -268,21 +201,13 @@ DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID) // no need to loop, no timeout offset = 0; count = handlesCopy.count(); -#ifndef Q_OS_WINRT ret = WaitForMultipleObjects(handlesCopy.count(), handlesCopy.constData(), false, INFINITE); -#else - ret = WaitForMultipleObjectsEx(handlesCopy.count(), handlesCopy.constData(), false, INFINITE, false); -#endif } else { int loop = 0; do { offset = loop * MAXIMUM_WAIT_OBJECTS; count = qMin(handlesCopy.count() - offset, MAXIMUM_WAIT_OBJECTS); -#ifndef Q_OS_WINRT ret = WaitForMultipleObjects(count, handlesCopy.constData() + offset, false, 100); -#else - ret = WaitForMultipleObjectsEx(count, handlesCopy.constData() + offset, false, 100, false); -#endif loop = (loop + 1) % loops; } while (ret == WAIT_TIMEOUT); } @@ -323,7 +248,7 @@ DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID) return 0; } -#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT) +#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) #ifndef Q_OS_WIN64 # define ULONG_PTR DWORD @@ -354,7 +279,7 @@ void qt_set_thread_name(HANDLE threadId, LPCSTR threadName) { } } -#endif // !QT_NO_DEBUG && Q_CC_MSVC && !Q_OS_WINRT +#endif // !QT_NO_DEBUG && Q_CC_MSVC /************************************************************************** ** QThreadPrivate @@ -365,11 +290,7 @@ void qt_set_thread_name(HANDLE threadId, LPCSTR threadName) QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *data) { Q_UNUSED(data); -#ifndef Q_OS_WINRT return new QEventDispatcherWin32; -#else - return new QEventDispatcherWinRT; -#endif } #if QT_CONFIG(thread) @@ -392,7 +313,7 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi data->ensureEventDispatcher(); -#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT) +#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) // sets the name of the current thread. QByteArray objectName = thr->objectName().toLocal8Bit(); qt_set_thread_name(HANDLE(-1), @@ -457,11 +378,7 @@ Qt::HANDLE QThread::currentThreadIdImpl() noexcept int QThread::idealThreadCount() noexcept { SYSTEM_INFO sysinfo; -#ifndef Q_OS_WINRT GetSystemInfo(&sysinfo); -#else - GetNativeSystemInfo(&sysinfo); -#endif return sysinfo.dwNumberOfProcessors; } @@ -519,16 +436,7 @@ void QThread::start(Priority priority) less than NormalPriority), but the newly created thread preempts its 'parent' and runs at normal priority. */ -#if defined(Q_CC_MSVC) && !defined(_DLL) // && !defined(Q_OS_WINRT) -# ifdef Q_OS_WINRT - // If you wish to accept the memory leaks, uncomment the part above. - // See: - // https://support.microsoft.com/en-us/kb/104641 - // https://msdn.microsoft.com/en-us/library/kdzttdcb.aspx -# error "Microsoft documentation says this combination leaks memory every time a thread is started. " \ - "Please change your build back to -MD/-MDd or, if you understand this issue and want to continue, " \ - "edit this source file." -# endif +#if defined(Q_CC_MSVC) && !defined(_DLL) // MSVC -MT or -MTd build d->handle = (Qt::HANDLE) _beginthreadex(NULL, d->stackSize, QThreadPrivate::start, this, CREATE_SUSPENDED, &(d->id)); @@ -537,7 +445,7 @@ void QThread::start(Priority priority) d->handle = CreateThread(nullptr, d->stackSize, reinterpret_cast(QThreadPrivate::start), this, CREATE_SUSPENDED, reinterpret_cast(&d->id)); -#endif // Q_OS_WINRT +#endif if (!d->handle) { qErrnoWarning("QThread::start: Failed to create thread"); @@ -603,10 +511,7 @@ void QThread::terminate() return; } - // Calling ExitThread() in setTerminationEnabled is all we can do on WinRT -#ifndef Q_OS_WINRT TerminateThread(d->handle, 0); -#endif QThreadPrivate::finish(this, false); } @@ -626,11 +531,7 @@ bool QThread::wait(QDeadlineTimer deadline) locker.mutex()->unlock(); bool ret = false; -#ifndef Q_OS_WINRT switch (WaitForSingleObject(d->handle, deadline.remainingTime())) { -#else - switch (WaitForSingleObjectEx(d->handle, deadline.remainingTime(), false)) { -#endif case WAIT_OBJECT_0: ret = true; break; @@ -671,11 +572,7 @@ void QThread::setTerminationEnabled(bool enabled) if (enabled && d->terminatePending) { QThreadPrivate::finish(thr, false); locker.unlock(); // don't leave the mutex locked! -#ifndef Q_OS_WINRT _endthreadex(0); -#else - ExitThread(0); -#endif } } diff --git a/src/corelib/thread/qwaitcondition_win.cpp b/src/corelib/thread/qwaitcondition_win.cpp index a6ad95b397..ba34129b7f 100644 --- a/src/corelib/thread/qwaitcondition_win.cpp +++ b/src/corelib/thread/qwaitcondition_win.cpp @@ -61,11 +61,7 @@ class QWaitConditionEvent public: inline QWaitConditionEvent() : priority(0), wokenUp(false) { -#ifndef Q_OS_WINRT event = CreateEvent(NULL, TRUE, FALSE, NULL); -#else - event = CreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS); -#endif } inline ~QWaitConditionEvent() { CloseHandle(event); } int priority; @@ -92,9 +88,7 @@ QWaitConditionEvent *QWaitConditionPrivate::pre() mtx.lock(); QWaitConditionEvent *wce = freeQueue.isEmpty() ? new QWaitConditionEvent : freeQueue.takeFirst(); -#ifndef Q_OS_WINRT wce->priority = GetThreadPriority(GetCurrentThread()); -#endif wce->wokenUp = false; // insert 'wce' into the queue (sorted by priority) diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 39fdc491df..78cfa05ec9 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -63,9 +63,6 @@ #include #ifdef Q_OS_WIN # include -# ifdef Q_OS_WINRT -# include "qfunctions_winrt.h" -# endif #endif #if defined(Q_OS_MAC) diff --git a/src/corelib/time/qtimezoneprivate_win.cpp b/src/corelib/time/qtimezoneprivate_win.cpp index 0aaf469ed9..1dc362e45a 100644 --- a/src/corelib/time/qtimezoneprivate_win.cpp +++ b/src/corelib/time/qtimezoneprivate_win.cpp @@ -46,11 +46,7 @@ #include -#ifndef Q_OS_WINRT #include -// The registry-based timezone backend is not available on WinRT, which falls back to equivalent APIs. -#define QT_USE_REGISTRY_TIMEZONE 1 -#endif QT_BEGIN_NAMESPACE @@ -71,10 +67,8 @@ QT_BEGIN_NAMESPACE // Vista introduced support for historic data, see MSDN docs on DYNAMIC_TIME_ZONE_INFORMATION // http://msdn.microsoft.com/en-gb/library/windows/desktop/ms724253%28v=vs.85%29.aspx -#ifdef QT_USE_REGISTRY_TIMEZONE static const wchar_t tzRegPath[] = LR"(SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones)"; static const wchar_t currTzRegPath[] = LR"(SYSTEM\CurrentControlSet\Control\TimeZoneInformation)"; -#endif enum { MIN_YEAR = -292275056, @@ -138,8 +132,6 @@ bool equalTzi(const TIME_ZONE_INFORMATION &tzi1, const TIME_ZONE_INFORMATION &tz && wcscmp(tzi1.DaylightName, tzi2.DaylightName) == 0); } -#ifdef QT_USE_REGISTRY_TIMEZONE - QWinTimeZonePrivate::QWinTransitionRule readRegistryRule(const HKEY &key, const wchar_t *value, bool *ok) { @@ -189,73 +181,6 @@ TIME_ZONE_INFORMATION getRegistryTzi(const QByteArray &windowsId, bool *ok) return tzi; } -#else // QT_USE_REGISTRY_TIMEZONE -struct QWinDynamicTimeZone -{ - QString standardName; - QString daylightName; - QString timezoneName; - qint32 bias; - bool daylightTime; -}; - -typedef QHash QWinRTTimeZoneHash; - -Q_GLOBAL_STATIC(QWinRTTimeZoneHash, gTimeZones) - -void enumerateTimeZones() -{ - DYNAMIC_TIME_ZONE_INFORMATION dtzInfo; - quint32 index = 0; - QString prevTimeZoneKeyName; - while (SUCCEEDED(EnumDynamicTimeZoneInformation(index++, &dtzInfo))) { - QWinDynamicTimeZone item; - item.timezoneName = QString::fromWCharArray(dtzInfo.TimeZoneKeyName); - // As soon as key name repeats, break. Some systems continue to always - // return the last item independent of index being out of range - if (item.timezoneName == prevTimeZoneKeyName) - break; - item.standardName = QString::fromWCharArray(dtzInfo.StandardName); - item.daylightName = QString::fromWCharArray(dtzInfo.DaylightName); - item.daylightTime = !dtzInfo.DynamicDaylightTimeDisabled; - item.bias = dtzInfo.Bias; - gTimeZones->insert(item.timezoneName.toUtf8(), item); - prevTimeZoneKeyName = item.timezoneName; - } -} - -DYNAMIC_TIME_ZONE_INFORMATION dynamicInfoForId(const QByteArray &windowsId) -{ - DYNAMIC_TIME_ZONE_INFORMATION dtzInfo; - quint32 index = 0; - QString prevTimeZoneKeyName; - while (SUCCEEDED(EnumDynamicTimeZoneInformation(index++, &dtzInfo))) { - const QString timeZoneName = QString::fromWCharArray(dtzInfo.TimeZoneKeyName); - if (timeZoneName == QLatin1String(windowsId)) - break; - if (timeZoneName == prevTimeZoneKeyName) - break; - prevTimeZoneKeyName = timeZoneName; - } - return dtzInfo; -} - -QWinTimeZonePrivate::QWinTransitionRule -readDynamicRule(DYNAMIC_TIME_ZONE_INFORMATION &dtzi, int year, bool *ok) -{ - TIME_ZONE_INFORMATION tzi; - QWinTimeZonePrivate::QWinTransitionRule rule; - *ok = GetTimeZoneInformationForYear(year, &dtzi, &tzi); - if (*ok) { - rule.startYear = 0; - rule.standardTimeBias = tzi.Bias + tzi.StandardBias; - rule.daylightTimeBias = tzi.Bias + tzi.DaylightBias - rule.standardTimeBias; - rule.standardTimeRule = tzi.StandardDate; - rule.daylightTimeRule = tzi.DaylightDate; - } - return rule; -} -#endif // QT_USE_REGISTRY_TIMEZONE bool isSameRule(const QWinTimeZonePrivate::QWinTransitionRule &last, const QWinTimeZonePrivate::QWinTransitionRule &rule) @@ -273,7 +198,6 @@ bool isSameRule(const QWinTimeZonePrivate::QWinTransitionRule &last, QList availableWindowsIds() { -#ifdef QT_USE_REGISTRY_TIMEZONE // TODO Consider caching results in a global static, very unlikely to change. QList list; QWinRegistryKey key(HKEY_LOCAL_MACHINE, tzRegPath); @@ -290,16 +214,10 @@ QList availableWindowsIds() } } return list; -#else // QT_USE_REGISTRY_TIMEZONE - if (gTimeZones->isEmpty()) - enumerateTimeZones(); - return gTimeZones->keys(); -#endif // QT_USE_REGISTRY_TIMEZONE } QByteArray windowsSystemZoneId() { -#ifdef QT_USE_REGISTRY_TIMEZONE // On Vista and later is held in the value TimeZoneKeyName in key currTzRegPath const QString id = QWinRegistryKey(HKEY_LOCAL_MACHINE, currTzRegPath) .stringValue(L"TimeZoneKeyName"); @@ -316,11 +234,6 @@ QByteArray windowsSystemZoneId() if (equalTzi(getRegistryTzi(winId, &ok), sysTzi)) return winId; } -#else // QT_USE_REGISTRY_TIMEZONE - DYNAMIC_TIME_ZONE_INFORMATION dtzi; - if (SUCCEEDED(GetDynamicTimeZoneInformation(&dtzi))) - return QString::fromWCharArray(dtzi.TimeZoneKeyName).toLocal8Bit(); -#endif // QT_USE_REGISTRY_TIMEZONE // If we can't determine the current ID use UTC return QTimeZonePrivate::utcQByteArray(); @@ -544,7 +457,6 @@ void QWinTimeZonePrivate::init(const QByteArray &ianaId) bool badMonth = false; // Only warn once per zone, if at all. if (!m_windowsId.isEmpty()) { -#ifdef QT_USE_REGISTRY_TIMEZONE // Open the base TZI for the time zone const QString baseKeyPath = QString::fromWCharArray(tzRegPath) + QLatin1Char('\\') + QString::fromUtf8(m_windowsId); @@ -591,50 +503,6 @@ void QWinTimeZonePrivate::init(const QByteArray &ianaId) m_tranRules.append(rule); } } -#else // QT_USE_REGISTRY_TIMEZONE - if (gTimeZones->isEmpty()) - enumerateTimeZones(); - QWinRTTimeZoneHash::const_iterator it = gTimeZones->find(m_windowsId); - if (it != gTimeZones->constEnd()) { - m_displayName = it->timezoneName; - m_standardName = it->standardName; - m_daylightName = it->daylightName; - DWORD firstYear = 0; - DWORD lastYear = 0; - DYNAMIC_TIME_ZONE_INFORMATION dtzi = dynamicInfoForId(m_windowsId); - if (GetDynamicTimeZoneInformationEffectiveYears(&dtzi, &firstYear, &lastYear) - == ERROR_SUCCESS && firstYear < lastYear) { - for (DWORD year = firstYear; year <= lastYear; ++year) { - bool ok = false; - QWinTransitionRule rule = readDynamicRule(dtzi, year, &ok); - if (ok - // Don't repeat a recurrent rule - && (m_tranRules.isEmpty() - || !isSameRule(m_tranRules.last(), rule))) { - if (!badMonth - && (rule.standardTimeRule.wMonth == 0) - != (rule.daylightTimeRule.wMonth == 0)) { - badMonth = true; - qWarning("MS dynamic TZ API violated its wMonth constraint;" - "this may cause mistakes for %s from %d", - ianaId.constData(), year); - } - rule.startYear = m_tranRules.isEmpty() ? MIN_YEAR : year; - m_tranRules.append(rule); - } - } - } else { - // At least try to get the non-dynamic data: - dtzi.DynamicDaylightTimeDisabled = false; - bool ok = false; - QWinTransitionRule rule = readDynamicRule(dtzi, 1970, &ok); - if (ok) { - rule.startYear = MIN_YEAR; - m_tranRules.append(rule); - } - } - } -#endif // QT_USE_REGISTRY_TIMEZONE } // If there are no rules then we failed to find a windowsId or any tzi info diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp index a3d2a2f7c0..ed4171fe4d 100644 --- a/src/corelib/tools/qcommandlineparser.cpp +++ b/src/corelib/tools/qcommandlineparser.cpp @@ -45,7 +45,7 @@ #include #include #include -#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) # include #endif #include @@ -542,7 +542,7 @@ QString QCommandLineParser::errorText() const enum MessageType { UsageMessage, ErrorMessage }; -#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) // Return whether to use a message box. Use handles if a console can be obtained // or we are run with redirected handles (for example, by QProcess). static inline bool displayMessageBox() @@ -554,17 +554,11 @@ static inline bool displayMessageBox() GetStartupInfo(&startupInfo); return !(startupInfo.dwFlags & STARTF_USESTDHANDLES); } -#endif // Q_OS_WIN && !QT_BOOTSTRAPPED && !Q_OS_WIN && !Q_OS_WINRT +#endif // Q_OS_WIN && !QT_BOOTSTRAPPED static void showParserMessage(const QString &message, MessageType type) { -#if defined(Q_OS_WINRT) - if (type == UsageMessage) - qInfo("%ls", qUtf16Printable(message)); - else - qCritical("%ls", qUtf16Printable(message)); - return; -#elif defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) +#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) if (displayMessageBox()) { const UINT flags = MB_OK | MB_TOPMOST | MB_SETFOREGROUND | (type == UsageMessage ? MB_ICONINFORMATION : MB_ICONERROR); -- cgit v1.2.3