summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/arch/arch.pri2
-rw-r--r--src/corelib/arch/qatomic_msvc.h42
-rw-r--r--src/corelib/codecs/codecs.pri23
-rw-r--r--src/corelib/codecs/qicucodec.cpp10
-rw-r--r--src/corelib/codecs/qtextcodec.cpp6
-rw-r--r--src/corelib/codecs/qutfcodec.cpp87
-rw-r--r--src/corelib/codecs/qwindowscodec.cpp2
-rw-r--r--src/corelib/corelib.pro16
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp36
-rw-r--r--src/corelib/global/qcompilerdetection.h30
-rw-r--r--src/corelib/global/qconfig-dist.h48
-rw-r--r--src/corelib/global/qconfig-large.h140
-rw-r--r--src/corelib/global/qconfig-medium.h241
-rw-r--r--src/corelib/global/qconfig-minimal.h463
-rw-r--r--src/corelib/global/qconfig-nacl.h233
-rw-r--r--src/corelib/global/qconfig-small.h281
-rw-r--r--src/corelib/global/qflags.h9
-rw-r--r--src/corelib/global/qglobal.cpp359
-rw-r--r--src/corelib/global/qglobal.h19
-rw-r--r--src/corelib/global/qhooks.cpp2
-rw-r--r--src/corelib/global/qlibraryinfo.cpp33
-rw-r--r--src/corelib/global/qlibraryinfo.h11
-rw-r--r--src/corelib/global/qlogging.cpp4
-rw-r--r--src/corelib/global/qnamespace.h8
-rw-r--r--src/corelib/global/qnamespace.qdoc35
-rw-r--r--src/corelib/global/qnumeric_p.h2
-rw-r--r--src/corelib/global/qprocessordetection.h2
-rw-r--r--src/corelib/global/qsysinfo.h18
-rw-r--r--src/corelib/global/qsystemdetection.h22
-rw-r--r--src/corelib/global/qt_windows.h17
-rw-r--r--src/corelib/io/io.pri37
-rw-r--r--src/corelib/io/qdatastream.h5
-rw-r--r--src/corelib/io/qdir.cpp2
-rw-r--r--src/corelib/io/qfileselector.cpp13
-rw-r--r--src/corelib/io/qfileselector_p.h2
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp2
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp250
-rw-r--r--src/corelib/io/qfilesystemiterator_win.cpp2
-rw-r--r--src/corelib/io/qfilesystemmetadata_p.h3
-rw-r--r--src/corelib/io/qfilesystemwatcher.cpp4
-rw-r--r--src/corelib/io/qfilesystemwatcher_fsevents.mm8
-rw-r--r--src/corelib/io/qfilesystemwatcher_win.cpp10
-rw-r--r--src/corelib/io/qfsfileengine.cpp8
-rw-r--r--src/corelib/io/qfsfileengine_p.h9
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp141
-rw-r--r--src/corelib/io/qiodevice.cpp33
-rw-r--r--src/corelib/io/qlockfile_unix.cpp4
-rw-r--r--src/corelib/io/qlockfile_win.cpp4
-rw-r--r--src/corelib/io/qprocess.cpp14
-rw-r--r--src/corelib/io/qprocess_unix.cpp2
-rw-r--r--src/corelib/io/qprocess_wince.cpp308
-rw-r--r--src/corelib/io/qsettings.cpp12
-rw-r--r--src/corelib/io/qsettings_mac.cpp26
-rw-r--r--src/corelib/io/qsettings_win.cpp8
-rw-r--r--src/corelib/io/qstandardpaths_mac.mm4
-rw-r--r--src/corelib/io/qstandardpaths_win.cpp42
-rw-r--r--src/corelib/io/qstorageinfo_p.h2
-rw-r--r--src/corelib/io/qtemporaryfile.cpp27
-rw-r--r--src/corelib/io/qtemporaryfile_p.h5
-rw-r--r--src/corelib/io/qtextstream.cpp2
-rw-r--r--src/corelib/io/qurl.cpp30
-rw-r--r--src/corelib/io/qurl.h16
-rw-r--r--src/corelib/io/qurl_mac.mm74
-rw-r--r--src/corelib/io/qwindowspipereader.cpp17
-rw-r--r--src/corelib/io/qwindowspipewriter.cpp5
-rw-r--r--src/corelib/json/qjson_p.h4
-rw-r--r--src/corelib/kernel/kernel.pri17
-rw-r--r--src/corelib/kernel/qcore_foundation.mm462
-rw-r--r--src/corelib/kernel/qcore_mac_objc.mm4
-rw-r--r--src/corelib/kernel/qcore_unix_p.h4
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp41
-rw-r--r--src/corelib/kernel/qcoreapplication_win.cpp36
-rw-r--r--src/corelib/kernel/qcorecmdlineargs_p.h88
-rw-r--r--src/corelib/kernel/qeventdispatcher_cf.mm12
-rw-r--r--src/corelib/kernel/qeventdispatcher_cf_p.h2
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp259
-rw-r--r--src/corelib/kernel/qeventdispatcher_win_p.h2
-rw-r--r--src/corelib/kernel/qfunctions_p.h4
-rw-r--r--src/corelib/kernel/qfunctions_wince.cpp407
-rw-r--r--src/corelib/kernel/qfunctions_wince.h473
-rw-r--r--src/corelib/kernel/qmath.h22
-rw-r--r--src/corelib/kernel/qmetaobject.h10
-rw-r--r--src/corelib/kernel/qmetaobject_p.h10
-rw-r--r--src/corelib/kernel/qmetatype.cpp6
-rw-r--r--src/corelib/kernel/qmetatype.h13
-rw-r--r--src/corelib/kernel/qobject.h4
-rw-r--r--src/corelib/kernel/qobject_impl.h16
-rw-r--r--src/corelib/kernel/qppsobject.cpp24
-rw-r--r--src/corelib/kernel/qsharedmemory_win.cpp8
-rw-r--r--src/corelib/kernel/qsystemerror.cpp22
-rw-r--r--src/corelib/kernel/qsystemsemaphore_p.h4
-rw-r--r--src/corelib/kernel/qsystemsemaphore_posix.cpp4
-rw-r--r--src/corelib/kernel/qsystemsemaphore_systemv.cpp3
-rw-r--r--src/corelib/kernel/qsystemsemaphore_win.cpp4
-rw-r--r--src/corelib/kernel/qtimer.h6
-rw-r--r--src/corelib/plugin/plugin.pri4
-rw-r--r--src/corelib/plugin/qfactoryloader.cpp12
-rw-r--r--src/corelib/plugin/qlibrary_unix.cpp16
-rw-r--r--src/corelib/plugin/qlibrary_win.cpp21
-rw-r--r--src/corelib/plugin/qmachparser.cpp3
-rw-r--r--src/corelib/plugin/qpluginloader.cpp5
-rw-r--r--src/corelib/plugin/qsystemlibrary.cpp16
-rw-r--r--src/corelib/plugin/qsystemlibrary_p.h4
-rw-r--r--src/corelib/plugin/quuid.cpp33
-rw-r--r--src/corelib/plugin/quuid.h6
-rw-r--r--src/corelib/plugin/quuid_darwin.mm75
-rw-r--r--src/corelib/statemachine/qsignaltransition.h1
-rw-r--r--src/corelib/statemachine/qstate.h1
-rw-r--r--src/corelib/thread/qmutex_win.cpp4
-rw-r--r--src/corelib/thread/qthread_win.cpp44
-rw-r--r--src/corelib/thread/qwaitcondition_win.cpp5
-rw-r--r--src/corelib/tools/qalgorithms.h204
-rw-r--r--src/corelib/tools/qbytearray.cpp85
-rw-r--r--src/corelib/tools/qbytearray.h8
-rw-r--r--src/corelib/tools/qbytearray_mac.mm99
-rw-r--r--src/corelib/tools/qbytearraylist.h2
-rw-r--r--src/corelib/tools/qchar.h12
-rw-r--r--src/corelib/tools/qcommandlineoption.cpp58
-rw-r--r--src/corelib/tools/qcommandlineoption.h16
-rw-r--r--src/corelib/tools/qcommandlineparser.cpp28
-rw-r--r--src/corelib/tools/qcryptographichash.h3
-rw-r--r--src/corelib/tools/qdatetime.cpp889
-rw-r--r--src/corelib/tools/qdatetime.h69
-rw-r--r--src/corelib/tools/qdatetime_mac.mm74
-rw-r--r--src/corelib/tools/qdatetime_p.h70
-rw-r--r--src/corelib/tools/qelapsedtimer_win.cpp49
-rw-r--r--src/corelib/tools/qline.cpp23
-rw-r--r--src/corelib/tools/qline.h14
-rw-r--r--src/corelib/tools/qlist.h5
-rw-r--r--src/corelib/tools/qlocale.cpp1
-rw-r--r--src/corelib/tools/qlocale_mac.mm3
-rw-r--r--src/corelib/tools/qlocale_win.cpp78
-rw-r--r--src/corelib/tools/qrect.h13
-rw-r--r--src/corelib/tools/qscopedpointer.cpp42
-rw-r--r--src/corelib/tools/qscopedpointer.h45
-rw-r--r--src/corelib/tools/qsharedpointer.cpp112
-rw-r--r--src/corelib/tools/qsharedpointer.h14
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h116
-rw-r--r--src/corelib/tools/qsimd.cpp29
-rw-r--r--src/corelib/tools/qsimd_p.h61
-rw-r--r--src/corelib/tools/qstring.cpp151
-rw-r--r--src/corelib/tools/qstring.h189
-rw-r--r--src/corelib/tools/qstring_mac.mm83
-rw-r--r--src/corelib/tools/qstringlist.h2
-rw-r--r--src/corelib/tools/qtimezoneprivate_win.cpp6
-rw-r--r--src/corelib/tools/tools.pri17
146 files changed, 2671 insertions, 5552 deletions
diff --git a/src/corelib/arch/arch.pri b/src/corelib/arch/arch.pri
index ec617386a4..0f7c2b887b 100644
--- a/src/corelib/arch/arch.pri
+++ b/src/corelib/arch/arch.pri
@@ -1,4 +1,4 @@
-win32|wince:HEADERS += arch/qatomic_msvc.h
+win32:HEADERS += arch/qatomic_msvc.h
HEADERS += \
arch/qatomic_bootstrap.h \
diff --git a/src/corelib/arch/qatomic_msvc.h b/src/corelib/arch/qatomic_msvc.h
index 62d54ded55..5eae2bdc48 100644
--- a/src/corelib/arch/qatomic_msvc.h
+++ b/src/corelib/arch/qatomic_msvc.h
@@ -45,8 +45,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
-#ifndef Q_OS_WINCE
-
// use compiler intrinsics for all atomic functions
# define QT_INTERLOCKED_PREFIX _
# define QT_INTERLOCKED_PROTOTYPE
@@ -58,36 +56,6 @@
# define Q_ATOMIC_INT64_IS_SUPPORTED
# endif
-#else // Q_OS_WINCE
-
-# if _WIN32_WCE < 0x600 && defined(_X86_)
-// For X86 Windows CE, include winbase.h to catch inline functions which
-// override the regular definitions inside of coredll.dll.
-// Though one could use the original version of Increment/Decrement, others are
-// not exported at all.
-# include <winbase.h>
-
-// It's safer to remove the volatile and let the compiler add it as needed.
-# define QT_INTERLOCKED_VOLATILE
-
-# else // _WIN32_WCE >= 0x600 || !_X86_
-
-# define QT_INTERLOCKED_PROTOTYPE __cdecl
-# define QT_INTERLOCKED_DECLARE_PROTOTYPES
-
-# if _WIN32_WCE >= 0x600
-# if defined(_X86_)
-# define QT_INTERLOCKED_PREFIX _
-# define QT_INTERLOCKED_INTRINSIC
-# endif
-# else
-# define QT_INTERLOCKED_VOLATILE
-# endif
-
-# endif // _WIN32_WCE >= 0x600 || !_X86_
-
-#endif // Q_OS_WINCE
-
////////////////////////////////////////////////////////////////////////////////////////////////////
// Prototype declaration
@@ -128,7 +96,7 @@ extern "C" {
long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Exchange )(long QT_INTERLOCKED_VOLATILE *, long);
long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( ExchangeAdd )(long QT_INTERLOCKED_VOLATILE *, long);
-# if !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86)
+# if !defined(__i386__) && !defined(_M_IX86)
void * QT_INTERLOCKED_FUNCTION( CompareExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *, void *);
void * QT_INTERLOCKED_FUNCTION( ExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *);
__int64 QT_INTERLOCKED_FUNCTION( ExchangeAdd64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64);
@@ -165,7 +133,7 @@ extern "C" {
# pragma intrinsic (_InterlockedCompareExchange)
# pragma intrinsic (_InterlockedExchangeAdd)
-# if !defined(Q_OS_WINCE) && !defined(_M_IX86)
+# if !defined(_M_IX86)
# pragma intrinsic (_InterlockedCompareExchangePointer)
# pragma intrinsic (_InterlockedExchangePointer)
# pragma intrinsic (_InterlockedExchangeAdd64)
@@ -176,7 +144,7 @@ extern "C" {
////////////////////////////////////////////////////////////////////////////////////////////////////
// Interlocked* replacement macros
-#if defined(Q_OS_WINCE) || defined(__i386__) || defined(_M_IX86)
+#if defined(__i386__) || defined(_M_IX86)
# define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \
reinterpret_cast<void *>( \
@@ -195,7 +163,7 @@ extern "C" {
reinterpret_cast<long QT_INTERLOCKED_VOLATILE *>(value), \
(valueToAdd))
-#else // !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86)
+#else // !defined(__i386__) && !defined(_M_IX86)
# define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \
QT_INTERLOCKED_FUNCTION(CompareExchangePointer)( \
@@ -213,7 +181,7 @@ extern "C" {
reinterpret_cast<qint64 QT_INTERLOCKED_VOLATILE *>(value), \
(valueToAdd))
-#endif // !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86)
+#endif // !defined(__i386__) && !defined(_M_IX86)
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri
index bfb677e6fb..fdaec33c5a 100644
--- a/src/corelib/codecs/codecs.pri
+++ b/src/corelib/codecs/codecs.pri
@@ -40,20 +40,17 @@ contains(QT_CONFIG,icu) {
codecs/qeuckrcodec.cpp \
codecs/qbig5codec.cpp
- unix:!qnx:!mac:!ios:!linux-android-* {
- contains(QT_CONFIG,iconv) {
- HEADERS += codecs/qiconvcodec_p.h
- SOURCES += codecs/qiconvcodec.cpp
- } else:contains(QT_CONFIG,gnu-libiconv) {
- HEADERS += codecs/qiconvcodec_p.h
- SOURCES += codecs/qiconvcodec.cpp
- DEFINES += GNU_LIBICONV
- LIBS_PRIVATE *= -liconv
- } else:contains(QT_CONFIG,sun-libiconv) {
- HEADERS += codecs/qiconvcodec_p.h
- SOURCES += codecs/qiconvcodec.cpp
- DEFINES += GNU_LIBICONV
+ unix:!qnx:!darwin:!linux-android-* {
+ contains(QT_CONFIG, iconv) {
+ HEADERS += codecs/qiconvcodec_p.h
+ SOURCES += codecs/qiconvcodec.cpp
+ contains(QT_CONFIG, gnu-libiconv) {
+ DEFINES += GNU_LIBICONV
+ LIBS_PRIVATE *= -liconv
+ } else: contains(QT_CONFIG, sun-libiconv) {
+ DEFINES += GNU_LIBICONV
}
+ }
} else:!win32-msvc* {
DEFINES += QT_NO_ICONV
}
diff --git a/src/corelib/codecs/qicucodec.cpp b/src/corelib/codecs/qicucodec.cpp
index aa2095d9da..ee9f1d0048 100644
--- a/src/corelib/codecs/qicucodec.cpp
+++ b/src/corelib/codecs/qicucodec.cpp
@@ -527,7 +527,7 @@ QTextCodec *QIcuCodec::codecForNameUnlocked(const char *name)
// check whether there is really a converter for the name available.
UConverter *conv = ucnv_open(standardName, &error);
if (!conv) {
- qDebug() << "codecForName: ucnv_open failed" << standardName << u_errorName(error);
+ qDebug("codecForName: ucnv_open failed %s %s", standardName, u_errorName(error));
return 0;
}
//qDebug() << "QIcuCodec: Standard name for " << name << "is" << standardName;
@@ -577,7 +577,7 @@ UConverter *QIcuCodec::getConverter(QTextCodec::ConverterState *state) const
ucnv_setSubstChars(static_cast<UConverter *>(state->d),
state->flags & QTextCodec::ConvertInvalidToNull ? "\0" : "?", 1, &error);
if (U_FAILURE(error))
- qDebug() << "getConverter(state) ucnv_open failed" << m_name << u_errorName(error);
+ qDebug("getConverter(state) ucnv_open failed %s %s", m_name, u_errorName(error));
}
conv = static_cast<UConverter *>(state->d);
}
@@ -587,7 +587,7 @@ UConverter *QIcuCodec::getConverter(QTextCodec::ConverterState *state) const
conv = ucnv_open(m_name, &error);
ucnv_setSubstChars(conv, "?", 1, &error);
if (U_FAILURE(error))
- qDebug() << "getConverter(no state) ucnv_open failed" << m_name << u_errorName(error);
+ qDebug("getConverter(no state) ucnv_open failed %s %s", m_name, u_errorName(error));
}
return conv;
}
@@ -610,7 +610,7 @@ QString QIcuCodec::convertToUnicode(const char *chars, int length, QTextCodec::C
&chars, end,
0, false, &error);
if (!U_SUCCESS(error) && error != U_BUFFER_OVERFLOW_ERROR) {
- qDebug() << "convertToUnicode failed:" << u_errorName(error);
+ qDebug("convertToUnicode failed: %s", u_errorName(error));
break;
}
@@ -647,7 +647,7 @@ QByteArray QIcuCodec::convertFromUnicode(const QChar *unicode, int length, QText
&uc, end,
0, false, &error);
if (!U_SUCCESS(error))
- qDebug() << "convertFromUnicode failed:" << u_errorName(error);
+ qDebug("convertFromUnicode failed: %s", u_errorName(error));
convertedChars = ch - string.data();
if (uc >= end)
break;
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index edb03af447..5098ac4242 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -132,7 +132,7 @@ bool qTextCodecNameMatch(const char *n, const char *h)
}
-#if !defined(Q_OS_WIN32) && !defined(Q_OS_WINCE) && !defined(QT_LOCALE_IS_UTF8)
+#if !defined(Q_OS_WIN32) && !defined(QT_LOCALE_IS_UTF8)
static QTextCodec *checkForCodec(const QByteArray &name) {
QTextCodec *c = QTextCodec::codecForName(name);
if (!c) {
@@ -169,7 +169,7 @@ static QTextCodec *setupLocaleMapper()
#if defined(QT_LOCALE_IS_UTF8)
locale = QTextCodec::codecForName("UTF-8");
-#elif defined(Q_OS_WIN) || defined(Q_OS_WINCE)
+#elif defined(Q_OS_WIN)
locale = QTextCodec::codecForName("System");
#else
@@ -289,7 +289,7 @@ static void setup()
#if !defined(QT_NO_ICONV)
(void) new QIconvCodec;
#endif
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN32)
(void) new QWindowsLocalCodec;
#endif // Q_OS_WIN32
#endif // !QT_NO_CODECS && !QT_BOOTSTRAPPED
diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp
index f1054ceb98..74a716db4a 100644
--- a/src/corelib/codecs/qutfcodec.cpp
+++ b/src/corelib/codecs/qutfcodec.cpp
@@ -52,6 +52,19 @@ enum { Endian = 0, Data = 1 };
static const uchar utf8bom[] = { 0xef, 0xbb, 0xbf };
+#if (defined(__SSE2__) && defined(QT_COMPILER_SUPPORTS_SSE2)) \
+ || (defined(__ARM_NEON__) && defined(Q_PROCESSOR_ARM_64))
+static Q_ALWAYS_INLINE uint qBitScanReverse(unsigned v) Q_DECL_NOTHROW
+{
+ uint result = qCountLeadingZeroBits(v);
+ // Now Invert the result: clz will count *down* from the msb to the lsb, so the msb index is 31
+ // and the lsb index is 0. The result for _bit_scan_reverse is expected to be the index when
+ // counting up: msb index is 0 (because it starts there), and the lsb index is 31.
+ result ^= sizeof(unsigned) * 8 - 1;
+ return result;
+}
+#endif
+
#if defined(__SSE2__) && defined(QT_COMPILER_SUPPORTS_SSE2)
static inline bool simdEncodeAscii(uchar *&dst, const ushort *&nextAscii, const ushort *&src, const ushort *end)
{
@@ -81,9 +94,9 @@ static inline bool simdEncodeAscii(uchar *&dst, const ushort *&nextAscii, const
// find the next probable ASCII character
// we don't want to load 32 bytes again in this loop if we know there are non-ASCII
// characters still coming
- nextAscii = src + _bit_scan_reverse(n) + 1;
+ nextAscii = src + qBitScanReverse(n) + 1;
- n = _bit_scan_forward(n);
+ n = qCountTrailingZeroBits(n);
dst += n;
src += n;
return false;
@@ -132,13 +145,81 @@ static inline bool simdDecodeAscii(ushort *&dst, const uchar *&nextAscii, const
// find the next probable ASCII character
// we don't want to load 16 bytes again in this loop if we know there are non-ASCII
// characters still coming
- n = _bit_scan_reverse(n);
+ n = qBitScanReverse(n);
nextAscii = src + (n / BitSpacing) + 1;
return false;
}
return src == end;
}
+#elif defined(__ARM_NEON__) && defined(Q_PROCESSOR_ARM_64) // vaddv is only available on Aarch64
+static inline bool simdEncodeAscii(uchar *&dst, const ushort *&nextAscii, const ushort *&src, const ushort *end)
+{
+ uint16x8_t maxAscii = vdupq_n_u16(0x7f);
+ uint16x8_t mask1 = { 1, 1 << 2, 1 << 4, 1 << 6, 1 << 8, 1 << 10, 1 << 12, 1 << 14 };
+ uint16x8_t mask2 = vshlq_n_u16(mask1, 1);
+
+ // do sixteen characters at a time
+ for ( ; end - src >= 16; src += 16, dst += 16) {
+ // load 2 lanes (or: "load interleaved")
+ uint16x8x2_t in = vld2q_u16(src);
+
+ // check if any of the elements > 0x7f, select 1 bit per element (element 0 -> bit 0, element 1 -> bit 1, etc),
+ // add those together into a scalar, and merge the scalars.
+ uint16_t nonAscii = vaddvq_u16(vandq_u16(vcgtq_u16(in.val[0], maxAscii), mask1))
+ | vaddvq_u16(vandq_u16(vcgtq_u16(in.val[1], maxAscii), mask2));
+
+ // merge the two lanes by shifting the values of the second by 8 and inserting them
+ uint16x8_t out = vsliq_n_u16(in.val[0], in.val[1], 8);
+
+ // store, even if there are non-ASCII characters here
+ vst1q_u8(dst, vreinterpretq_u8_u16(out));
+
+ if (nonAscii) {
+ // find the next probable ASCII character
+ // we don't want to load 32 bytes again in this loop if we know there are non-ASCII
+ // characters still coming
+ nextAscii = src + qBitScanReverse(nonAscii) + 1;
+
+ nonAscii = qCountTrailingZeroBits(nonAscii);
+ dst += nonAscii;
+ src += nonAscii;
+ return false;
+ }
+ }
+ return src == end;
+}
+
+static inline bool simdDecodeAscii(ushort *&dst, const uchar *&nextAscii, const uchar *&src, const uchar *end)
+{
+ // do eight characters at a time
+ uint8x8_t msb_mask = vdup_n_u8(0x80);
+ uint8x8_t add_mask = { 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7 };
+ for ( ; end - src >= 8; src += 8, dst += 8) {
+ uint8x8_t c = vld1_u8(src);
+ uint8_t n = vaddv_u8(vand_u8(vcge_u8(c, msb_mask), add_mask));
+ if (!n) {
+ // store
+ vst1q_u16(dst, vmovl_u8(c));
+ continue;
+ }
+
+ // copy the front part that is still ASCII
+ while (!(n & 1)) {
+ *dst++ = *src++;
+ n >>= 1;
+ }
+
+ // find the next probable ASCII character
+ // we don't want to load 16 bytes again in this loop if we know there are non-ASCII
+ // characters still coming
+ n = qBitScanReverse(n);
+ nextAscii = src + n + 1;
+ return false;
+
+ }
+ return src == end;
+}
#else
static inline bool simdEncodeAscii(uchar *, const ushort *, const ushort *, const ushort *)
{
diff --git a/src/corelib/codecs/qwindowscodec.cpp b/src/corelib/codecs/qwindowscodec.cpp
index b802ab7249..813d3c8153 100644
--- a/src/corelib/codecs/qwindowscodec.cpp
+++ b/src/corelib/codecs/qwindowscodec.cpp
@@ -157,7 +157,7 @@ QString QWindowsLocalCodec::convertToUnicodeCharByChar(const char *chars, int le
state->remainingChars = 0;
}
const char *mb = mbcs;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
const char *next = 0;
QString s;
while ((next = CharNextExA(CP_ACP, mb, 0)) != mb) {
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index 42fd5d1a61..ccf9aaa612 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -47,11 +47,19 @@ include(statemachine/statemachine.pri)
include(mimetypes/mimetypes.pri)
include(xml/xml.pri)
-# otherwise mingw headers do not declare common functions like putenv
-mingw: CONFIG -= strict_c++
+win32 {
+ mingw {
+ # otherwise mingw headers do not declare common functions like putenv
+ CONFIG -= strict_c++
+ # Override MinGW's definition in _mingw.h
+ DEFINES += WINVER=0x600 _WIN32_WINNT=0x0600
+ }
+
+ !winrt: LIBS_PRIVATE += -lwinmm
+}
-mac|darwin {
- !ios {
+darwin {
+ osx {
LIBS_PRIVATE += -framework ApplicationServices
LIBS_PRIVATE += -framework CoreServices
}
diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
index a022187c21..ae969ca269 100644
--- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
@@ -131,26 +131,46 @@ absoluteValue = qAbs(myValue);
//! [10]
-//! [11]
-qreal valueA = 2.3;
-qreal valueB = 2.7;
+//! [11A]
+double valueA = 2.3;
+double valueB = 2.7;
int roundedValueA = qRound(valueA);
// roundedValueA = 2
int roundedValueB = qRound(valueB);
// roundedValueB = 3
-//! [11]
+//! [11A]
+//! [11B]
+float valueA = 2.3;
+float valueB = 2.7;
-//! [12]
-qreal valueA = 42949672960.3;
-qreal valueB = 42949672960.7;
+int roundedValueA = qRound(valueA);
+// roundedValueA = 2
+int roundedValueB = qRound(valueB);
+// roundedValueB = 3
+//! [11B]
+
+
+//! [12A]
+double valueA = 42949672960.3;
+double valueB = 42949672960.7;
+
+qint64 roundedValueA = qRound64(valueA);
+// roundedValueA = 42949672960
+qint64 roundedValueB = qRound64(valueB);
+// roundedValueB = 42949672961
+//! [12A]
+
+//! [12B]
+float valueA = 42949672960.3;
+float valueB = 42949672960.7;
qint64 roundedValueA = qRound64(valueA);
// roundedValueA = 42949672960
qint64 roundedValueB = qRound64(valueB);
// roundedValueB = 42949672961
-//! [12]
+//! [12B]
//! [13]
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 669ab136ac..c5424be035 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -650,14 +650,6 @@
/* General C++ features */
# define Q_COMPILER_RESTRICTED_VLA
# define Q_COMPILER_THREADSAFE_STATICS
-# if !__has_feature(cxx_exceptions)
-# ifndef QT_NO_EXCEPTIONS
-# define QT_NO_EXCEPTIONS
-# endif
-# endif
-# if !__has_feature(cxx_rtti)
-# define QT_NO_RTTI
-# endif
# if __has_feature(attribute_deprecated_with_message)
# define Q_DECL_DEPRECATED_X(text) __attribute__ ((__deprecated__(text)))
# endif
@@ -1073,16 +1065,18 @@
# define Q_COMPILER_DEFAULT_DELETE_MEMBERS
#endif
-#if defined(__cpp_constexpr) && __cpp_constexpr-0 >= 201304
-# define Q_DECL_CONSTEXPR constexpr
-# define Q_DECL_RELAXED_CONSTEXPR constexpr
-# define Q_CONSTEXPR constexpr
-# define Q_RELAXED_CONSTEXPR constexpr
-#elif defined Q_COMPILER_CONSTEXPR
-# define Q_DECL_CONSTEXPR constexpr
-# define Q_DECL_RELAXED_CONSTEXPR
-# define Q_CONSTEXPR constexpr
-# define Q_RELAXED_CONSTEXPR const
+#if defined Q_COMPILER_CONSTEXPR
+# if defined(__cpp_constexpr) && __cpp_constexpr-0 >= 201304
+# define Q_DECL_CONSTEXPR constexpr
+# define Q_DECL_RELAXED_CONSTEXPR constexpr
+# define Q_CONSTEXPR constexpr
+# define Q_RELAXED_CONSTEXPR constexpr
+# else
+# define Q_DECL_CONSTEXPR constexpr
+# define Q_DECL_RELAXED_CONSTEXPR
+# define Q_CONSTEXPR constexpr
+# define Q_RELAXED_CONSTEXPR const
+# endif
#else
# define Q_DECL_CONSTEXPR
# define Q_DECL_RELAXED_CONSTEXPR
diff --git a/src/corelib/global/qconfig-dist.h b/src/corelib/global/qconfig-dist.h
deleted file mode 100644
index c9739db990..0000000000
--- a/src/corelib/global/qconfig-dist.h
+++ /dev/null
@@ -1,48 +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$
-**
-****************************************************************************/
-
-
-/*
- Empty leaves all features enabled. See doc/html/emb-features.html for choices.
-
- Note that disabling some features will produce a libqt that is not
- compatible with other libqt builds. Such modifications are only
- supported on Qt for Embedded Linux where reducing the library size is
- important and where the application suite is often a fixed set.
-*/
diff --git a/src/corelib/global/qconfig-large.h b/src/corelib/global/qconfig-large.h
deleted file mode 100644
index 270858e65b..0000000000
--- a/src/corelib/global/qconfig-large.h
+++ /dev/null
@@ -1,140 +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$
-**
-****************************************************************************/
-
-/* Dialogs */
-#ifndef QT_NO_FILEDIALOG
-# define QT_NO_FILEDIALOG
-#endif
-#ifndef QT_NO_FONTDIALOG
-# define QT_NO_FONTDIALOG
-#endif
-#ifndef QT_NO_INPUTDIALOG
-# define QT_NO_INPUTDIALOG
-#endif
-#ifndef QT_NO_PRINTDIALOG
-# define QT_NO_PRINTDIALOG
-#endif
-#ifndef QT_NO_PROGRESSDIALOG
-# define QT_NO_PROGRESSDIALOG
-#endif
-
-/* Images */
-#ifndef QT_NO_IMAGEFORMAT_BMP
-# define QT_NO_IMAGEFORMAT_BMP
-#endif
-#ifndef QT_NO_IMAGEFORMAT_PPM
-# define QT_NO_IMAGEFORMAT_PPM
-#endif
-
-/* Internationalization */
-#ifndef QT_NO_CODECS
-# define QT_NO_CODECS
-#endif
-#ifndef QT_NO_TRANSLATION
-# define QT_NO_TRANSLATION
-#endif
-
-/* ItemViews */
-#ifndef QT_NO_TABLEVIEW
-# define QT_NO_TABLEVIEW
-#endif
-#ifndef QT_NO_TREEVIEW
-# define QT_NO_TREEVIEW
-#endif
-
-/* Kernel */
-#ifndef QT_NO_CLIPBOARD
-# define QT_NO_CLIPBOARD
-#endif
-#ifndef QT_NO_DRAGANDDROP
-# define QT_NO_DRAGANDDROP
-#endif
-#ifndef QT_NO_EFFECTS
-# define QT_NO_EFFECTS
-#endif
-#ifndef QT_NO_PROPERTIES
-# define QT_NO_PROPERTIES
-#endif
-
-/* Networking */
-#ifndef QT_NO_HTTP
-# define QT_NO_HTTP
-#endif
-#ifndef QT_NO_UDPSOCKET
-# define QT_NO_UDPSOCKET
-#endif
-#ifndef QT_NO_FTP
-# define QT_NO_FTP
-#endif
-
-/* Painting */
-#ifndef QT_NO_COLORNAMES
-# define QT_NO_COLORNAMES
-#endif
-#ifndef QT_NO_PICTURE
-# define QT_NO_PICTURE
-#endif
-#ifndef QT_NO_PRINTER
-# define QT_NO_PRINTER
-#endif
-#ifndef QT_NO_CUPS
-# define QT_NO_CUPS
-#endif
-
-/* Styles */
-#ifndef QT_NO_STYLE_STYLESHEET
-# define QT_NO_STYLE_STYLESHEET
-#endif
-
-/* Widgets */
-#ifndef QT_NO_CALENDARWIDGET
-# define QT_NO_CALENDARWIDGET
-#endif
-#ifndef QT_NO_DATETIMEEDIT
-# define QT_NO_DATETIMEEDIT
-#endif
-#ifndef QT_NO_DIAL
-# define QT_NO_DIAL
-#endif
-#ifndef QT_NO_TABLEWIDGET
-# define QT_NO_TABLEWIDGET
-#endif
-#ifndef QT_NO_TREEWIDGET
-# define QT_NO_TREEWIDGET
-#endif
diff --git a/src/corelib/global/qconfig-medium.h b/src/corelib/global/qconfig-medium.h
deleted file mode 100644
index 830e936924..0000000000
--- a/src/corelib/global/qconfig-medium.h
+++ /dev/null
@@ -1,241 +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$
-**
-****************************************************************************/
-
-/* Dialogs */
-#ifndef QT_NO_COLORDIALOG
-# define QT_NO_COLORDIALOG
-#endif
-#ifndef QT_NO_FILEDIALOG
-# define QT_NO_FILEDIALOG
-#endif
-#ifndef QT_NO_FONTDIALOG
-# define QT_NO_FONTDIALOG
-#endif
-#ifndef QT_NO_INPUTDIALOG
-# define QT_NO_INPUTDIALOG
-#endif
-#ifndef QT_NO_PRINTDIALOG
-# define QT_NO_PRINTDIALOG
-#endif
-#ifndef QT_NO_PROGRESSDIALOG
-# define QT_NO_PROGRESSDIALOG
-#endif
-
-/* Images */
-#ifndef QT_NO_IMAGEFORMAT_BMP
-# define QT_NO_IMAGEFORMAT_BMP
-#endif
-#ifndef QT_NO_IMAGEFORMAT_PPM
-# define QT_NO_IMAGEFORMAT_PPM
-#endif
-#ifndef QT_NO_MOVIE
-# define QT_NO_MOVIE
-#endif
-
-/* Internationalization */
-#ifndef QT_NO_BIG_CODECS
-# define QT_NO_BIG_CODECS
-#endif
-#ifndef QT_NO_TEXTCODEC
-# define QT_NO_TEXTCODEC
-#endif
-#ifndef QT_NO_CODECS
-# define QT_NO_CODECS
-#endif
-#ifndef QT_NO_TRANSLATION
-# define QT_NO_TRANSLATION
-#endif
-
-/* ItemViews */
-#ifndef QT_NO_TABLEVIEW
-# define QT_NO_TABLEVIEW
-#endif
-#ifndef QT_NO_TREEVIEW
-# define QT_NO_TREEVIEW
-#endif
-
-/* Kernel */
-#ifndef QT_NO_ACTION
-# define QT_NO_ACTION
-#endif
-#ifndef QT_NO_CLIPBOARD
-# define QT_NO_CLIPBOARD
-#endif
-#ifndef QT_NO_DRAGANDDROP
-# define QT_NO_DRAGANDDROP
-#endif
-#ifndef QT_NO_EFFECTS
-# define QT_NO_EFFECTS
-#endif
-#ifndef QT_NO_PROPERTIES
-# define QT_NO_PROPERTIES
-#endif
-#ifndef QT_NO_SESSIONMANAGER
-# define QT_NO_SESSIONMANAGER
-#endif
-#ifndef QT_NO_SHORTCUT
-# define QT_NO_SHORTCUT
-#endif
-#ifndef QT_NO_WHEELEVENT
-# define QT_NO_WHEELEVENT
-#endif
-
-/* Networking */
-#ifndef QT_NO_HTTP
-# define QT_NO_HTTP
-#endif
-#ifndef QT_NO_NETWORKPROXY
-# define QT_NO_NETWORKPROXY
-#endif
-#ifndef QT_NO_SOCKS5
-# define QT_NO_SOCKS5
-#endif
-#ifndef QT_NO_UDPSOCKET
-# define QT_NO_UDPSOCKET
-#endif
-#ifndef QT_NO_FTP
-# define QT_NO_FTP
-#endif
-
-/* Painting */
-#ifndef QT_NO_COLORNAMES
-# define QT_NO_COLORNAMES
-#endif
-#ifndef QT_NO_PICTURE
-# define QT_NO_PICTURE
-#endif
-#ifndef QT_NO_PRINTER
-# define QT_NO_PRINTER
-#endif
-#ifndef QT_NO_CUPS
-# define QT_NO_CUPS
-#endif
-
-/* Styles */
-#ifndef QT_NO_STYLE_STYLESHEET
-# define QT_NO_STYLE_STYLESHEET
-#endif
-
-/* Utilities */
-#ifndef QT_NO_UNDOCOMMAND
-# define QT_NO_UNDOCOMMAND
-#endif
-#ifndef QT_NO_UNDOGROUP
-# define QT_NO_UNDOGROUP
-#endif
-#ifndef QT_NO_UNDOSTACK
-# define QT_NO_UNDOSTACK
-#endif
-#ifndef QT_NO_UNDOVIEW
-# define QT_NO_UNDOVIEW
-#endif
-#ifndef QT_NO_GESTURES
-# define QT_NO_GESTURES
-#endif
-
-/* Widgets */
-#ifndef QT_NO_LCDNUMBER
-# define QT_NO_LCDNUMBER
-#endif
-#ifndef QT_NO_CALENDARWIDGET
-# define QT_NO_CALENDARWIDGET
-#endif
-#ifndef QT_NO_DATETIMEEDIT
-# define QT_NO_DATETIMEEDIT
-#endif
-#ifndef QT_NO_MENU
-# define QT_NO_MENU
-#endif
-#ifndef QT_NO_CONTEXTMENU
-# define QT_NO_CONTEXTMENU
-#endif
-#ifndef QT_NO_MAINWINDOW
-# define QT_NO_MAINWINDOW
-#endif
-#ifndef QT_NO_DOCKWIDGET
-# define QT_NO_DOCKWIDGET
-#endif
-#ifndef QT_NO_TOOLBAR
-# define QT_NO_TOOLBAR
-#endif
-#ifndef QT_NO_MENUBAR
-# define QT_NO_MENUBAR
-#endif
-#ifndef QT_NO_PROGRESSBAR
-# define QT_NO_PROGRESSBAR
-#endif
-#ifndef QT_NO_SIZEGRIP
-# define QT_NO_SIZEGRIP
-#endif
-#ifndef QT_NO_DIAL
-# define QT_NO_DIAL
-#endif
-#ifndef QT_NO_STACKEDWIDGET
-# define QT_NO_STACKEDWIDGET
-#endif
-#ifndef QT_NO_TABWIDGET
-# define QT_NO_TABWIDGET
-#endif
-#ifndef QT_NO_STATUSBAR
-# define QT_NO_STATUSBAR
-#endif
-#ifndef QT_NO_STATUSTIP
-# define QT_NO_STATUSTIP
-#endif
-#ifndef QT_NO_TABLEWIDGET
-# define QT_NO_TABLEWIDGET
-#endif
-#ifndef QT_NO_TOOLBUTTON
-# define QT_NO_TOOLBUTTON
-#endif
-#ifndef QT_NO_TABBAR
-# define QT_NO_TABBAR
-#endif
-#ifndef QT_NO_TOOLBOX
-# define QT_NO_TOOLBOX
-#endif
-#ifndef QT_NO_WHATSTHIS
-# define QT_NO_WHATSTHIS
-#endif
-#ifndef QT_NO_TOOLTIP
-# define QT_NO_TOOLTIP
-#endif
-#ifndef QT_NO_TREEWIDGET
-# define QT_NO_TREEWIDGET
-#endif
diff --git a/src/corelib/global/qconfig-minimal.h b/src/corelib/global/qconfig-minimal.h
deleted file mode 100644
index 305655b1c9..0000000000
--- a/src/corelib/global/qconfig-minimal.h
+++ /dev/null
@@ -1,463 +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$
-**
-****************************************************************************/
-
-/* Data structures */
-#ifndef QT_NO_TEXTDATE
-# define QT_NO_TEXTDATE
-#endif
-#ifndef QT_NO_DATESTRING
-# define QT_NO_DATESTRING
-#endif
-
-/* Dialogs */
-#ifndef QT_NO_COLORDIALOG
-# define QT_NO_COLORDIALOG
-#endif
-#ifndef QT_NO_ERRORMESSAGE
-# define QT_NO_ERRORMESSAGE
-#endif
-#ifndef QT_NO_FILEDIALOG
-# define QT_NO_FILEDIALOG
-#endif
-#ifndef QT_NO_FONTDIALOG
-# define QT_NO_FONTDIALOG
-#endif
-#ifndef QT_NO_INPUTDIALOG
-# define QT_NO_INPUTDIALOG
-#endif
-#ifndef QT_NO_MESSAGEBOX
-# define QT_NO_MESSAGEBOX
-#endif
-#ifndef QT_NO_PRINTDIALOG
-# define QT_NO_PRINTDIALOG
-#endif
-#ifndef QT_NO_PRINTPREVIEWDIALOG
-# define QT_NO_PRINTPREVIEWDIALOG
-#endif
-#ifndef QT_NO_PROGRESSDIALOG
-# define QT_NO_PROGRESSDIALOG
-#endif
-#ifndef QT_NO_WIZARD
-# define QT_NO_WIZARD
-#endif
-
-/* File I/O */
-#ifndef QT_NO_DOM
-# define QT_NO_DOM
-#endif
-#ifndef QT_NO_FILESYSTEMWATCHER
-# define QT_NO_FILESYSTEMWATCHER
-#endif
-#ifndef QT_NO_FILESYSTEMMODEL
-# define QT_NO_FILESYSTEMMODEL
-#endif
-#ifndef QT_NO_PROCESS
-# define QT_NO_PROCESS
-#endif
-#ifndef QT_NO_TEMPORARYFILE
-# define QT_NO_TEMPORARYFILE
-#endif
-#ifndef QT_NO_SETTINGS
-# define QT_NO_SETTINGS
-#endif
-#ifndef QT_NO_LIBRARY
-# define QT_NO_LIBRARY
-#endif
-
-/* Fonts */
-#ifndef QT_NO_FREETYPE
-# define QT_NO_FREETYPE
-#endif
-
-/* Images */
-#ifndef QT_NO_IMAGEFORMATPLUGIN
-# define QT_NO_IMAGEFORMATPLUGIN
-#endif
-#ifndef QT_NO_IMAGEFORMAT_BMP
-# define QT_NO_IMAGEFORMAT_BMP
-#endif
-#ifndef QT_NO_IMAGEFORMAT_JPEG
-# define QT_NO_IMAGEFORMAT_JPEG
-#endif
-#ifndef QT_NO_IMAGEFORMAT_PNG
-# define QT_NO_IMAGEFORMAT_PNG
-#endif
-#ifndef QT_NO_IMAGEFORMAT_PPM
-# define QT_NO_IMAGEFORMAT_PPM
-#endif
-#ifndef QT_NO_IMAGEFORMAT_XBM
-# define QT_NO_IMAGEFORMAT_XBM
-#endif
-#ifndef QT_NO_IMAGEFORMAT_XPM
-# define QT_NO_IMAGEFORMAT_XPM
-#endif
-#ifndef QT_NO_IMAGE_HEURISTIC_MASK
-# define QT_NO_IMAGE_HEURISTIC_MASK
-#endif
-#ifndef QT_NO_MOVIE
-# define QT_NO_MOVIE
-#endif
-
-/* Internationalization */
-#ifndef QT_NO_BIG_CODECS
-# define QT_NO_BIG_CODECS
-#endif
-#ifndef QT_NO_TEXTCODEC
-# define QT_NO_TEXTCODEC
-#endif
-#ifndef QT_NO_CODECS
-# define QT_NO_CODECS
-#endif
-#ifndef QT_NO_TRANSLATION
-# define QT_NO_TRANSLATION
-#endif
-
-/* ItemViews */
-#ifndef QT_NO_ITEMVIEWS
-# define QT_NO_ITEMVIEWS
-#endif
-#ifndef QT_NO_DATAWIDGETMAPPER
-# define QT_NO_DATAWIDGETMAPPER
-#endif
-#ifndef QT_NO_DIRMODEL
-# define QT_NO_DIRMODEL
-#endif
-#ifndef QT_NO_LISTVIEW
-# define QT_NO_LISTVIEW
-#endif
-#ifndef QT_NO_COLUMNVIEW
-# define QT_NO_COLUMNVIEW
-#endif
-#ifndef QT_NO_PROXYMODEL
-# define QT_NO_PROXYMODEL
-#endif
-#ifndef QT_NO_SORTFILTERPROXYMODEL
-# define QT_NO_SORTFILTERPROXYMODEL
-#endif
-#ifndef QT_NO_STANDARDITEMMODEL
-# define QT_NO_STANDARDITEMMODEL
-#endif
-#ifndef QT_NO_STRINGLISTMODEL
-# define QT_NO_STRINGLISTMODEL
-#endif
-#ifndef QT_NO_TABLEVIEW
-# define QT_NO_TABLEVIEW
-#endif
-#ifndef QT_NO_TREEVIEW
-# define QT_NO_TREEVIEW
-#endif
-
-/* Kernel */
-#ifndef QT_NO_ACTION
-# define QT_NO_ACTION
-#endif
-#ifndef QT_NO_CLIPBOARD
-# define QT_NO_CLIPBOARD
-#endif
-#ifndef QT_NO_CSSPARSER
-# define QT_NO_CSSPARSER
-#endif
-#ifndef QT_NO_CURSOR
-# define QT_NO_CURSOR
-#endif
-#ifndef QT_NO_DRAGANDDROP
-# define QT_NO_DRAGANDDROP
-#endif
-#ifndef QT_NO_EFFECTS
-# define QT_NO_EFFECTS
-#endif
-#ifndef QT_NO_PROPERTIES
-# define QT_NO_PROPERTIES
-#endif
-#ifndef QT_NO_SESSIONMANAGER
-# define QT_NO_SESSIONMANAGER
-#endif
-#ifndef QT_NO_SHAREDMEMORY
-# define QT_NO_SHAREDMEMORY
-#endif
-#ifndef QT_NO_SHORTCUT
-# define QT_NO_SHORTCUT
-#endif
-#ifndef QT_NO_SYSTEMSEMAPHORE
-# define QT_NO_SYSTEMSEMAPHORE
-#endif
-#ifndef QT_NO_TABLETEVENT
-# define QT_NO_TABLETEVENT
-#endif
-#ifndef QT_NO_TEXTHTMLPARSER
-# define QT_NO_TEXTHTMLPARSER
-#endif
-#ifndef QT_NO_CONCURRENT
-# define QT_NO_CONCURRENT
-#endif
-#ifndef QT_NO_WHEELEVENT
-# define QT_NO_WHEELEVENT
-#endif
-#ifndef QT_NO_XMLSTREAM
-# define QT_NO_XMLSTREAM
-#endif
-#ifndef QT_NO_XMLSTREAMREADER
-# define QT_NO_XMLSTREAMREADER
-#endif
-#ifndef QT_NO_XMLSTREAMWRITER
-# define QT_NO_XMLSTREAMWRITER
-#endif
-
-/* Networking */
-#ifndef QT_NO_HTTP
-# define QT_NO_HTTP
-#endif
-#ifndef QT_NO_NETWORKPROXY
-# define QT_NO_NETWORKPROXY
-#endif
-#ifndef QT_NO_SOCKS5
-# define QT_NO_SOCKS5
-#endif
-#ifndef QT_NO_UDPSOCKET
-# define QT_NO_UDPSOCKET
-#endif
-#ifndef QT_NO_FTP
-# define QT_NO_FTP
-#endif
-
-/* Painting */
-#ifndef QT_NO_COLORNAMES
-# define QT_NO_COLORNAMES
-#endif
-#ifndef QT_NO_PAINT_DEBUG
-# define QT_NO_PAINT_DEBUG
-#endif
-#ifndef QT_NO_PICTURE
-# define QT_NO_PICTURE
-#endif
-#ifndef QT_NO_PRINTER
-# define QT_NO_PRINTER
-#endif
-#ifndef QT_NO_CUPS
-# define QT_NO_CUPS
-#endif
-
-/* Styles */
-#ifndef QT_NO_STYLE_FUSION
-# define QT_NO_STYLE_FUSION
-#endif
-#ifndef QT_NO_STYLE_STYLESHEET
-# define QT_NO_STYLE_STYLESHEET
-#endif
-#ifndef QT_NO_STYLE_WINDOWSCE
-# define QT_NO_STYLE_WINDOWSCE
-#endif
-#ifndef QT_NO_STYLE_WINDOWSMOBILE
-# define QT_NO_STYLE_WINDOWSMOBILE
-#endif
-#ifndef QT_NO_STYLE_WINDOWSVISTA
-# define QT_NO_STYLE_WINDOWSVISTA
-#endif
-#ifndef QT_NO_STYLE_WINDOWSXP
-# define QT_NO_STYLE_WINDOWSXP
-#endif
-
-/* Utilities */
-#ifndef QT_NO_ACCESSIBILITY
-# define QT_NO_ACCESSIBILITY
-#endif
-#ifndef QT_NO_COMPLETER
-# define QT_NO_COMPLETER
-#endif
-#ifndef QT_NO_DESKTOPSERVICES
-# define QT_NO_DESKTOPSERVICES
-#endif
-#ifndef QT_NO_MIMETYPE
-# define QT_NO_MIMETYPE
-#endif
-#ifndef QT_NO_SYSTEMTRAYICON
-# define QT_NO_SYSTEMTRAYICON
-#endif
-#ifndef QT_NO_UNDOCOMMAND
-# define QT_NO_UNDOCOMMAND
-#endif
-#ifndef QT_NO_UNDOGROUP
-# define QT_NO_UNDOGROUP
-#endif
-#ifndef QT_NO_UNDOSTACK
-# define QT_NO_UNDOSTACK
-#endif
-#ifndef QT_NO_UNDOVIEW
-# define QT_NO_UNDOVIEW
-#endif
-#ifndef QT_NO_GESTURES
-# define QT_NO_GESTURES
-#endif
-
-/* Widgets */
-#ifndef QT_NO_GROUPBOX
-# define QT_NO_GROUPBOX
-#endif
-#ifndef QT_NO_BUTTONGROUP
-# define QT_NO_BUTTONGROUP
-#endif
-#ifndef QT_NO_LCDNUMBER
-# define QT_NO_LCDNUMBER
-#endif
-#ifndef QT_NO_LINEEDIT
-# define QT_NO_LINEEDIT
-#endif
-#ifndef QT_NO_COMBOBOX
-# define QT_NO_COMBOBOX
-#endif
-#ifndef QT_NO_FONTCOMBOBOX
-# define QT_NO_FONTCOMBOBOX
-#endif
-#ifndef QT_NO_SPINBOX
-# define QT_NO_SPINBOX
-#endif
-#ifndef QT_NO_CALENDARWIDGET
-# define QT_NO_CALENDARWIDGET
-#endif
-#ifndef QT_NO_DATETIMEEDIT
-# define QT_NO_DATETIMEEDIT
-#endif
-#ifndef QT_NO_LISTWIDGET
-# define QT_NO_LISTWIDGET
-#endif
-#ifndef QT_NO_MENU
-# define QT_NO_MENU
-#endif
-#ifndef QT_NO_CONTEXTMENU
-# define QT_NO_CONTEXTMENU
-#endif
-#ifndef QT_NO_MAINWINDOW
-# define QT_NO_MAINWINDOW
-#endif
-#ifndef QT_NO_DOCKWIDGET
-# define QT_NO_DOCKWIDGET
-#endif
-#ifndef QT_NO_TOOLBAR
-# define QT_NO_TOOLBAR
-#endif
-#ifndef QT_NO_MENUBAR
-# define QT_NO_MENUBAR
-#endif
-#ifndef QT_NO_PROGRESSBAR
-# define QT_NO_PROGRESSBAR
-#endif
-#ifndef QT_NO_RESIZEHANDLER
-# define QT_NO_RESIZEHANDLER
-#endif
-#ifndef QT_NO_RUBBERBAND
-# define QT_NO_RUBBERBAND
-#endif
-#ifndef QT_NO_SPLITTER
-# define QT_NO_SPLITTER
-#endif
-#ifndef QT_NO_SIZEGRIP
-# define QT_NO_SIZEGRIP
-#endif
-#ifndef QT_NO_SLIDER
-# define QT_NO_SLIDER
-#endif
-#ifndef QT_NO_DIAL
-# define QT_NO_DIAL
-#endif
-#ifndef QT_NO_SCROLLBAR
-# define QT_NO_SCROLLBAR
-#endif
-#ifndef QT_NO_SCROLLAREA
-# define QT_NO_SCROLLAREA
-#endif
-#ifndef QT_NO_GRAPHICSVIEW
-# define QT_NO_GRAPHICSVIEW
-#endif
-#ifndef QT_NO_PRINTPREVIEWWIDGET
-# define QT_NO_PRINTPREVIEWWIDGET
-#endif
-#ifndef QT_NO_MDIAREA
-# define QT_NO_MDIAREA
-#endif
-#ifndef QT_NO_TEXTEDIT
-# define QT_NO_TEXTEDIT
-#endif
-#ifndef QT_NO_SYNTAXHIGHLIGHTER
-# define QT_NO_SYNTAXHIGHLIGHTER
-#endif
-#ifndef QT_NO_TEXTBROWSER
-# define QT_NO_TEXTBROWSER
-#endif
-#ifndef QT_NO_SPINWIDGET
-# define QT_NO_SPINWIDGET
-#endif
-#ifndef QT_NO_SPLASHSCREEN
-# define QT_NO_SPLASHSCREEN
-#endif
-#ifndef QT_NO_STACKEDWIDGET
-# define QT_NO_STACKEDWIDGET
-#endif
-#ifndef QT_NO_TABWIDGET
-# define QT_NO_TABWIDGET
-#endif
-#ifndef QT_NO_STATUSBAR
-# define QT_NO_STATUSBAR
-#endif
-#ifndef QT_NO_STATUSTIP
-# define QT_NO_STATUSTIP
-#endif
-#ifndef QT_NO_TABLEWIDGET
-# define QT_NO_TABLEWIDGET
-#endif
-#ifndef QT_NO_TOOLBUTTON
-# define QT_NO_TOOLBUTTON
-#endif
-#ifndef QT_NO_TABBAR
-# define QT_NO_TABBAR
-#endif
-#ifndef QT_NO_TOOLBOX
-# define QT_NO_TOOLBOX
-#endif
-#ifndef QT_NO_WHATSTHIS
-# define QT_NO_WHATSTHIS
-#endif
-#ifndef QT_NO_TOOLTIP
-# define QT_NO_TOOLTIP
-#endif
-#ifndef QT_NO_TREEWIDGET
-# define QT_NO_TREEWIDGET
-#endif
-#ifndef QT_NO_VALIDATOR
-# define QT_NO_VALIDATOR
-#endif
diff --git a/src/corelib/global/qconfig-nacl.h b/src/corelib/global/qconfig-nacl.h
deleted file mode 100644
index 10292c05c3..0000000000
--- a/src/corelib/global/qconfig-nacl.h
+++ /dev/null
@@ -1,233 +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$
-**
-****************************************************************************/
-
-#if 0
-#pragma qt_sync_stop_processing
-#endif
-
-#define QT_FONTS_ARE_RESOURCES
-
-/* Data structures */
-#ifndef QT_NO_TEXTDATE
-# define QT_NO_TEXTDATE
-#endif
-#ifndef QT_NO_DATESTRING
-# define QT_NO_DATESTRING
-#endif
-
-/* Dialogs */
-#ifndef QT_NO_FILEDIALOG
-# define QT_NO_FILEDIALOG
-#endif
-#ifndef QT_NO_PRINTDIALOG
-# define QT_NO_PRINTDIALOG
-#endif
-#ifndef QT_NO_PRINTPREVIEWDIALOG
-# define QT_NO_PRINTPREVIEWDIALOG
-#endif
-
-
-/* File I/O */
-#ifndef QT_NO_DOM
-# define QT_NO_DOM
-#endif
-#ifndef QT_NO_FILESYSTEMWATCHER
-# define QT_NO_FILESYSTEMWATCHER
-#endif
-#ifndef QT_NO_FILESYSTEMMODEL
-# define QT_NO_FILESYSTEMMODEL
-#endif
-#ifndef QT_NO_FILESYSTEMMODEL
-# define QT_NO_FILESYSTEMMODEL
-#endif
-#ifndef QT_NO_PROCESS
-# define QT_NO_PROCESS
-#endif
-#ifndef QT_NO_TEMPORARYFILE
-# define QT_NO_TEMPORARYFILE
-#endif
-#ifndef QT_NO_SETTINGS
-# define QT_NO_SETTINGS
-#endif
-#ifndef QT_NO_LIBRARY
-# define QT_NO_LIBRARY
-#endif
-
-/* Images */
-#ifndef QT_NO_IMAGEFORMATPLUGIN
-# define QT_NO_IMAGEFORMATPLUGIN
-#endif
-#ifndef QT_NO_IMAGE_HEURISTIC_MASK
-# define QT_NO_IMAGE_HEURISTIC_MASK
-#endif
-#ifndef QT_NO_MOVIE
-# define QT_NO_MOVIE
-#endif
-
-/* Internationalization */
-#ifndef QT_NO_BIG_CODECS
-# define QT_NO_BIG_CODECS
-#endif
-#ifndef QT_NO_TEXTCODEC
-# define QT_NO_TEXTCODEC
-#endif
-#ifndef QT_NO_CODECS
-# define QT_NO_CODECS
-#endif
-#ifndef QT_NO_TRANSLATION
-# define QT_NO_TRANSLATION
-#endif
-
-/* ItemViews */
-
-#ifndef QT_NO_DIRMODEL
-# define QT_NO_DIRMODEL
-#endif
-
-/* Kernel */
-#ifndef QT_NO_CLIPBOARD
-# define QT_NO_CLIPBOARD
-#endif
-#ifndef QT_NO_CSSPARSER
-# define QT_NO_CSSPARSER
-#endif
-#ifndef QT_NO_CURSOR
-# define QT_NO_CURSOR
-#endif
-#ifndef QT_NO_DRAGANDDROP
-# define QT_NO_DRAGANDDROP
-#endif
-#ifndef QT_NO_EFFECTS
-# define QT_NO_EFFECTS
-#endif
-#ifndef QT_NO_SESSIONMANAGER
-# define QT_NO_SESSIONMANAGER
-#endif
-#ifndef QT_NO_SHAREDMEMORY
-# define QT_NO_SHAREDMEMORY
-#endif
-#ifndef QT_NO_SYSTEMLOCALE
-# define QT_NO_SYSTEMSEMAPHORE
-#endif
-#ifndef QT_NO_SYSTEMSEMAPHORE
-# define QT_NO_SYSTEMSEMAPHORE
-#endif
-#ifndef QT_NO_TABLETEVENT
-# define QT_NO_TABLETEVENT
-#endif
-#ifndef QT_NO_CRASHHANDLER
-# define QT_NO_CRASHHANDLER
-#endif
-#ifndef QT_NO_CONCURRENT
-# define QT_NO_CONCURRENT
-#endif
-#ifndef QT_NO_XMLSTREAM
-# define QT_NO_XMLSTREAM
-#endif
-#ifndef QT_NO_XMLSTREAMREADER
-# define QT_NO_XMLSTREAMREADER
-#endif
-#ifndef QT_NO_XMLSTREAMWRITER
-# define QT_NO_XMLSTREAMWRITER
-#endif
-
-/* Networking */
-#ifndef QT_NO_HTTP
-# define QT_NO_HTTP
-#endif
-#ifndef QT_NO_NETWORKPROXY
-# define QT_NO_NETWORKPROXY
-#endif
-#ifndef QT_NO_SOCKS5
-# define QT_NO_SOCKS5
-#endif
-#ifndef QT_NO_UDPSOCKET
-# define QT_NO_UDPSOCKET
-#endif
-#ifndef QT_NO_FTP
-# define QT_NO_FTP
-#endif
-
-/* Painting */
-#ifndef QT_NO_COLORNAMES
-# define QT_NO_COLORNAMES
-#endif
-#ifndef QT_NO_PAINT_DEBUG
-# define QT_NO_PAINT_DEBUG
-#endif
-#ifndef QT_NO_PICTURE
-# define QT_NO_PICTURE
-#endif
-#ifndef QT_NO_PRINTER
-# define QT_NO_PRINTER
-#endif
-#ifndef QT_NO_CUPS
-# define QT_NO_CUPS
-#endif
-
-/* Styles */
-#ifndef QT_NO_STYLE_STYLESHEET
-# define QT_NO_STYLE_STYLESHEET
-#endif
-#ifndef QT_NO_STYLE_WINDOWSCE
-# define QT_NO_STYLE_WINDOWSCE
-#endif
-#ifndef QT_NO_STYLE_WINDOWSMOBILE
-# define QT_NO_STYLE_WINDOWSMOBILE
-#endif
-#ifndef QT_NO_STYLE_WINDOWSVISTA
-# define QT_NO_STYLE_WINDOWSVISTA
-#endif
-#ifndef QT_NO_STYLE_WINDOWSXP
-# define QT_NO_STYLE_WINDOWSXP
-#endif
-
-/* Utilities */
-#ifndef QT_NO_ACCESSIBILITY
-# define QT_NO_ACCESSIBILITY
-#endif
-#ifndef QT_NO_COMPLETER
-# define QT_NO_COMPLETER
-#endif
-#ifndef QT_NO_DESKTOPSERVICES
-# define QT_NO_DESKTOPSERVICES
-#endif
-#ifndef QT_NO_SYSTEMTRAYICON
-# define QT_NO_SYSTEMTRAYICON
-#endif
diff --git a/src/corelib/global/qconfig-small.h b/src/corelib/global/qconfig-small.h
deleted file mode 100644
index 1f1bff91a3..0000000000
--- a/src/corelib/global/qconfig-small.h
+++ /dev/null
@@ -1,281 +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$
-**
-****************************************************************************/
-
-/* Dialogs */
-#ifndef QT_NO_COLORDIALOG
-# define QT_NO_COLORDIALOG
-#endif
-#ifndef QT_NO_ERRORMESSAGE
-# define QT_NO_ERRORMESSAGE
-#endif
-#ifndef QT_NO_FILEDIALOG
-# define QT_NO_FILEDIALOG
-#endif
-#ifndef QT_NO_FONTDIALOG
-# define QT_NO_FONTDIALOG
-#endif
-#ifndef QT_NO_INPUTDIALOG
-# define QT_NO_INPUTDIALOG
-#endif
-#ifndef QT_NO_MESSAGEBOX
-# define QT_NO_MESSAGEBOX
-#endif
-#ifndef QT_NO_PRINTDIALOG
-# define QT_NO_PRINTDIALOG
-#endif
-#ifndef QT_NO_PROGRESSDIALOG
-# define QT_NO_PROGRESSDIALOG
-#endif
-
-/* File I/O */
-#ifndef QT_NO_SETTINGS
-# define QT_NO_SETTINGS
-#endif
-#ifndef QT_NO_LIBRARY
-# define QT_NO_LIBRARY
-#endif
-
-/* Fonts */
-#ifndef QT_NO_FREETYPE
-# define QT_NO_FREETYPE
-#endif
-
-/* Images */
-#ifndef QT_NO_IMAGEFORMATPLUGIN
-# define QT_NO_IMAGEFORMATPLUGIN
-#endif
-#ifndef QT_NO_IMAGEFORMAT_BMP
-# define QT_NO_IMAGEFORMAT_BMP
-#endif
-#ifndef QT_NO_IMAGEFORMAT_JPEG
-# define QT_NO_IMAGEFORMAT_JPEG
-#endif
-#ifndef QT_NO_IMAGEFORMAT_PPM
-# define QT_NO_IMAGEFORMAT_PPM
-#endif
-#ifndef QT_NO_IMAGEFORMAT_XBM
-# define QT_NO_IMAGEFORMAT_XBM
-#endif
-#ifndef QT_NO_IMAGEFORMAT_XPM
-# define QT_NO_IMAGEFORMAT_XPM
-#endif
-#ifndef QT_NO_MOVIE
-# define QT_NO_MOVIE
-#endif
-
-/* Internationalization */
-#ifndef QT_NO_TEXTCODEC
-# define QT_NO_TEXTCODEC
-#endif
-#ifndef QT_NO_CODECS
-# define QT_NO_CODECS
-#endif
-#ifndef QT_NO_TRANSLATION
-# define QT_NO_TRANSLATION
-#endif
-
-/* ItemViews */
-#ifndef QT_NO_DIRMODEL
-# define QT_NO_DIRMODEL
-#endif
-#ifndef QT_NO_PROXYMODEL
-# define QT_NO_PROXYMODEL
-#endif
-#ifndef QT_NO_SORTFILTERPROXYMODEL
-# define QT_NO_SORTFILTERPROXYMODEL
-#endif
-#ifndef QT_NO_STRINGLISTMODEL
-# define QT_NO_STRINGLISTMODEL
-#endif
-#ifndef QT_NO_TABLEVIEW
-# define QT_NO_TABLEVIEW
-#endif
-#ifndef QT_NO_TREEVIEW
-# define QT_NO_TREEVIEW
-#endif
-
-/* Kernel */
-#ifndef QT_NO_ACTION
-# define QT_NO_ACTION
-#endif
-#ifndef QT_NO_CLIPBOARD
-# define QT_NO_CLIPBOARD
-#endif
-#ifndef QT_NO_DRAGANDDROP
-# define QT_NO_DRAGANDDROP
-#endif
-#ifndef QT_NO_EFFECTS
-# define QT_NO_EFFECTS
-#endif
-#ifndef QT_NO_PROPERTIES
-# define QT_NO_PROPERTIES
-#endif
-#ifndef QT_NO_SESSIONMANAGER
-# define QT_NO_SESSIONMANAGER
-#endif
-#ifndef QT_NO_SHORTCUT
-# define QT_NO_SHORTCUT
-#endif
-#ifndef QT_NO_WHEELEVENT
-# define QT_NO_WHEELEVENT
-#endif
-
-/* Networking */
-#ifndef QT_NO_HTTP
-# define QT_NO_HTTP
-#endif
-
-/* Painting */
-#ifndef QT_NO_COLORNAMES
-# define QT_NO_COLORNAMES
-#endif
-#ifndef QT_NO_PICTURE
-# define QT_NO_PICTURE
-#endif
-#ifndef QT_NO_PRINTER
-# define QT_NO_PRINTER
-#endif
-#ifndef QT_NO_CUPS
-# define QT_NO_CUPS
-#endif
-
-/* Styles */
-#ifndef QT_NO_STYLE_FUSION
-# define QT_NO_STYLE_FUSION
-#endif
-#ifndef QT_NO_STYLE_STYLESHEET
-# define QT_NO_STYLE_STYLESHEET
-#endif
-#ifndef QT_NO_STYLE_WINDOWSVISTA
-# define QT_NO_STYLE_WINDOWSVISTA
-#endif
-
-/* Utilities */
-#ifndef QT_NO_COMPLETER
-# define QT_NO_COMPLETER
-#endif
-#ifndef QT_NO_DESKTOPSERVICES
-# define QT_NO_DESKTOPSERVICES
-#endif
-#ifndef QT_NO_MIMETYPE
-# define QT_NO_MIMETYPE
-#endif
-#ifndef QT_NO_SYSTEMTRAYICON
-# define QT_NO_SYSTEMTRAYICON
-#endif
-#ifndef QT_NO_GESTURES
-# define QT_NO_GESTURES
-#endif
-
-/* Widgets */
-#ifndef QT_NO_LCDNUMBER
-# define QT_NO_LCDNUMBER
-#endif
-#ifndef QT_NO_FONTCOMBOBOX
-# define QT_NO_FONTCOMBOBOX
-#endif
-#ifndef QT_NO_SPINBOX
-# define QT_NO_SPINBOX
-#endif
-#ifndef QT_NO_CALENDARWIDGET
-# define QT_NO_CALENDARWIDGET
-#endif
-#ifndef QT_NO_DATETIMEEDIT
-# define QT_NO_DATETIMEEDIT
-#endif
-#ifndef QT_NO_MENU
-# define QT_NO_MENU
-#endif
-#ifndef QT_NO_CONTEXTMENU
-# define QT_NO_CONTEXTMENU
-#endif
-#ifndef QT_NO_MAINWINDOW
-# define QT_NO_MAINWINDOW
-#endif
-#ifndef QT_NO_DOCKWIDGET
-# define QT_NO_DOCKWIDGET
-#endif
-#ifndef QT_NO_TOOLBAR
-# define QT_NO_TOOLBAR
-#endif
-#ifndef QT_NO_MENUBAR
-# define QT_NO_MENUBAR
-#endif
-#ifndef QT_NO_PROGRESSBAR
-# define QT_NO_PROGRESSBAR
-#endif
-#ifndef QT_NO_SPLITTER
-# define QT_NO_SPLITTER
-#endif
-#ifndef QT_NO_SIZEGRIP
-# define QT_NO_SIZEGRIP
-#endif
-#ifndef QT_NO_STACKEDWIDGET
-# define QT_NO_STACKEDWIDGET
-#endif
-#ifndef QT_NO_TABWIDGET
-# define QT_NO_TABWIDGET
-#endif
-#ifndef QT_NO_STATUSBAR
-# define QT_NO_STATUSBAR
-#endif
-#ifndef QT_NO_TABLEWIDGET
-# define QT_NO_TABLEWIDGET
-#endif
-#ifndef QT_NO_TOOLBUTTON
-# define QT_NO_TOOLBUTTON
-#endif
-#ifndef QT_NO_TABBAR
-# define QT_NO_TABBAR
-#endif
-#ifndef QT_NO_TOOLBOX
-# define QT_NO_TOOLBOX
-#endif
-#ifndef QT_NO_WHATSTHIS
-# define QT_NO_WHATSTHIS
-#endif
-#ifndef QT_NO_TOOLTIP
-# define QT_NO_TOOLTIP
-#endif
-#ifndef QT_NO_TREEWIDGET
-# define QT_NO_TREEWIDGET
-#endif
-#ifndef QT_NO_VALIDATOR
-# define QT_NO_VALIDATOR
-#endif
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h
index b907caa9b6..a6bd37c33f 100644
--- a/src/corelib/global/qflags.h
+++ b/src/corelib/global/qflags.h
@@ -111,8 +111,8 @@ public:
typedef Enum enum_type;
// compiler-generated copy/move ctor/assignment operators are fine!
#ifdef Q_QDOC
- inline QFlags(const QFlags &other);
- inline QFlags &operator=(const QFlags &other);
+ Q_DECL_CONSTEXPR inline QFlags(const QFlags &other);
+ Q_DECL_CONSTEXPR inline QFlags &operator=(const QFlags &other);
#endif
Q_DECL_CONSTEXPR inline QFlags(Enum f) Q_DECL_NOTHROW : i(Int(f)) {}
Q_DECL_CONSTEXPR inline QFlags(Zero = Q_NULLPTR) Q_DECL_NOTHROW : i(0) {}
@@ -163,8 +163,10 @@ private:
Int i;
};
+#ifndef Q_MOC_RUN
#define Q_DECLARE_FLAGS(Flags, Enum)\
typedef QFlags<Enum> Flags;
+#endif
#define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \
Q_DECL_CONSTEXPR inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) Q_DECL_NOTHROW \
@@ -179,8 +181,11 @@ Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1,
#else /* Q_NO_TYPESAFE_FLAGS */
+#ifndef Q_MOC_RUN
#define Q_DECLARE_FLAGS(Flags, Enum)\
typedef uint Flags;
+#endif
+
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
#endif /* Q_NO_TYPESAFE_FLAGS */
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 6ca2ecff91..3eaec11008 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -47,7 +47,6 @@
#include "qdatetime.h"
#include <private/qlocale_tools_p.h>
-#include <private/qsystemlibrary_p.h>
#include <qmutex.h>
#ifndef QT_NO_QOBJECT
@@ -64,11 +63,9 @@
# include <exception>
#endif
-#if !defined(Q_OS_WINCE)
-# include <errno.h>
-# if defined(Q_CC_MSVC)
-# include <crtdbg.h>
-# endif
+#include <errno.h>
+#if defined(Q_CC_MSVC)
+# include <crtdbg.h>
#endif
#ifdef Q_OS_WINRT
@@ -573,11 +570,11 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in
\snippet code/src_corelib_global_qglobal.cpp 4
The remaining functions are qRound() and qRound64(), which both
- accept a \l qreal value as their argument returning the value
- rounded up to the nearest integer and 64-bit integer respectively,
- the qInstallMessageHandler() function which installs the given
- QtMessageHandler, and the qVersion() function which returns the
- version number of Qt at run-time as a string.
+ accept a \c double or \c float value as their argument returning
+ the value rounded up to the nearest integer and 64-bit integer
+ respectively, the qInstallMessageHandler() function which installs
+ the given QtMessageHandler, and the qVersion() function which
+ returns the version number of Qt at run-time as a string.
\section1 Macros
@@ -864,24 +861,44 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in
\snippet code/src_corelib_global_qglobal.cpp 10
*/
-/*! \fn int qRound(qreal value)
+/*! \fn int qRound(double value)
+ \relates <QtGlobal>
+
+ Rounds \a value to the nearest integer.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp 11A
+*/
+
+/*! \fn int qRound(float value)
\relates <QtGlobal>
Rounds \a value to the nearest integer.
Example:
- \snippet code/src_corelib_global_qglobal.cpp 11
+ \snippet code/src_corelib_global_qglobal.cpp 11B
+*/
+
+/*! \fn qint64 qRound64(double value)
+ \relates <QtGlobal>
+
+ Rounds \a value to the nearest 64-bit integer.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp 12A
*/
-/*! \fn qint64 qRound64(qreal value)
+/*! \fn qint64 qRound64(float value)
\relates <QtGlobal>
Rounds \a value to the nearest 64-bit integer.
Example:
- \snippet code/src_corelib_global_qglobal.cpp 12
+ \snippet code/src_corelib_global_qglobal.cpp 12B
*/
/*! \fn const T &qMin(const T &value1, const T &value2)
@@ -1016,7 +1033,7 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in
example, "4.1.2"). This may be a different version than the
version the application was compiled against.
- \sa QT_VERSION_STR
+ \sa QT_VERSION_STR, QLibraryInfo::version()
*/
const char *qVersion() Q_DECL_NOTHROW
@@ -1147,19 +1164,11 @@ bool qSharedBuild() Q_DECL_NOTHROW
\value WV_6_3 Operating system version 6.3, corresponds to Windows 8.1, introduced in Qt 5.2
\value WV_10_0 Operating system version 10.0, corresponds to Windows 10, introduced in Qt 5.5
- CE-based versions:
-
- \value WV_CE Windows CE
- \value WV_CENET Windows CE .NET
- \value WV_CE_5 Windows CE 5.x
- \value WV_CE_6 Windows CE 6.x
-
The following masks can be used for testing whether a Windows
version is MS-DOS-based, NT-based, or CE-based:
\value WV_DOS_based MS-DOS-based version of Windows
\value WV_NT_based NT-based version of Windows
- \value WV_CE_based CE-based version of Windows
\value WV_None Operating system other than Windows.
@@ -1262,7 +1271,7 @@ bool qSharedBuild() Q_DECL_NOTHROW
\relates <QtGlobal>
Defined on all supported versions of Windows. That is, if
- \l Q_OS_WIN32, \l Q_OS_WIN64, \l Q_OS_WINCE or \l Q_OS_WINRT is defined.
+ \l Q_OS_WIN32, \l Q_OS_WIN64 or \l Q_OS_WINRT is defined.
*/
/*!
@@ -1280,13 +1289,6 @@ bool qSharedBuild() Q_DECL_NOTHROW
*/
/*!
- \macro Q_OS_WINCE
- \relates <QtGlobal>
-
- Defined on Windows CE.
-*/
-
-/*!
\macro Q_OS_WINRT
\relates <QtGlobal>
@@ -1916,13 +1918,33 @@ QSysInfo::MacVersion QSysInfo::macVersion()
return QSysInfo::MacVersion(Q_MV_OSX(version.major, version.minor));
#elif defined(Q_OS_IOS)
return QSysInfo::MacVersion(Q_MV_IOS(version.major, version.minor));
+#elif defined(Q_OS_TVOS)
+ return QSysInfo::MacVersion(Q_MV_TVOS(version.major, version.minor));
#else
return QSysInfo::MV_Unknown;
#endif
}
const QSysInfo::MacVersion QSysInfo::MacintoshVersion = QSysInfo::macVersion();
-#elif defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#ifdef Q_OS_OSX
+static const char *osxVer_helper(QAppleOperatingSystemVersion version = qt_apple_os_version())
+{
+ if (version.major == 10) {
+ switch (version.minor) {
+ case 9:
+ return "Mavericks";
+ case 10:
+ return "Yosemite";
+ case 11:
+ return "El Capitan";
+ }
+ }
+ // unknown, future version
+ return 0;
+}
+#endif
+
+#elif defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) || defined(Q_OS_WINRT)
QT_BEGIN_INCLUDE_NAMESPACE
#include "qt_windows.h"
@@ -1975,9 +1997,7 @@ static inline OSVERSIONINFOEX determineWinOsVersion()
{
OSVERSIONINFOEX result = { sizeof(OSVERSIONINFOEX), 0, 0, 0, 0, {'\0'}, 0, 0, 0, 0, 0};
-#ifndef Q_OS_WINCE
#define GetProcAddressA GetProcAddress
-#endif
// 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,
@@ -2026,113 +2046,66 @@ static inline OSVERSIONINFOEX determineWinOsVersion()
static OSVERSIONINFOEX winOsVersion()
{
- static OSVERSIONINFOEX result = determineWinOsVersion();
- return result;
-}
-
-QSysInfo::WinVersion QSysInfo::windowsVersion()
-{
-#ifndef VER_PLATFORM_WIN32s
-#define VER_PLATFORM_WIN32s 0
-#endif
-#ifndef VER_PLATFORM_WIN32_WINDOWS
-#define VER_PLATFORM_WIN32_WINDOWS 1
-#endif
-#ifndef VER_PLATFORM_WIN32_NT
-#define VER_PLATFORM_WIN32_NT 2
-#endif
-#ifndef VER_PLATFORM_WIN32_CE
-#define VER_PLATFORM_WIN32_CE 3
-#endif
-
- static QSysInfo::WinVersion winver;
- if (winver)
- return winver;
- winver = QSysInfo::WV_NT;
- const OSVERSIONINFOEX osver = winOsVersion();
- if (osver.dwMajorVersion == 0)
- return QSysInfo::WV_None;
-#ifdef Q_OS_WINCE
- DWORD qt_cever = 0;
- qt_cever = osver.dwMajorVersion * 100;
- qt_cever += osver.dwMinorVersion * 10;
-#endif
- switch (osver.dwPlatformId) {
- case VER_PLATFORM_WIN32s:
- winver = QSysInfo::WV_32s;
- break;
- case VER_PLATFORM_WIN32_WINDOWS:
- // We treat Windows Me (minor 90) the same as Windows 98
- if (osver.dwMinorVersion == 90)
- winver = QSysInfo::WV_Me;
- else if (osver.dwMinorVersion == 10)
- winver = QSysInfo::WV_98;
- else
- winver = QSysInfo::WV_95;
- break;
-#ifdef Q_OS_WINCE
- case VER_PLATFORM_WIN32_CE:
- if (qt_cever >= 600)
- winver = QSysInfo::WV_CE_6;
- if (qt_cever >= 500)
- winver = QSysInfo::WV_CE_5;
- else if (qt_cever >= 400)
- winver = QSysInfo::WV_CENET;
- else
- winver = QSysInfo::WV_CE;
- break;
-#endif
- default: // VER_PLATFORM_WIN32_NT
- if (osver.dwMajorVersion < 5) {
- winver = QSysInfo::WV_NT;
- } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 0) {
- winver = QSysInfo::WV_2000;
- } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 1) {
- winver = QSysInfo::WV_XP;
- } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 2) {
- winver = QSysInfo::WV_2003;
- } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 0) {
- winver = QSysInfo::WV_VISTA;
- } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 1) {
- winver = QSysInfo::WV_WINDOWS7;
- } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 2) {
- winver = QSysInfo::WV_WINDOWS8;
- } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 3) {
- winver = QSysInfo::WV_WINDOWS8_1;
- } else if (osver.dwMajorVersion == 10 && osver.dwMinorVersion == 0) {
- winver = QSysInfo::WV_WINDOWS10;
- } else {
- winver = QSysInfo::WV_NT_based;
- }
- }
-
+ OSVERSIONINFOEX realResult = determineWinOsVersion();
#ifdef QT_DEBUG
{
if (Q_UNLIKELY(qEnvironmentVariableIsSet("QT_WINVER_OVERRIDE"))) {
+ OSVERSIONINFOEX result = realResult;
+ result.dwMajorVersion = 0;
+ result.dwMinorVersion = 0;
+
+ // Erase any build number and service pack information
+ result.dwBuildNumber = 0;
+ result.szCSDVersion[0] = L'\0';
+ result.wServicePackMajor = 0;
+ result.wServicePackMinor = 0;
+
const QByteArray winVerOverride = qgetenv("QT_WINVER_OVERRIDE");
- if (winVerOverride == "NT")
- winver = QSysInfo::WV_NT;
- else if (winVerOverride == "2000")
- winver = QSysInfo::WV_2000;
- else if (winVerOverride == "2003")
- winver = QSysInfo::WV_2003;
- else if (winVerOverride == "XP")
- winver = QSysInfo::WV_XP;
- else if (winVerOverride == "VISTA")
- winver = QSysInfo::WV_VISTA;
- else if (winVerOverride == "WINDOWS7")
- winver = QSysInfo::WV_WINDOWS7;
- else if (winVerOverride == "WINDOWS8")
- winver = QSysInfo::WV_WINDOWS8;
- else if (winVerOverride == "WINDOWS8_1")
- winver = QSysInfo::WV_WINDOWS8_1;
- else if (winVerOverride == "WINDOWS10")
- winver = QSysInfo::WV_WINDOWS10;
+ if (winVerOverride == "WINDOWS7" || winVerOverride == "2008_R2") {
+ result.dwMajorVersion = 6;
+ result.dwMinorVersion = 1;
+ } else if (winVerOverride == "WINDOWS8" || winVerOverride == "2012") {
+ result.dwMajorVersion = 6;
+ result.dwMinorVersion = 2;
+ } else if (winVerOverride == "WINDOWS8_1" || winVerOverride == "2012_R2") {
+ result.dwMajorVersion = 6;
+ result.dwMinorVersion = 3;
+ } else if (winVerOverride == "WINDOWS10" || winVerOverride == "2016") {
+ result.dwMajorVersion = 10;
+ } else {
+ return realResult;
+ }
+
+ if (winVerOverride == "2008_R2"
+ || winVerOverride == "2012"
+ || winVerOverride == "2012_R2"
+ || winVerOverride == "2016") {
+ // If the current host OS is a domain controller and the override OS
+ // is also a server type OS, preserve that information
+ if (result.wProductType == VER_NT_WORKSTATION)
+ result.wProductType = VER_NT_SERVER;
+ } else {
+ // Any other OS must be a workstation OS type
+ result.wProductType = VER_NT_WORKSTATION;
+ }
}
}
#endif
+ return realResult;
+}
- return winver;
+QSysInfo::WinVersion QSysInfo::windowsVersion()
+{
+ const OSVERSIONINFOEX osver = winOsVersion();
+ if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 1)
+ return QSysInfo::WV_WINDOWS7;
+ if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 2)
+ return QSysInfo::WV_WINDOWS8;
+ if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 3)
+ return QSysInfo::WV_WINDOWS8_1;
+ if (osver.dwMajorVersion == 10 && osver.dwMinorVersion == 0)
+ return QSysInfo::WV_WINDOWS10;
+ return QSysInfo::WV_NT_based;
}
static QString winSp_helper()
@@ -2151,37 +2124,21 @@ static QString winSp_helper()
static const char *winVer_helper()
{
- const bool workstation = winOsVersion().wProductType == VER_NT_WORKSTATION;
-
- switch (int(QSysInfo::WindowsVersion)) {
- case QSysInfo::WV_NT:
- return "NT";
- case QSysInfo::WV_2000:
- return "2000";
- case QSysInfo::WV_XP:
- return "XP";
- case QSysInfo::WV_2003:
- return "2003";
- case QSysInfo::WV_VISTA:
- return workstation ? "Vista" : "Server 2008";
- case QSysInfo::WV_WINDOWS7:
+ const OSVERSIONINFOEX osver = winOsVersion();
+ const bool workstation = osver.wProductType == VER_NT_WORKSTATION;
+
+#define Q_WINVER(major, minor) (major << 8 | minor)
+ switch (Q_WINVER(osver.dwMajorVersion, osver.dwMinorVersion)) {
+ case Q_WINVER(6, 1):
return workstation ? "7" : "Server 2008 R2";
- case QSysInfo::WV_WINDOWS8:
+ case Q_WINVER(6, 2):
return workstation ? "8" : "Server 2012";
- case QSysInfo::WV_WINDOWS8_1:
+ case Q_WINVER(6, 3):
return workstation ? "8.1" : "Server 2012 R2";
- case QSysInfo::WV_WINDOWS10:
+ case Q_WINVER(10, 0):
return workstation ? "10" : "Server 2016";
-
- case QSysInfo::WV_CE:
- return "CE";
- case QSysInfo::WV_CENET:
- return "CENET";
- case QSysInfo::WV_CE_5:
- return "CE5";
- case QSysInfo::WV_CE_6:
- return "CE6";
}
+#undef Q_WINVER
// unknown, future version
return 0;
}
@@ -2438,7 +2395,7 @@ QString QSysInfo::buildCpuArchitecture()
*/
QString QSysInfo::currentCpuArchitecture()
{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
// We don't need to catch all the CPU architectures in this function;
// only those where the host CPU might be different than the build target
// (usually, 64-bit platforms).
@@ -2590,9 +2547,7 @@ static QString unknownText()
*/
QString QSysInfo::kernelType()
{
-#if defined(Q_OS_WINCE)
- return QStringLiteral("wince");
-#elif defined(Q_OS_WIN)
+#if defined(Q_OS_WIN)
return QStringLiteral("winnt");
#elif defined(Q_OS_UNIX)
struct utsname u;
@@ -2648,16 +2603,15 @@ QString QSysInfo::kernelVersion()
to determine the distribution name and returns that. If determining the
distribution name failed, it returns "unknown".
- \b{Darwin, OS X and iOS note}: this function returns "osx" for OS X
- systems, "ios" for iOS systems and "darwin" in case the system could not be
- determined.
+ \b{Darwin, OS X, iOS and tvOS note}: this function returns "osx" for OS X
+ systems, "ios" for iOS systems, "tvos" for tvOS systems and "darwin" in case
+ the system could not be determined.
\b{FreeBSD note}: this function returns "debian" for Debian/kFreeBSD and
"unknown" otherwise.
\b{Windows note}: this function returns "winphone" for builds for Windows
- Phone, "winrt" for WinRT builds, "wince" for Windows CE and Embedded
- Compact builds, and "windows" for normal desktop builds.
+ Phone, "winrt" for WinRT builds and "windows" for normal desktop builds.
For other Unix-type systems, this function usually returns "unknown".
@@ -2670,8 +2624,6 @@ QString QSysInfo::productType()
return QStringLiteral("winphone");
#elif defined(Q_OS_WINRT)
return QStringLiteral("winrt");
-#elif defined(Q_OS_WINCE)
- return QStringLiteral("wince");
#elif defined(Q_OS_WIN)
return QStringLiteral("windows");
@@ -2683,6 +2635,8 @@ QString QSysInfo::productType()
#elif defined(Q_OS_IOS)
return QStringLiteral("ios");
+#elif defined(Q_OS_TVOS)
+ return QStringLiteral("tvos");
#elif defined(Q_OS_OSX)
return QStringLiteral("osx");
#elif defined(Q_OS_DARWIN)
@@ -2766,50 +2720,35 @@ QString QSysInfo::prettyProductName()
{
#if defined(Q_OS_IOS)
return QLatin1String("iOS ") + productVersion();
+#elif defined(Q_OS_TVOS)
+ return QLatin1String("tvOS ") + productVersion();
#elif defined(Q_OS_OSX)
- // get the known codenames
- const char *basename = 0;
- switch (int(MacintoshVersion)) {
- case MV_CHEETAH:
- case MV_PUMA:
- case MV_JAGUAR:
- case MV_PANTHER:
- case MV_TIGER:
- // This version of Qt does not run on those versions of OS X
- // so this case label will never be reached
- Q_UNREACHABLE();
- break;
- case MV_LEOPARD:
- basename = "Mac OS X Leopard (";
- break;
- case MV_SNOWLEOPARD:
- basename = "Mac OS X Snow Leopard (";
- break;
- case MV_LION:
- basename = "OS X Lion (";
- break;
- case MV_MOUNTAINLION:
- basename = "OS X Mountain Lion (";
- break;
- case MV_MAVERICKS:
- basename = "OS X Mavericks (";
- break;
- case MV_YOSEMITE:
- basename = "OS X Yosemite (";
- break;
- case MV_ELCAPITAN:
- basename = "OS X El Capitan (";
- break;
+ const QAppleOperatingSystemVersion version = qt_apple_os_version();
+ const char *name = osxVer_helper(version);
+ if (name) {
+ return QLatin1String("OS X ") + QLatin1String(name)
+ + QLatin1String(" (") + QString::number(version.major)
+ + QLatin1Char('.') + QString::number(version.minor)
+ + QLatin1Char(')');
+ } else {
+ return QLatin1String("OS X ")
+ + QString::number(version.major) + QLatin1Char('.')
+ + QString::number(version.minor);
}
- if (basename)
- return QLatin1String(basename) + productVersion() + QLatin1Char(')');
-
- // a future version of OS X
- return QLatin1String("OS X ") + productVersion();
#elif defined(Q_OS_WINPHONE)
return QLatin1String("Windows Phone ") + QLatin1String(winVer_helper());
#elif defined(Q_OS_WIN)
- return QLatin1String("Windows ") + QLatin1String(winVer_helper()) + winSp_helper();
+ const char *name = winVer_helper();
+ const OSVERSIONINFOEX osver = winOsVersion();
+ if (name)
+ return QLatin1String("Windows ") + QLatin1String(name) + winSp_helper()
+ + QLatin1String(" (") + QString::number(osver.dwMajorVersion)
+ + QLatin1Char('.') + QString::number(osver.dwMinorVersion)
+ + QLatin1Char(')');
+ else
+ return QLatin1String("Windows ")
+ + QString::number(osver.dwMajorVersion) + QLatin1Char('.')
+ + QString::number(osver.dwMinorVersion);
#elif defined(Q_OS_ANDROID)
return QLatin1String("Android ") + productVersion();
#elif defined(Q_OS_HAIKU)
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 2081ca8649..cf647ea20d 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -469,7 +469,7 @@ typedef qptrdiff qintptr;
# define QT_ASCII_CAST_WARN
#endif
-#if defined(__i386__) || defined(_WIN32) || defined(_WIN32_WCE)
+#if defined(__i386__) || defined(_WIN32)
# if defined(Q_CC_GNU)
# define QT_FASTCALL __attribute__((regparm(3)))
# elif defined(Q_CC_MSVC)
@@ -529,23 +529,11 @@ Q_DECL_CONSTEXPR inline int qRound(double d)
{ return d >= 0.0 ? int(d + 0.5) : int(d - double(int(d-1)) + 0.5) + int(d-1); }
Q_DECL_CONSTEXPR inline int qRound(float d)
{ return d >= 0.0f ? int(d + 0.5f) : int(d - float(int(d-1)) + 0.5f) + int(d-1); }
-#ifdef Q_QDOC
-/*
- Just for documentation generation
-*/
-int qRound(qreal d);
-#endif
Q_DECL_CONSTEXPR inline qint64 qRound64(double d)
{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - double(qint64(d-1)) + 0.5) + qint64(d-1); }
Q_DECL_CONSTEXPR inline qint64 qRound64(float d)
{ return d >= 0.0f ? qint64(d + 0.5f) : qint64(d - float(qint64(d-1)) + 0.5f) + qint64(d-1); }
-#ifdef Q_QDOC
-/*
- Just for documentation generation
-*/
-qint64 qRound64(qreal d);
-#endif
template <typename T>
Q_DECL_CONSTEXPR inline const T &qMin(const T &a, const T &b) { return (a < b) ? a : b; }
@@ -622,7 +610,7 @@ class QDataStream;
# define QT_NO_SOCKS5
#endif
-#if defined(Q_OS_IOS)
+#if defined(QT_PLATFORM_UIKIT)
# define QT_NO_PROCESS
#endif
@@ -1032,8 +1020,11 @@ Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
#ifdef Q_QDOC
// Just for documentation generation
+template<typename T>
auto qOverload(T functionPointer);
+template<typename T>
auto qConstOverload(T memberFunctionPointer);
+template<typename T>
auto qNonConstOverload(T memberFunctionPointer);
#elif defined(Q_COMPILER_VARIADIC_TEMPLATES)
diff --git a/src/corelib/global/qhooks.cpp b/src/corelib/global/qhooks.cpp
index b91ec64786..7b9a3db30d 100644
--- a/src/corelib/global/qhooks.cpp
+++ b/src/corelib/global/qhooks.cpp
@@ -67,7 +67,7 @@ quintptr Q_CORE_EXPORT qtHookData[] = {
// The required sizes and offsets are tested in tests/auto/other/toolsupport.
// When this fails and the change was intentional, adjust the test and
// adjust this value here.
- 5
+ 15
};
Q_STATIC_ASSERT(QHooks::LastHookIndex == sizeof(qtHookData) / sizeof(qtHookData[0]));
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 458200180e..c31b6daa00 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -229,30 +229,30 @@ QLibraryInfo::QLibraryInfo()
{ }
/*!
- Returns the person to whom this build of Qt is licensed.
-
- \sa licensedProducts()
+ \deprecated
+ This function used to return the person to whom this build of Qt is licensed, now returns an empty string.
*/
+#if QT_DEPRECATED_SINCE(5, 8)
QString
QLibraryInfo::licensee()
{
- const char * volatile str = QT_CONFIGURE_LICENSEE;
- return QString::fromLocal8Bit(str);
+ return QString();
}
+#endif
/*!
- Returns the products that the license for this build of Qt has access to.
-
- \sa licensee()
+ \deprecated
+ This function used to return the products that the license for this build of Qt has access to, now returns an empty string.
*/
+#if QT_DEPRECATED_SINCE(5, 8)
QString
QLibraryInfo::licensedProducts()
{
- const char * volatile str = QT_CONFIGURE_LICENSED_PRODUCTS;
- return QString::fromLatin1(str);
+ return QString();
}
+#endif
/*!
\since 4.6
@@ -366,6 +366,19 @@ QLibraryInfo::isDebugBuild()
#endif
}
+#ifndef QT_BOOTSTRAPPED
+/*!
+ \since 5.8
+ Returns the version of the Qt library.
+
+ \sa qVersion()
+*/
+QVersionNumber QLibraryInfo::version() Q_DECL_NOTHROW
+{
+ return QVersionNumber(QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH);
+}
+#endif // QT_BOOTSTRAPPED
+
#endif // QT_BUILD_QMAKE
/*
diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h
index 362d47dea3..55be706382 100644
--- a/src/corelib/global/qlibraryinfo.h
+++ b/src/corelib/global/qlibraryinfo.h
@@ -42,6 +42,7 @@
#include <QtCore/qstring.h>
#include <QtCore/qdatetime.h>
+#include <QtCore/qversionnumber.h>
QT_BEGIN_NAMESPACE
@@ -50,8 +51,10 @@ class QStringList;
class Q_CORE_EXPORT QLibraryInfo
{
public:
- static QString licensee();
- static QString licensedProducts();
+#if QT_DEPRECATED_SINCE(5, 8)
+ static QT_DEPRECATED QString licensee();
+ static QT_DEPRECATED QString licensedProducts();
+#endif
#ifndef QT_NO_DATESTRING
#if QT_DEPRECATED_SINCE(5, 5)
@@ -63,6 +66,10 @@ public:
static bool isDebugBuild();
+#ifndef QT_BOOTSTRAPPED
+ static QVersionNumber version() Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
+#endif
+
enum LibraryLocation
{
PrefixPath = 0,
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index f2e293c45b..0fe095b8d3 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -170,7 +170,7 @@ static bool isFatal(QtMsgType msgType)
static bool willLogToConsole()
{
-#if defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#if defined(Q_OS_WINRT)
// these systems have no stderr, so always log to the system log
return false;
#elif defined(QT_BOOTSTRAPPED)
@@ -1176,7 +1176,7 @@ void QMessagePattern::setPattern(const QString &pattern)
else if (inIf)
error += QStringLiteral("QT_MESSAGE_PATTERN: missing %{endif}\n");
if (!error.isEmpty()) {
-#if defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#if defined(Q_OS_WINRT)
OutputDebugString(reinterpret_cast<const wchar_t*>(error.utf16()));
if (0)
#elif defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB)
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 2a0b8461cd..edb568a2d6 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -301,12 +301,7 @@ public:
MacWindowToolBarButtonHint = 0x10000000,
BypassGraphicsProxyWidget = 0x20000000,
NoDropShadowWindowHint = 0x40000000,
- WindowFullscreenButtonHint = 0x80000000,
-
- // The following enums have overlapping values with other enums.
- // This was not intentional, but it's too late to change now.
- WindowOkButtonHint = 0x00080000, // WindowTransparentForInput
- WindowCancelButtonHint = 0x00100000 // WindowOverridesSystemGestures
+ WindowFullscreenButtonHint = 0x80000000
};
Q_DECLARE_FLAGS(WindowFlags, WindowType)
@@ -509,6 +504,7 @@ public:
AA_DontUseNativeDialogs = 23,
AA_SynthesizeMouseForUnhandledTabletEvents = 24,
AA_CompressHighFrequencyEvents = 25,
+ AA_DontCheckOpenGLContextThreadAffinity = 26,
// Add new attributes before this line
AA_AttributeCount
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 3c53a23896..d8a0acabf1 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -250,6 +250,13 @@
If your application needs to handle all events with no compression,
you can unset this attribute. This value has been added in Qt 5.7.
+ \value AA_DontCheckOpenGLContextThreadAffinity When making a context
+ current using QOpenGLContext, do not check that the
+ \l{QObject#Thread Affinity}{QObject thread affinity}
+ of the QOpenGLContext object is the same thread calling
+ \l{QOpenGLContext::makeCurrent}{makeCurrent()}. This value has been
+ added in Qt 5.8.
+
The following values are obsolete:
\value AA_ImmediateWidgetCreation This attribute is no longer fully
@@ -753,27 +760,25 @@
\value MonoOnly The pixmap becomes monochrome. If necessary,
it is dithered using the chosen dithering algorithm.
- Dithering mode preference for RGB channels:
+ Dithering mode preference:
- \value DiffuseDither (default) - A high-quality dither.
- \value OrderedDither A faster, more ordered dither.
+ \value DiffuseDither (default) - A high-quality dither using error diffusion.
+ \value OrderedDither A faster, ordered dither.
\value ThresholdDither No dithering; closest color is used.
- Dithering mode preference for alpha channel:
+ Dithering mode preference for 1-bit alpha masks:
\value ThresholdAlphaDither (default) - No dithering.
- \value OrderedAlphaDither A faster, more ordered dither.
- \value DiffuseAlphaDither A high-quality dither.
+ \value OrderedAlphaDither A faster, ordered dither.
+ \value DiffuseAlphaDither A high-quality dither using error diffusion.
\omitvalue NoAlpha
Color matching versus dithering preference:
- \value PreferDither (default when converting to a pixmap) - Always dither
- 32-bit images when the image is converted to 8 bits.
- \value AvoidDither (default when converting for the purpose of saving to
- file) - Dither 32-bit images only if the image has more than 256
- colors and it is being converted to 8 bits.
- \omitvalue AutoDither
+ \value PreferDither Always dither images when converting to smaller color-spaces.
+ \value AvoidDither Only dither to indexed formats if the source image uses more
+ different colors than the size of the color table of the destination format.
+ \value AutoDither (default) - Only dither when down-converting to 1 or 8-bit indexed formats.
\omitvalue ColorMode_Mask
\omitvalue Dither_Mask
@@ -2221,12 +2226,6 @@
the bottom. This window hint is currently not implemented
for OS X.
- \value WindowOkButtonHint Adds an OK button to the window decoration of a dialog.
- Only supported for Windows CE.
-
- \value WindowCancelButtonHint Adds a Cancel button to the window decoration of a dialog.
- Only supported for Windows CE.
-
\value WindowTransparentForInput Informs the window system that this window
is used only for output (displaying something) and does not take input.
Therefore input events should pass through as if it wasn't there.
diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h
index 5705bc29c8..b7f7d5187c 100644
--- a/src/corelib/global/qnumeric_p.h
+++ b/src/corelib/global/qnumeric_p.h
@@ -56,7 +56,7 @@
#include <cmath>
#include <limits>
-#if defined(Q_CC_MSVC) && !defined(Q_OS_WINCE)
+#if defined(Q_CC_MSVC)
# include <intrin.h>
#elif defined(Q_CC_INTEL)
# include <immintrin.h> // for _addcarry_u<nn>
diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h
index 6ecd41bc30..566d76d3d2 100644
--- a/src/corelib/global/qprocessordetection.h
+++ b/src/corelib/global/qprocessordetection.h
@@ -334,7 +334,7 @@
# 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(_WIN32_WCE) || defined(WINAPI_FAMILY) // Windows CE is always little-endian according to MSDN.
+ || defined(WINAPI_FAMILY) // WinRT is always little-endian according to MSDN.
# define Q_BYTE_ORDER Q_LITTLE_ENDIAN
# else
# error "Unable to determine byte order!"
diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h
index b74fc80468..143e00a4c3 100644
--- a/src/corelib/global/qsysinfo.h
+++ b/src/corelib/global/qsysinfo.h
@@ -69,7 +69,7 @@ public:
LittleEndian
# ifdef Q_QDOC
- , ByteOrder = <platform-dependent>
+ , ByteOrder = BigEndian or LittleEndian
# elif Q_BYTE_ORDER == Q_BIG_ENDIAN
, ByteOrder = BigEndian
# elif Q_BYTE_ORDER == Q_LITTLE_ENDIAN
@@ -109,13 +109,7 @@ public:
WV_6_1 = WV_WINDOWS7,
WV_6_2 = WV_WINDOWS8,
WV_6_3 = WV_WINDOWS8_1,
- WV_10_0 = WV_WINDOWS10,
-
- WV_CE = 0x0100,
- WV_CENET = 0x0200,
- WV_CE_5 = 0x0300,
- WV_CE_6 = 0x0400,
- WV_CE_based = 0x0f00
+ WV_10_0 = WV_WINDOWS10
};
#if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
static const WinVersion WindowsVersion;
@@ -127,6 +121,7 @@ public:
#define Q_MV_OSX(major, minor) (major == 10 ? minor + 2 : (major == 9 ? 1 : 0))
#define Q_MV_IOS(major, minor) (QSysInfo::MV_IOS | major << 4 | minor)
+#define Q_MV_TVOS(major, minor) (QSysInfo::MV_TVOS | major << 4 | minor)
enum MacVersion {
MV_None = 0xffff,
MV_Unknown = 0x0000,
@@ -174,7 +169,12 @@ public:
MV_IOS_8_2 = Q_MV_IOS(8, 2),
MV_IOS_8_3 = Q_MV_IOS(8, 3),
MV_IOS_8_4 = Q_MV_IOS(8, 4),
- MV_IOS_9_0 = Q_MV_IOS(9, 0)
+ MV_IOS_9_0 = Q_MV_IOS(9, 0),
+
+ /* tvOS */
+ MV_TVOS = 1 << 9,
+ MV_TVOS_9_0 = Q_MV_TVOS(9, 0),
+ MV_TVOS_9_1 = Q_MV_TVOS(9, 1)
};
#if defined(Q_OS_MAC)
static const MacVersion MacintoshVersion;
diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h
index 1e95d1a2ec..ccf5851d18 100644
--- a/src/corelib/global/qsystemdetection.h
+++ b/src/corelib/global/qsystemdetection.h
@@ -56,7 +56,6 @@
OS2 - OS/2
OS2EMX - XFree86 on OS/2 (not PM)
WIN32 - Win32 (Windows 2000/XP/Vista/7 and Windows Server 2003/2008)
- WINCE - WinCE (Windows CE 5.0)
WINRT - WinRT (Windows 8 Runtime)
CYGWIN - Cygwin
SOLARIS - Sun Solaris
@@ -103,14 +102,17 @@
# define Q_OS_DARWIN32
# endif
# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
-# if defined(TARGET_OS_TV) && TARGET_OS_TV
-# define Q_OS_TVOS
-# elif defined(TARGET_OS_WATCH) && TARGET_OS_WATCH
+# if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH
# define Q_OS_WATCHOS
# else
-# // TARGET_OS_IOS is only available in newer SDKs,
-# // so assume any other iOS-based platform is iOS for now
-# define Q_OS_IOS
+# define QT_PLATFORM_UIKIT
+# if defined(TARGET_OS_TV) && TARGET_OS_TV
+# define Q_OS_TVOS
+# else
+# // TARGET_OS_IOS is only available in newer SDKs,
+# // so assume any other iOS-based platform is iOS for now
+# define Q_OS_IOS
+# endif
# endif
# else
# // there is no "real" OS X define (rdar://22640089),
@@ -129,9 +131,7 @@
# define Q_OS_WIN32
# define Q_OS_WIN64
#elif !defined(SAG_COM) && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__))
-# if defined(WINCE) || defined(_WIN32_WCE)
-# define Q_OS_WINCE
-# elif defined(WINAPI_FAMILY)
+# if defined(WINAPI_FAMILY)
# ifndef WINAPI_FAMILY_PC_APP
# define WINAPI_FAMILY_PC_APP WINAPI_FAMILY_APP
# endif
@@ -209,7 +209,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_WINCE) || defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINRT)
# define Q_OS_WIN
#endif
diff --git a/src/corelib/global/qt_windows.h b/src/corelib/global/qt_windows.h
index 8ac3c2135d..7b95501c08 100644
--- a/src/corelib/global/qt_windows.h
+++ b/src/corelib/global/qt_windows.h
@@ -48,10 +48,10 @@
#if defined(Q_CC_MINGW)
// mingw's windows.h does not set _WIN32_WINNT, resulting breaking compilation
# ifndef WINVER
-# define WINVER 0x501
+# define WINVER 0x600
# endif
# ifndef _WIN32_WINNT
-# define _WIN32_WINNT 0x0501
+# define _WIN32_WINNT 0x600
# endif
#endif
@@ -67,10 +67,6 @@
# define _WIN32_IE 0x0501
#endif
-#ifdef _WIN32_WCE
-#include <ceconfig.h>
-#endif
-
// already defined when compiled with WINVER >= 0x0500
#ifndef SPI_SETMENUANIMATION
#define SPI_SETMENUANIMATION 0x1003
@@ -144,13 +140,4 @@
#define CLEARTYPE_QUALITY 5
#endif
-#ifdef Q_OS_WINCE
-#ifndef LR_DEFAULTSIZE
-#define LR_DEFAULTSIZE 0
-#endif
-#ifndef LR_SHARED
-#define LR_SHARED 0
-#endif
-#endif // Q_OS_WINCE
-
#endif // QT_WINDOWS_H
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri
index 1cb2909c2a..ab345e9aae 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -106,25 +106,21 @@ win32 {
SOURCES += io/qfilesystemiterator_win.cpp
!winrt {
- SOURCES += io/qsettings_win.cpp
- SOURCES += io/qstandardpaths_win.cpp
+ HEADERS += \
+ io/qwindowspipereader_p.h \
+ io/qwindowspipewriter_p.h \
+ io/qwinoverlappedionotifier_p.h
- wince* {
- SOURCES += io/qprocess_wince.cpp \
- io/qstorageinfo_stub.cpp
- } else {
- HEADERS += \
- io/qwinoverlappedionotifier_p.h \
- io/qwindowspipereader_p.h \
- io/qwindowspipewriter_p.h
- SOURCES += \
- io/qprocess_win.cpp \
- io/qwinoverlappedionotifier.cpp \
- io/qwindowspipereader.cpp \
- io/qwindowspipewriter.cpp \
- io/qstorageinfo_win.cpp
- LIBS += -lmpr
- }
+ SOURCES += \
+ io/qprocess_win.cpp \
+ io/qsettings_win.cpp \
+ io/qstandardpaths_win.cpp \
+ io/qstorageinfo_win.cpp \
+ io/qwindowspipereader.cpp \
+ io/qwindowspipewriter.cpp \
+ io/qwinoverlappedionotifier.cpp
+
+ LIBS += -lmpr
} else {
SOURCES += \
io/qstandardpaths_winrt.cpp \
@@ -139,7 +135,7 @@ win32 {
io/qprocess_unix.cpp \
io/qfilesystemiterator_unix.cpp
- !integrity {
+ !integrity:!tvos {
SOURCES += io/forkfd_qt.cpp
HEADERS += \
../3rdparty/forkfd/forkfd.h
@@ -147,7 +143,6 @@ win32 {
}
!nacl:mac: {
SOURCES += io/qsettings_mac.cpp
- OBJECTIVE_SOURCES += io/qurl_mac.mm
}
mac {
SOURCES += io/qstorageinfo_mac.cpp
@@ -156,7 +151,7 @@ win32 {
OBJECTIVE_SOURCES += io/qfilesystemwatcher_fsevents.mm
HEADERS += io/qfilesystemwatcher_fsevents_p.h
LIBS += -framework DiskArbitration -framework IOKit
- } else:ios {
+ } else {
LIBS += -framework MobileCoreServices
}
} else:android {
diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h
index e4cd3b3509..76d173bb3e 100644
--- a/src/corelib/io/qdatastream.h
+++ b/src/corelib/io/qdatastream.h
@@ -91,10 +91,11 @@ public:
Qt_5_5 = Qt_5_4,
Qt_5_6 = 17,
Qt_5_7 = Qt_5_6,
-#if QT_VERSION >= 0x050800
+ Qt_5_8 = Qt_5_7,
+#if QT_VERSION >= 0x050900
#error Add the datastream version for this Qt version and update Qt_DefaultCompiledVersion
#endif
- Qt_DefaultCompiledVersion = Qt_5_7
+ Qt_DefaultCompiledVersion = Qt_5_8
};
enum ByteOrder {
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 9efe2fb90e..af07b52cdb 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -2187,7 +2187,7 @@ QString QDir::cleanPath(const QString &path)
name.replace(dir_separator, QLatin1Char('/'));
bool allowUncPaths = false;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) //allow unc paths
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) //allow unc paths
allowUncPaths = true;
#endif
diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp
index 4ac12fc9ea..f0db3d1ae3 100644
--- a/src/corelib/io/qfileselector.cpp
+++ b/src/corelib/io/qfileselector.cpp
@@ -55,8 +55,6 @@ QT_BEGIN_NAMESPACE
//Environment variable to allow tooling full control of file selectors
static const char env_override[] = "QT_NO_BUILTIN_SELECTORS";
-static const ushort selectorIndicator = '+';
-
Q_GLOBAL_STATIC(QFileSelectorSharedData, sharedData);
static QBasicMutex sharedDataMutex;
@@ -267,7 +265,7 @@ QUrl QFileSelector::select(const QUrl &filePath) const
return ret;
}
-static QString selectionHelper(const QString &path, const QString &fileName, const QStringList &selectors)
+QString QFileSelectorPrivate::selectionHelper(const QString &path, const QString &fileName, const QStringList &selectors, const QChar &indicator)
{
/* selectionHelper does a depth-first search of possible selected files. Because there is strict
selector ordering in the API, we can stop checking as soon as we find the file in a directory
@@ -276,12 +274,15 @@ static QString selectionHelper(const QString &path, const QString &fileName, con
Q_ASSERT(path.isEmpty() || path.endsWith(QLatin1Char('/')));
for (const QString &s : selectors) {
- QString prospectiveBase = path + QLatin1Char(selectorIndicator) + s + QLatin1Char('/');
+ QString prospectiveBase = path;
+ if (!indicator.isNull())
+ prospectiveBase += indicator;
+ prospectiveBase += s + QLatin1Char('/');
QStringList remainingSelectors = selectors;
remainingSelectors.removeAll(s);
if (!QDir(prospectiveBase).exists())
continue;
- QString prospectiveFile = selectionHelper(prospectiveBase, fileName, remainingSelectors);
+ QString prospectiveFile = selectionHelper(prospectiveBase, fileName, remainingSelectors, indicator);
if (!prospectiveFile.isEmpty())
return prospectiveFile;
}
@@ -369,7 +370,7 @@ QStringList QFileSelectorPrivate::platformSelectors()
#if defined(Q_OS_WIN)
// can't fall back to QSysInfo because we need both "winphone" and "winrt" for the Windows Phone case
ret << QStringLiteral("windows");
- ret << QSysInfo::kernelType(); // "wince" and "winnt"
+ ret << QSysInfo::kernelType(); // "winnt"
# if defined(Q_OS_WINRT)
ret << QStringLiteral("winrt");
# if defined(Q_OS_WINPHONE)
diff --git a/src/corelib/io/qfileselector_p.h b/src/corelib/io/qfileselector_p.h
index f93eb0ccb3..024d0b190d 100644
--- a/src/corelib/io/qfileselector_p.h
+++ b/src/corelib/io/qfileselector_p.h
@@ -70,6 +70,8 @@ public:
static void updateSelectors();
static QStringList platformSelectors();
static void addStatics(const QStringList &); //For loading GUI statics from other Qt modules
+ static QString selectionHelper(const QString &path, const QString &fileName,
+ const QStringList &selectors, const QChar &indicator = QLatin1Char('+'));
QFileSelectorPrivate();
QString select(const QString &filePath) const;
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 75797e58da..eebe5f1f94 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -61,7 +61,7 @@
#include <CoreServices/CoreServices.h>
#endif
-#ifdef Q_OS_IOS
+#if defined(QT_PLATFORM_UIKIT)
#include <MobileCoreServices/MobileCoreServices.h>
#endif
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 85c795fadd..8375dc9b1b 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -53,13 +53,9 @@
#include "qdatetime.h"
#include "qt_windows.h"
-#if !defined(Q_OS_WINCE)
-# include <sys/types.h>
-# include <direct.h>
-# include <winioctl.h>
-#else
-# include <types.h>
-#endif
+#include <sys/types.h>
+#include <direct.h>
+#include <winioctl.h>
#include <objbase.h>
#ifndef Q_OS_WINRT
# include <shlobj.h>
@@ -116,8 +112,7 @@ typedef INT_PTR intptr_t;
# define INVALID_FILE_ATTRIBUTES (DWORD (-1))
#endif
-#if !defined(Q_OS_WINCE)
-# if !defined(REPARSE_DATA_BUFFER_HEADER_SIZE)
+#if !defined(REPARSE_DATA_BUFFER_HEADER_SIZE)
typedef struct _REPARSE_DATA_BUFFER {
ULONG ReparseTag;
USHORT ReparseDataLength;
@@ -143,32 +138,31 @@ typedef struct _REPARSE_DATA_BUFFER {
} GenericReparseBuffer;
};
} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
-# define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer)
-# endif // !defined(REPARSE_DATA_BUFFER_HEADER_SIZE)
+# define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer)
+#endif // !defined(REPARSE_DATA_BUFFER_HEADER_SIZE)
-# ifndef MAXIMUM_REPARSE_DATA_BUFFER_SIZE
-# define MAXIMUM_REPARSE_DATA_BUFFER_SIZE 16384
-# endif
-# ifndef IO_REPARSE_TAG_SYMLINK
-# define IO_REPARSE_TAG_SYMLINK (0xA000000CL)
-# endif
-# ifndef FSCTL_GET_REPARSE_POINT
-# define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
-# endif
-#endif // !defined(Q_OS_WINCE)
+#ifndef MAXIMUM_REPARSE_DATA_BUFFER_SIZE
+# define MAXIMUM_REPARSE_DATA_BUFFER_SIZE 16384
+#endif
+#ifndef IO_REPARSE_TAG_SYMLINK
+# define IO_REPARSE_TAG_SYMLINK (0xA000000CL)
+#endif
+#ifndef FSCTL_GET_REPARSE_POINT
+# define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
+#endif
QT_BEGIN_NAMESPACE
Q_CORE_EXPORT int qt_ntfs_permission_lookup = 0;
-#if defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#if defined(Q_OS_WINRT)
static QString qfsPrivateCurrentDir = QLatin1String("");
-// As none of the functions we try to resolve do exist on Windows CE
+// As none of the functions we try to resolve do exist on WinRT
// we use QT_NO_LIBRARY to shorten everything up a little bit.
-#ifndef QT_NO_LIBRARY
-#define QT_NO_LIBRARY 1
-#endif
-#endif
+# ifndef QT_NO_LIBRARY
+# define QT_NO_LIBRARY 1
+# endif
+#endif // Q_OS_WINRT
#if !defined(QT_NO_LIBRARY)
QT_BEGIN_INCLUDE_NAMESPACE
@@ -182,8 +176,6 @@ typedef DWORD (WINAPI *PtrGetEffectiveRightsFromAclW)(PACL, PTRUSTEE_W, OUT PACC
static PtrGetEffectiveRightsFromAclW ptrGetEffectiveRightsFromAclW = 0;
typedef BOOL (WINAPI *PtrGetUserProfileDirectoryW)(HANDLE, LPWSTR, LPDWORD);
static PtrGetUserProfileDirectoryW ptrGetUserProfileDirectoryW = 0;
-typedef BOOL (WINAPI *PtrGetVolumePathNamesForVolumeNameW)(LPCWSTR,LPWSTR,DWORD,PDWORD);
-static PtrGetVolumePathNamesForVolumeNameW ptrGetVolumePathNamesForVolumeNameW = 0;
QT_END_INCLUDE_NAMESPACE
static TRUSTEE_W currentUserTrusteeW;
@@ -233,7 +225,6 @@ static void resolveLibs()
#endif
triedResolve = true;
-#if !defined(Q_OS_WINCE)
HINSTANCE advapiHnd = QSystemLibrary::load(L"advapi32");
if (advapiHnd) {
ptrGetNamedSecurityInfoW = (PtrGetNamedSecurityInfoW)GetProcAddress(advapiHnd, "GetNamedSecurityInfoW");
@@ -279,10 +270,6 @@ static void resolveLibs()
HINSTANCE userenvHnd = QSystemLibrary::load(L"userenv");
if (userenvHnd)
ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW");
- HINSTANCE kernel32 = LoadLibrary(L"kernel32");
- if(kernel32)
- ptrGetVolumePathNamesForVolumeNameW = (PtrGetVolumePathNamesForVolumeNameW)GetProcAddress(kernel32, "GetVolumePathNamesForVolumeNameW");
-#endif
}
}
#endif // QT_NO_LIBRARY
@@ -309,14 +296,14 @@ static bool resolveUNCLibs()
}
#endif
triedResolve = true;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
HINSTANCE hLib = QSystemLibrary::load(L"Netapi32");
if (hLib) {
ptrNetShareEnum = (PtrNetShareEnum)GetProcAddress(hLib, "NetShareEnum");
if (ptrNetShareEnum)
ptrNetApiBufferFree = (PtrNetApiBufferFree)GetProcAddress(hLib, "NetApiBufferFree");
}
-#endif // !Q_OS_WINCE && !Q_OS_WINRT
+#endif // !Q_OS_WINRT
}
return ptrNetShareEnum && ptrNetApiBufferFree;
}
@@ -324,7 +311,7 @@ static bool resolveUNCLibs()
static QString readSymLink(const QFileSystemEntry &link)
{
QString result;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#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,
@@ -357,27 +344,24 @@ static QString readSymLink(const QFileSystemEntry &link)
#if !defined(QT_NO_LIBRARY)
resolveLibs();
- if (ptrGetVolumePathNamesForVolumeNameW) {
- QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive);
- if(matchVolName.indexIn(result) == 0) {
- DWORD len;
- wchar_t buffer[MAX_PATH];
- QString volumeName = result.mid(0, matchVolName.matchedLength()).prepend(QLatin1String("\\\\?\\"));
- if(ptrGetVolumePathNamesForVolumeNameW((wchar_t*)volumeName.utf16(), buffer, MAX_PATH, &len) != 0)
- result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer));
- }
+ QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive);
+ if (matchVolName.indexIn(result) == 0) {
+ DWORD len;
+ wchar_t buffer[MAX_PATH];
+ QString volumeName = result.mid(0, matchVolName.matchedLength()).prepend(QLatin1String("\\\\?\\"));
+ if (GetVolumePathNamesForVolumeName(reinterpret_cast<LPCWSTR>(volumeName.utf16()), buffer, MAX_PATH, &len) != 0)
+ result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer));
}
-#endif // !Q_OS_WINCE && !Q_OS_WINRT
+#endif // !Q_OS_WINRT
}
#else
Q_UNUSED(link);
-#endif // Q_OS_WINCE || Q_OS_WINRT
+#endif // Q_OS_WINRT
return result;
}
static QString readLink(const QFileSystemEntry &link)
{
-#if !defined(Q_OS_WINCE)
#if !defined(QT_NO_LIBRARY)
QString ret;
@@ -418,21 +402,6 @@ static QString readLink(const QFileSystemEntry &link)
Q_UNUSED(link);
return QString();
#endif // QT_NO_LIBRARY
-#elif !defined(QT_NO_WINCE_SHELLSDK)
- wchar_t target[MAX_PATH];
- QString result;
- if (SHGetShortcutTarget((wchar_t*)QFileInfo(link.filePath()).absoluteFilePath().replace(QLatin1Char('/'),QLatin1Char('\\')).utf16(), target, MAX_PATH)) {
- result = QString::fromWCharArray(target);
- if (result.startsWith(QLatin1Char('"')))
- result.remove(0,1);
- if (result.endsWith(QLatin1Char('"')))
- result.remove(result.size()-1,1);
- }
- return result;
-#else // QT_NO_WINCE_SHELLSDK
- Q_UNUSED(link);
- return QString();
-#endif // Q_OS_WINCE
}
static bool uncShareExists(const QString &server)
@@ -533,7 +502,7 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path)
{
// can be //server or //server/share
QString absPath;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81)
+#if !defined(Q_OS_WINRT_WIN81)
QVarLengthArray<wchar_t, MAX_PATH> buf(qMax(MAX_PATH, path.size() + 1));
wchar_t *fileName = 0;
DWORD retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName);
@@ -553,17 +522,12 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path)
if (absPath.size() < rootPath.size() && rootPath.startsWith(absPath))
absPath = rootPath;
# endif // Q_OS_WINRT
-#elif !defined(Q_OS_WINCE)
+#else // !Q_OS_WINRT_WIN81
if (QDir::isRelativePath(path))
absPath = QDir::toNativeSeparators(QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + path));
else
absPath = QDir::toNativeSeparators(QDir::cleanPath(path));
-#else // Q_OS_WINRT
- if (path.startsWith(QLatin1Char('/')) || path.startsWith(QLatin1Char('\\')))
- absPath = QDir::toNativeSeparators(path);
- else
- absPath = QDir::toNativeSeparators(QDir::cleanPath(qfsPrivateCurrentDir + QLatin1Char('/') + path));
-#endif // Q_OS_WINCE
+#endif // Q_OS_WINRT_WIN81
// This is really ugly, but GetFullPathName strips off whitespace at the end.
// If you for instance write ". " in the lineedit of QFileDialog,
// (which is an invalid filename) this function will strip the space off and viola,
@@ -580,15 +544,10 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
QString ret;
if (!entry.isRelative()) {
-#if !defined(Q_OS_WINCE)
- if (entry.isAbsolute() && entry.isClean()) {
+ if (entry.isAbsolute() && entry.isClean())
ret = entry.filePath();
- } else {
+ else
ret = QDir::fromNativeSeparators(nativeAbsoluteFilePath(entry.filePath()));
- }
-#else
- ret = entry.filePath();
-#endif
} else {
#ifndef Q_OS_WINRT_WIN81
ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + entry.filePath());
@@ -617,25 +576,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
}
-#ifndef Q_OS_WINCE
-
-// FILE_INFO_BY_HANDLE_CLASS has been extended by FileIdInfo = 18 as of VS2012.
-typedef enum { Q_FileIdInfo = 18 } Q_FILE_INFO_BY_HANDLE_CLASS;
-
-# if defined(Q_CC_MINGW) || (defined(Q_CC_MSVC) && (_MSC_VER < 1700 || WINVER <= 0x0601))
-
-// MinGW-64 defines FILE_ID_128 as of gcc-4.8.1 along with FILE_SUPPORTS_INTEGRITY_STREAMS
-# if !(defined(Q_CC_MINGW) && defined(FILE_SUPPORTS_INTEGRITY_STREAMS))
-typedef struct _FILE_ID_128 {
- BYTE Identifier[16];
-} FILE_ID_128, *PFILE_ID_128;
-# endif // !(Q_CC_MINGW && FILE_SUPPORTS_INTEGRITY_STREAMS)
+#if defined(Q_CC_MINGW) && WINVER < 0x0602 // Windows 8 onwards
typedef struct _FILE_ID_INFO {
ULONGLONG VolumeSerialNumber;
FILE_ID_128 FileId;
} FILE_ID_INFO, *PFILE_ID_INFO;
-# endif // if defined (Q_CC_MINGW) || (defined(Q_CC_MSVC) && (_MSC_VER < 1700 || WINVER <= 0x0601))
+
+#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
// File ID for Windows up to version 7.
static inline QByteArray fileId(HANDLE handle)
@@ -658,44 +606,26 @@ static inline QByteArray fileId(HANDLE handle)
// File ID for Windows starting from version 8.
QByteArray fileIdWin8(HANDLE handle)
{
-#ifndef Q_OS_WINRT
- typedef BOOL (WINAPI* GetFileInformationByHandleExType)(HANDLE, Q_FILE_INFO_BY_HANDLE_CLASS, void *, DWORD);
-
- // Dynamically resolve GetFileInformationByHandleEx (Vista onwards).
- static GetFileInformationByHandleExType getFileInformationByHandleEx = 0;
- if (!getFileInformationByHandleEx) {
- QSystemLibrary library(QLatin1String("kernel32"));
- getFileInformationByHandleEx = (GetFileInformationByHandleExType)library.resolve("GetFileInformationByHandleEx");
- }
- QByteArray result;
- if (getFileInformationByHandleEx) {
- FILE_ID_INFO infoEx;
- if (getFileInformationByHandleEx(handle, Q_FileIdInfo,
- &infoEx, sizeof(FILE_ID_INFO))) {
- result = QByteArray::number(infoEx.VolumeSerialNumber, 16);
- result += ':';
- // Note: MinGW-64's definition of FILE_ID_128 differs from the MSVC one.
- result += QByteArray((char *)&infoEx.FileId, sizeof(infoEx.FileId)).toHex();
- }
- }
-#else // !Q_OS_WINRT
+#if !defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE)
QByteArray result;
FILE_ID_INFO infoEx;
- if (GetFileInformationByHandleEx(handle, FileIdInfo,
+ if (GetFileInformationByHandleEx(handle,
+ static_cast<FILE_INFO_BY_HANDLE_CLASS>(18), // FileIdInfo in Windows 8
&infoEx, sizeof(FILE_ID_INFO))) {
result = QByteArray::number(infoEx.VolumeSerialNumber, 16);
result += ':';
- result += QByteArray((char *)infoEx.FileId.Identifier, sizeof(infoEx.FileId.Identifier)).toHex();
+ // Note: MinGW-64's definition of FILE_ID_128 differs from the MSVC one.
+ result += QByteArray(reinterpret_cast<const char *>(&infoEx.FileId), int(sizeof(infoEx.FileId))).toHex();
}
-#endif // Q_OS_WINRT
return result;
+#else // !QT_BOOTSTRAPPED && !QT_BUILD_QMAKE
+ return fileId(handle);
+#endif
}
-#endif // !Q_OS_WINCE
//static
QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry)
{
-#ifndef Q_OS_WINCE
QByteArray result;
const HANDLE handle =
#ifndef Q_OS_WINRT
@@ -711,9 +641,6 @@ QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry)
CloseHandle(handle);
}
return result;
-#else // !Q_OS_WINCE
- return entry.nativeFilePath().toLower().toLatin1();
-#endif
}
//static
@@ -882,7 +809,7 @@ static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaDa
{
bool entryExists = false;
DWORD fileAttrib = 0;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
if (fname.isDriveRoot()) {
// a valid drive ??
const UINT oldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
@@ -925,7 +852,7 @@ static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaDa
fileAttrib = FILE_ATTRIBUTE_DIRECTORY;
entryExists = true;
}
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
}
#endif
if (entryExists)
@@ -949,7 +876,6 @@ static bool tryFindFallback(const QFileSystemEntry &fname, QFileSystemMetaData &
return filledData;
}
-#if !defined(Q_OS_WINCE)
//static
bool QFileSystemEngine::fillMetaData(int fd, QFileSystemMetaData &data,
QFileSystemMetaData::MetaDataFlags what)
@@ -960,7 +886,6 @@ bool QFileSystemEngine::fillMetaData(int fd, QFileSystemMetaData &data,
}
return false;
}
-#endif
//static
bool QFileSystemEngine::fillMetaData(HANDLE fHandle, QFileSystemMetaData &data,
@@ -1069,25 +994,6 @@ static inline bool mkDir(const QString &path, DWORD *lastError = 0)
{
if (lastError)
*lastError = 0;
-#if defined(Q_OS_WINCE)
- // Unfortunately CreateDirectory returns true for paths longer than
- // 256, but does not create a directory. It starts to fail, when
- // path length > MAX_PATH, which is 260 usually on CE.
- // This only happens on a Windows Mobile device. Windows CE seems
- // not to be affected by this.
- static int platformId = 0;
- if (platformId == 0) {
- wchar_t platformString[64];
- if (SystemParametersInfo(SPI_GETPLATFORMTYPE, sizeof(platformString)/sizeof(*platformString),platformString,0)) {
- if (0 == wcscmp(platformString, L"PocketPC") || 0 == wcscmp(platformString, L"Smartphone"))
- platformId = 1;
- else
- platformId = 2;
- }
- }
- if (platformId == 1 && QFSFileEnginePrivate::longFileName(path).size() > 256)
- return false;
-#endif
const QString longPath = QFSFileEnginePrivate::longFileName(path);
const bool result = ::CreateDirectory((wchar_t*)longPath.utf16(), 0);
if (lastError) // Capture lastError before any QString is freed since custom allocators might change it.
@@ -1217,9 +1123,7 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo
//static
QString QFileSystemEngine::rootPath()
{
-#if defined(Q_OS_WINCE)
- QString ret = QLatin1String("/");
-#elif defined(Q_OS_WINRT)
+#if defined(Q_OS_WINRT)
// We specify the package root as root directory
QString ret = QLatin1String("/");
// Get package location
@@ -1285,13 +1189,8 @@ QString QFileSystemEngine::homePath()
+ QString::fromLocal8Bit(qgetenv("HOMEPATH"));
if (ret.isEmpty() || !QFile::exists(ret)) {
ret = QString::fromLocal8Bit(qgetenv("HOME"));
- if (ret.isEmpty() || !QFile::exists(ret)) {
-#if defined(Q_OS_WINCE)
- ret = QLatin1String("\\My Documents");
- if (!QFile::exists(ret))
-#endif
- ret = rootPath();
- }
+ if (ret.isEmpty() || !QFile::exists(ret))
+ ret = rootPath();
}
}
}
@@ -1304,10 +1203,6 @@ QString QFileSystemEngine::tempPath()
#ifndef Q_OS_WINRT
wchar_t tempPath[MAX_PATH];
const DWORD len = GetTempPath(MAX_PATH, tempPath);
-#ifdef Q_OS_WINCE
- if (len)
- ret = QString::fromWCharArray(tempPath, len);
-#else // Q_OS_WINCE
if (len) { // GetTempPath() can return short names, expand.
wchar_t longTempPath[MAX_PATH];
const DWORD longLen = GetLongPathName(tempPath, longTempPath, MAX_PATH);
@@ -1315,7 +1210,6 @@ QString QFileSystemEngine::tempPath()
QString::fromWCharArray(longTempPath, longLen) :
QString::fromWCharArray(tempPath, len);
}
-#endif // !Q_OS_WINCE
if (!ret.isEmpty()) {
while (ret.endsWith(QLatin1Char('\\')))
ret.chop(1);
@@ -1343,11 +1237,7 @@ QString QFileSystemEngine::tempPath()
ret = QDir::fromNativeSeparators(QString::fromWCharArray(path.GetRawBuffer(nullptr)));
#endif // Q_OS_WINRT
if (ret.isEmpty()) {
-#if !defined(Q_OS_WINCE)
ret = QLatin1String("C:/tmp");
-#else
- ret = QLatin1String("/Temp");
-#endif
} else if (ret.length() >= 2 && ret[1] == QLatin1Char(':'))
ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters.
return ret;
@@ -1360,7 +1250,7 @@ bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry)
if(!(meta.exists() && meta.isDirectory()))
return false;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81)
+#if !defined(Q_OS_WINRT_WIN81)
//TODO: this should really be using nativeFilePath(), but that returns a path in long format \\?\c:\foo
//which causes many problems later on when it's returned through currentPath()
return ::SetCurrentDirectory(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(entry.filePath()).utf16())) != 0;
@@ -1373,7 +1263,7 @@ bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry)
QFileSystemEntry QFileSystemEngine::currentPath()
{
QString ret;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81)
+#if !defined(Q_OS_WINRT_WIN81)
DWORD size = 0;
wchar_t currentName[PATH_MAX];
size = ::GetCurrentDirectory(PATH_MAX, currentName);
@@ -1389,17 +1279,13 @@ QFileSystemEntry QFileSystemEngine::currentPath()
}
if (ret.length() >= 2 && ret[1] == QLatin1Char(':'))
ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters.
-#else // !Q_OS_WINCE && !Q_OS_WINRT_WIN81
+#else // !Q_OS_WINRT_WIN81
//TODO - a race condition exists when using currentPath / setCurrentPath from multiple threads
if (qfsPrivateCurrentDir.isEmpty())
-#ifndef Q_OS_WINRT_WIN81
- qfsPrivateCurrentDir = QCoreApplication::applicationDirPath();
-#else
qfsPrivateCurrentDir = QDir::rootPath();
-#endif
ret = qfsPrivateCurrentDir;
-#endif // Q_OS_WINCE || Q_OS_WINRT_WIN81
+#endif // Q_OS_WINRT_WIN81
return QFileSystemEntry(ret, QFileSystemEntry::FromNativePath());
}
@@ -1482,31 +1368,11 @@ static inline QDateTime fileTimeToQDateTime(const FILETIME *time)
{
QDateTime ret;
-#if defined(Q_OS_WINCE)
- SYSTEMTIME systime;
- FILETIME ftime;
- systime.wYear = 1970;
- systime.wMonth = 1;
- systime.wDay = 1;
- systime.wHour = 0;
- systime.wMinute = 0;
- systime.wSecond = 0;
- systime.wMilliseconds = 0;
- systime.wDayOfWeek = 4;
- SystemTimeToFileTime(&systime, &ftime);
- unsigned __int64 acttime = (unsigned __int64)time->dwHighDateTime << 32 | time->dwLowDateTime;
- FileTimeToSystemTime(time, &systime);
- unsigned __int64 time1970 = (unsigned __int64)ftime.dwHighDateTime << 32 | ftime.dwLowDateTime;
- unsigned __int64 difftime = acttime - time1970;
- difftime /= 10000000;
- ret.setTime_t((unsigned int)difftime);
-#else
SYSTEMTIME sTime, lTime;
FileTimeToSystemTime(time, &sTime);
SystemTimeToTzSpecificLocalTime(0, &sTime, &lTime);
ret.setDate(QDate(lTime.wYear, lTime.wMonth, lTime.wDay));
ret.setTime(QTime(lTime.wHour, lTime.wMinute, lTime.wSecond, lTime.wMilliseconds));
-#endif
return ret;
}
diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp
index ba195b2330..9e40a41b4c 100644
--- a/src/corelib/io/qfilesystemiterator_win.cpp
+++ b/src/corelib/io/qfilesystemiterator_win.cpp
@@ -92,12 +92,10 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa
haveData = true;
int infoLevel = 0 ; // FindExInfoStandard;
DWORD dwAdditionalFlags = 0;
-#ifndef Q_OS_WINCE
if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7) {
dwAdditionalFlags = 2; // FIND_FIRST_EX_LARGE_FETCH
infoLevel = 1 ; // FindExInfoBasic;
}
-#endif
int searchOps = 0; // FindExSearchNameMatch
if (onlyDirs)
searchOps = 1 ; // FindExSearchLimitToDirectories
diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h
index 7135c9b19b..b38188d357 100644
--- a/src/corelib/io/qfilesystemmetadata_p.h
+++ b/src/corelib/io/qfilesystemmetadata_p.h
@@ -331,13 +331,10 @@ inline void QFileSystemMetaData::fillFromFindData(WIN32_FIND_DATA &findData, boo
if (setLinkType) {
knownFlagsMask |= LinkType;
entryFlags &= ~LinkType;
-#if !defined(Q_OS_WINCE)
if ((fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT)
&& (findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) {
entryFlags |= LinkType;
}
-#endif
-
}
}
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index acea610625..55f4bddd17 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -58,7 +58,7 @@
# include "qfilesystemwatcher_win_p.h"
#elif defined(USE_INOTIFY)
# include "qfilesystemwatcher_inotify_p.h"
-#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD) || defined(Q_OS_IOS)
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD) || defined(QT_PLATFORM_UIKIT)
# include "qfilesystemwatcher_kqueue_p.h"
#elif defined(Q_OS_OSX)
# include "qfilesystemwatcher_fsevents_p.h"
@@ -74,7 +74,7 @@ QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject
// there is a chance that inotify may fail on Linux pre-2.6.13 (August
// 2005), so we can't just new inotify directly.
return QInotifyFileSystemWatcherEngine::create(parent);
-#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD) || defined(Q_OS_IOS)
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD) || defined(QT_PLATFORM_UIKIT)
return QKqueueFileSystemWatcherEngine::create(parent);
#elif defined(Q_OS_OSX)
return QFseventsFileSystemWatcherEngine::create(parent);
diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.mm b/src/corelib/io/qfilesystemwatcher_fsevents.mm
index be9eef889a..beb8acb05f 100644
--- a/src/corelib/io/qfilesystemwatcher_fsevents.mm
+++ b/src/corelib/io/qfilesystemwatcher_fsevents.mm
@@ -198,7 +198,7 @@ void QFseventsFileSystemWatcherEngine::processEvent(ConstFSEventStreamRef stream
const FSEventStreamEventFlags eventFlags[],
const FSEventStreamEventId eventIds[])
{
-#if defined(Q_OS_OSX) && MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_6
+#if defined(Q_OS_OSX)
Q_UNUSED(streamRef);
bool needsRestart = false;
@@ -256,12 +256,6 @@ void QFseventsFileSystemWatcherEngine::processEvent(ConstFSEventStreamRef stream
if (needsRestart)
emit scheduleStreamRestart();
#else
- // This is a work-around for moc: when we put the version check at the top of the header file,
- // moc will still see the Q_OBJECT macro and generate a meta-object when compiling for 10.6,
- // which obviously won't link.
- //
- // So the trick is to still compile this class on 10.6, but never instantiate it.
-
Q_UNUSED(streamRef);
Q_UNUSED(numEvents);
Q_UNUSED(eventPaths);
diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp
index e8b49db9f3..be56d8dd1d 100644
--- a/src/corelib/io/qfilesystemwatcher_win.cpp
+++ b/src/corelib/io/qfilesystemwatcher_win.cpp
@@ -86,13 +86,9 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths,
QString path = it.next();
QString normalPath = path;
if ((normalPath.endsWith(QLatin1Char('/')) && !normalPath.endsWith(QLatin1String(":/")))
- || (normalPath.endsWith(QLatin1Char('\\')) && !normalPath.endsWith(QLatin1String(":\\")))
-#ifdef Q_OS_WINCE
- && normalPath.size() > 1)
-#else
- )
-#endif
- normalPath.chop(1);
+ || (normalPath.endsWith(QLatin1Char('\\')) && !normalPath.endsWith(QLatin1String(":\\")))) {
+ normalPath.chop(1);
+ }
QFileInfo fileInfo(normalPath);
if (!fileInfo.exists())
continue;
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp
index 2cda4d6bda..098bc49468 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -48,9 +48,7 @@
#ifndef QT_NO_FSFILEENGINE
-#if !defined(Q_OS_WINCE)
#include <errno.h>
-#endif
#if defined(Q_OS_UNIX)
#include "private/qcore_unix_p.h"
#endif
@@ -125,10 +123,8 @@ void QFSFileEnginePrivate::init()
{
is_sequential = 0;
tried_stat = 0;
-#if !defined(Q_OS_WINCE)
need_lstat = 1;
is_link = 0;
-#endif
openMode = QIODevice::NotOpen;
fd = -1;
fh = 0;
@@ -139,10 +135,8 @@ void QFSFileEnginePrivate::init()
fileAttrib = INVALID_FILE_ATTRIBUTES;
fileHandle = INVALID_HANDLE_VALUE;
mapHandle = NULL;
-#ifndef Q_OS_WINCE
cachedFd = -1;
#endif
-#endif
}
/*!
@@ -551,7 +545,7 @@ bool QFSFileEnginePrivate::seekFdFh(qint64 pos)
} else {
// Unbuffered stdio mode.
if (QT_LSEEK(fd, QT_OFF_T(pos), SEEK_SET) == -1) {
- qWarning() << "QFile::at: Cannot set file position" << pos;
+ qWarning("QFile::at: Cannot set file position %lld", pos);
q->setError(QFile::PositionError, qt_error_string(errno));
return false;
}
diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h
index dd498a5bc5..593ecc2687 100644
--- a/src/corelib/io/qfsfileengine_p.h
+++ b/src/corelib/io/qfsfileengine_p.h
@@ -61,10 +61,6 @@
QT_BEGIN_NAMESPACE
-#if defined(Q_OS_WINCE_STD) && _WIN32_WCE < 0x600
-#define Q_USE_DEPRECATED_MAP_API 1
-#endif
-
class QFSFileEnginePrivate;
class Q_CORE_EXPORT QFSFileEngine : public QAbstractFileEngine
@@ -184,10 +180,7 @@ public:
HANDLE mapHandle;
QHash<uchar *, DWORD /* offset % AllocationGranularity */> maps;
-#ifndef Q_OS_WINCE
mutable int cachedFd;
-#endif
-
mutable DWORD fileAttrib;
#else
QHash<uchar *, QPair<int /*offset % PageSize*/, size_t /*length + offset % PageSize*/> > maps;
@@ -206,10 +199,8 @@ public:
mutable uint is_sequential : 2;
mutable uint tried_stat : 1;
-#if !defined(Q_OS_WINCE)
mutable uint need_lstat : 1;
mutable uint is_link : 1;
-#endif
#if defined(Q_OS_WIN)
bool doStat(QFileSystemMetaData::MetaDataFlags flags) const;
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index c37a690646..70c347978e 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -50,13 +50,9 @@
#include "qdatetime.h"
#include "qt_windows.h"
-#if !defined(Q_OS_WINCE)
-# include <sys/types.h>
-# include <direct.h>
-# include <winioctl.h>
-#else
-# include <types.h>
-#endif
+#include <sys/types.h>
+#include <direct.h>
+#include <winioctl.h>
#include <objbase.h>
#ifndef Q_OS_WINRT
# include <shlobj.h>
@@ -77,14 +73,12 @@
QT_BEGIN_NAMESPACE
-#if !defined(Q_OS_WINCE)
static inline bool isUncPath(const QString &path)
{
// Starts with \\, but not \\.
return (path.startsWith(QLatin1String("\\\\"))
&& path.size() > 2 && path.at(2) != QLatin1Char('.'));
}
-#endif
/*!
\internal
@@ -95,7 +89,7 @@ QString QFSFileEnginePrivate::longFileName(const QString &path)
return path;
QString absPath = QFileSystemEngine::nativeAbsoluteFilePath(path);
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
QString prefix = QLatin1String("\\\\?\\");
if (isUncPath(absPath)) {
prefix.append(QLatin1String("UNC\\")); // "\\\\?\\UNC\\"
@@ -171,7 +165,6 @@ bool QFSFileEnginePrivate::nativeClose()
// Windows native mode.
bool ok = true;
-#ifndef Q_OS_WINCE
if (cachedFd != -1) {
if (::_close(cachedFd) && !::CloseHandle(fileHandle)) {
q->setError(QFile::UnspecifiedError, qt_error_string());
@@ -184,7 +177,6 @@ bool QFSFileEnginePrivate::nativeClose()
return ok;
}
-#endif
if ((fileHandle == INVALID_HANDLE_VALUE || !::CloseHandle(fileHandle))) {
q->setError(QFile::UnspecifiedError, qt_error_string());
@@ -238,24 +230,6 @@ qint64 QFSFileEnginePrivate::nativeSize() const
// Always retrive the current information
metaData.clearFlags(QFileSystemMetaData::SizeAttribute);
-#if defined(Q_OS_WINCE)
- // Buffered stdlib mode.
- if (fh) {
- QT_OFF_T oldPos = QT_FTELL(fh);
- QT_FSEEK(fh, 0, SEEK_END);
- qint64 fileSize = (qint64)QT_FTELL(fh);
- QT_FSEEK(fh, oldPos, SEEK_SET);
- if (fileSize == -1) {
- fileSize = 0;
- thatQ->setError(QFile::UnspecifiedError, qt_error_string(errno));
- }
- return fileSize;
- }
- if (fd != -1) {
- thatQ->setError(QFile::UnspecifiedError, QLatin1String("Not implemented!"));
- return 0;
- }
-#endif
bool filled = false;
if (fileHandle != INVALID_HANDLE_VALUE && openMode != QIODevice::NotOpen )
filled = QFileSystemEngine::fillMetaData(fileHandle, metaData,
@@ -287,7 +261,6 @@ qint64 QFSFileEnginePrivate::nativePos() const
if (fileHandle == INVALID_HANDLE_VALUE)
return 0;
-#if !defined(Q_OS_WINCE)
LARGE_INTEGER currentFilePos;
LARGE_INTEGER offset;
offset.QuadPart = 0;
@@ -297,18 +270,6 @@ qint64 QFSFileEnginePrivate::nativePos() const
}
return qint64(currentFilePos.QuadPart);
-#else
- LARGE_INTEGER filepos;
- filepos.HighPart = 0;
- DWORD newFilePointer = SetFilePointer(fileHandle, 0, &filepos.HighPart, FILE_CURRENT);
- if (newFilePointer == 0xFFFFFFFF && GetLastError() != NO_ERROR) {
- thatQ->setError(QFile::UnspecifiedError, qt_error_string());
- return 0;
- }
-
- filepos.LowPart = newFilePointer;
- return filepos.QuadPart;
-#endif
}
/*
@@ -323,7 +284,6 @@ bool QFSFileEnginePrivate::nativeSeek(qint64 pos)
return seekFdFh(pos);
}
-#if !defined(Q_OS_WINCE)
LARGE_INTEGER currentFilePos;
LARGE_INTEGER offset;
offset.QuadPart = pos;
@@ -333,17 +293,6 @@ bool QFSFileEnginePrivate::nativeSeek(qint64 pos)
}
return true;
-#else
- DWORD newFilePointer;
- LARGE_INTEGER *li = reinterpret_cast<LARGE_INTEGER*>(&pos);
- newFilePointer = SetFilePointer(fileHandle, li->LowPart, &li->HighPart, FILE_BEGIN);
- if (newFilePointer == 0xFFFFFFFF && GetLastError() != NO_ERROR) {
- q->setError(QFile::PositionError, qt_error_string());
- return false;
- }
-
- return true;
-#endif
}
/*
@@ -462,7 +411,6 @@ int QFSFileEnginePrivate::nativeHandle() const
{
if (fh || fd != -1)
return fh ? QT_FILENO(fh) : fd;
-#ifndef Q_OS_WINCE
if (cachedFd != -1)
return cachedFd;
@@ -473,9 +421,6 @@ int QFSFileEnginePrivate::nativeHandle() const
flags |= _O_RDONLY;
cachedFd = _open_osfhandle((intptr_t) fileHandle, flags);
return cachedFd;
-#else
- return -1;
-#endif
}
/*
@@ -483,7 +428,7 @@ int QFSFileEnginePrivate::nativeHandle() const
*/
bool QFSFileEnginePrivate::nativeIsSequential() const
{
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
HANDLE handle = fileHandle;
if (fh || fd != -1)
handle = (HANDLE)_get_osfhandle(fh ? QT_FILENO(fh) : fd);
@@ -531,35 +476,9 @@ bool QFSFileEngine::rename(const QString &newName)
bool QFSFileEngine::renameOverwrite(const QString &newName)
{
Q_D(QFSFileEngine);
-#if defined(Q_OS_WINCE)
- // Windows Embedded Compact 7 does not have MoveFileEx, simulate it with the following sequence:
- // 1. DeleteAndRenameFile (Should work on RAM FS when both files exist)
- // 2. DeleteFile/MoveFile (Should work on all file systems)
- //
- // DeleteFile/MoveFile fallback implementation violates atomicity, but it is more acceptable than
- // alternative CopyFile/DeleteFile sequence for the following reasons:
- //
- // 1. DeleteFile/MoveFile is way faster than CopyFile/DeleteFile and thus more atomic.
- // 2. Given the intended use case of this function in QSaveFile, DeleteFile/MoveFile sequence will
- // delete the old content, but leave a file "filename.ext.XXXXXX" in the same directory if MoveFile fails.
- // With CopyFile/DeleteFile sequence, it can happen that new data is partially copied to target file
- // (because CopyFile is not atomic either), thus leaving *some* content to target file.
- // This makes the need for application level recovery harder to detect than in DeleteFile/MoveFile
- // sequence where target file simply does not exist.
- //
- bool ret = ::DeleteAndRenameFile((wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16(),
- (wchar_t*)d->fileEntry.nativeFilePath().utf16()) != 0;
- if (!ret) {
- ret = ::DeleteFile((wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16()) != 0;
- if (ret || ::GetLastError() == ERROR_FILE_NOT_FOUND)
- ret = ::MoveFile((wchar_t*)d->fileEntry.nativeFilePath().utf16(),
- (wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16()) != 0;
- }
-#else
bool ret = ::MoveFileEx((wchar_t*)d->fileEntry.nativeFilePath().utf16(),
(wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16(),
MOVEFILE_REPLACE_EXISTING) != 0;
-#endif
if (!ret)
setError(QFile::RenameError, QSystemError(::GetLastError(), QSystemError::NativeError).toString());
return ret;
@@ -587,7 +506,7 @@ bool QFSFileEngine::setCurrentPath(const QString &path)
QString QFSFileEngine::currentPath(const QString &fileName)
{
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
QString ret;
//if filename is a drive: then get the pwd of that drive
if (fileName.length() >= 2 &&
@@ -606,10 +525,10 @@ 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_WINCE && !Q_OS_WINRT
+#else // !Q_OS_WINRT
Q_UNUSED(fileName);
return QFileSystemEngine::currentPath().filePath();
-#endif // Q_OS_WINCE || Q_OS_WINRT
+#endif // Q_OS_WINRT
}
QString QFSFileEngine::homePath()
@@ -630,12 +549,12 @@ QString QFSFileEngine::tempPath()
QFileInfoList QFSFileEngine::drives()
{
QFileInfoList ret;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
-#if defined(Q_OS_WIN32)
+#if !defined(Q_OS_WINRT)
+# if defined(Q_OS_WIN32)
const UINT oldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
quint32 driveBits = (quint32) GetLogicalDrives() & 0x3ffffff;
::SetErrorMode(oldErrorMode);
-#endif
+# endif
char driveName[] = "A:/";
while (driveBits) {
@@ -645,10 +564,10 @@ QFileInfoList QFSFileEngine::drives()
driveBits = driveBits >> 1;
}
return ret;
-#else // !Q_OS_WINCE && !Q_OS_WINRT
+#else // !Q_OS_WINRT
ret.append(QFileInfo(QLatin1String("/")));
return ret;
-#endif // Q_OS_WINCE || Q_OS_WINRT
+#endif // Q_OS_WINRT
}
bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) const
@@ -656,13 +575,11 @@ bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) cons
if (!tried_stat || !metaData.hasFlags(flags)) {
tried_stat = true;
-#if !defined(Q_OS_WINCE)
int localFd = fd;
if (fh && fileEntry.isEmpty())
localFd = QT_FILENO(fh);
if (localFd != -1)
QFileSystemEngine::fillMetaData(localFd, metaData, flags);
-#endif
if (metaData.missingFlags(flags) && !fileEntry.isEmpty())
QFileSystemEngine::fillMetaData(fileEntry, metaData, metaData.missingFlags(flags));
}
@@ -673,8 +590,8 @@ bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) cons
bool QFSFileEngine::link(const QString &newName)
{
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
-#if !defined(QT_NO_LIBRARY)
+#if !defined(Q_OS_WINRT)
+# if !defined(QT_NO_LIBRARY)
bool ret = false;
QString linkName = newName;
@@ -715,24 +632,11 @@ bool QFSFileEngine::link(const QString &newName)
CoUninitialize();
return ret;
-#else
+# else // QT_NO_LIBRARY
Q_UNUSED(newName);
return false;
-#endif // QT_NO_LIBRARY
-#elif defined(Q_OS_WINCE) && !defined(QT_NO_WINCE_SHELLSDK)
- QString linkName = newName;
- linkName.replace(QLatin1Char('/'), QLatin1Char('\\'));
- if (!linkName.endsWith(QLatin1String(".lnk")))
- linkName += QLatin1String(".lnk");
- QString orgName = fileName(AbsoluteName).replace(QLatin1Char('/'), QLatin1Char('\\'));
- // Need to append on our own
- orgName.prepend(QLatin1Char('"'));
- orgName.append(QLatin1Char('"'));
- bool ret = SUCCEEDED(SHCreateShortcut((wchar_t*)linkName.utf16(), (wchar_t*)orgName.utf16()));
- if (!ret)
- setError(QFile::RenameError, qt_error_string());
- return ret;
-#else // Q_OS_WINCE && !QT_NO_WINCE_SHELLSDK
+# endif // QT_NO_LIBRARY
+#else // !Q_OS_WINRT
Q_UNUSED(newName);
Q_UNIMPLEMENTED();
return false;
@@ -813,7 +717,6 @@ QString QFSFileEngine::fileName(FileName file) const
QString ret;
if (!isRelativePath()) {
-#if !defined(Q_OS_WINCE)
if (d->fileEntry.filePath().startsWith(QLatin1Char('/')) || // It's a absolute path to the current drive, so \a.txt -> Z:\a.txt
d->fileEntry.filePath().size() == 2 || // It's a drive letter that needs to get a working dir appended
(d->fileEntry.filePath().size() > 2 && d->fileEntry.filePath().at(2) != QLatin1Char('/')) || // It's a drive-relative path, so Z:a.txt -> Z:\currentpath\a.txt
@@ -821,9 +724,7 @@ QString QFSFileEngine::fileName(FileName file) const
d->fileEntry.filePath().endsWith(QLatin1String("/..")) || d->fileEntry.filePath().endsWith(QLatin1String("/.")))
{
ret = QDir::fromNativeSeparators(QFileSystemEngine::nativeAbsoluteFilePath(d->fileEntry.filePath()));
- } else
-#endif
- {
+ } else {
ret = d->fileEntry.filePath();
}
} else {
@@ -905,14 +806,12 @@ bool QFSFileEngine::setSize(qint64 size)
if (d->fileHandle != INVALID_HANDLE_VALUE || d->fd != -1 || d->fh) {
// resize open file
HANDLE fh = d->fileHandle;
-#if !defined(Q_OS_WINCE)
if (fh == INVALID_HANDLE_VALUE) {
if (d->fh)
fh = (HANDLE)_get_osfhandle(QT_FILENO(d->fh));
else
fh = (HANDLE)_get_osfhandle(d->fd);
}
-#endif
if (fh == INVALID_HANDLE_VALUE)
return false;
qint64 currentPos = pos();
@@ -984,10 +883,8 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size,
// get handle to the file
HANDLE handle = fileHandle;
-#ifndef Q_OS_WINCE
if (handle == INVALID_HANDLE_VALUE && fh)
handle = (HANDLE)::_get_osfhandle(QT_FILENO(fh));
-#endif
#ifdef Q_USE_DEPRECATED_MAP_API
nativeClose();
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index fd204b00de..36616a5236 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -1148,34 +1148,31 @@ QByteArray QIODevice::read(qint64 maxSize)
Q_D(QIODevice);
QByteArray result;
- CHECK_MAXLEN(read, result);
-
#if defined QIODEVICE_DEBUG
printf("%p QIODevice::read(%lld), d->pos = %lld, d->buffer.size() = %lld\n",
this, maxSize, d->pos, d->buffer.size());
#endif
+ // Try to prevent the data from being copied, if we have a chunk
+ // with the same size in the read buffer.
+ if (maxSize == d->buffer.nextDataBlockSize() && !d->transactionStarted
+ && (d->openMode & (QIODevice::ReadOnly | QIODevice::Text)) == QIODevice::ReadOnly) {
+ result = d->buffer.read();
+ if (!d->isSequential())
+ d->pos += maxSize;
+ if (d->buffer.isEmpty())
+ readData(nullptr, 0);
+ return result;
+ }
+
+ CHECK_MAXLEN(read, result);
if (maxSize >= MaxByteArraySize) {
checkWarnMessage(this, "read", "maxSize argument exceeds QByteArray size limit");
maxSize = MaxByteArraySize - 1;
}
- qint64 readBytes = 0;
- if (maxSize) {
- result.resize(int(maxSize));
- if (!result.size()) {
- // If resize fails, read incrementally.
- qint64 readResult;
- do {
- result.resize(int(qMin(maxSize, qint64(result.size() + d->readBufferChunkSize))));
- readResult = read(result.data() + readBytes, result.size() - readBytes);
- if (readResult > 0 || readBytes == 0)
- readBytes += readResult;
- } while (readResult == d->readBufferChunkSize);
- } else {
- readBytes = read(result.data(), result.size());
- }
- }
+ result.resize(int(maxSize));
+ qint64 readBytes = read(result.data(), result.size());
if (readBytes <= 0)
result.clear();
diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp
index e1bd769e77..79141d1e8f 100644
--- a/src/corelib/io/qlockfile_unix.cpp
+++ b/src/corelib/io/qlockfile_unix.cpp
@@ -70,7 +70,7 @@
# include <cstdio>
#elif defined(Q_OS_HAIKU)
# include <kernel/OS.h>
-#elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS)
+#elif defined(Q_OS_BSD4) && !defined(QT_PLATFORM_UIKIT)
# if !defined(Q_OS_NETBSD)
# include <sys/user.h>
# endif
@@ -283,7 +283,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
if (get_thread_info(pid, &info) != B_OK)
return QString();
return QFile::decodeName(info.name);
-#elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS)
+#elif defined(Q_OS_BSD4) && !defined(QT_PLATFORM_UIKIT)
# if defined(Q_OS_NETBSD)
struct kinfo_proc2 kp;
int mib[6] = { CTL_KERN, KERN_PROC2, KERN_PROC_PID, (int)pid, sizeof(struct kinfo_proc2), 1 };
diff --git a/src/corelib/io/qlockfile_win.cpp b/src/corelib/io/qlockfile_win.cpp
index 4afab3d135..baaff8da17 100644
--- a/src/corelib/io/qlockfile_win.cpp
+++ b/src/corelib/io/qlockfile_win.cpp
@@ -100,7 +100,7 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys()
? QLockFile::LockFailedError
: QLockFile::PermissionError;
default:
- qWarning() << "Got unexpected locking error" << lastError;
+ qWarning("Got unexpected locking error %llu", quint64(lastError));
return QLockFile::UnknownError;
}
}
@@ -165,7 +165,7 @@ bool QLockFilePrivate::isApparentlyStale() const
QString QLockFilePrivate::processNameByPid(qint64 pid)
{
-#if !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE)
+#if !defined(Q_OS_WINRT)
typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
HMODULE hPsapi = LoadLibraryA("psapi");
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 914d4421d0..ebafd6b524 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -48,9 +48,6 @@
#if defined QPROCESS_DEBUG
#include <qstring.h>
#include <ctype.h>
-#if !defined(Q_OS_WINCE)
-#include <errno.h>
-#endif
QT_BEGIN_NAMESPACE
/*
@@ -1988,13 +1985,6 @@ qint64 QProcess::writeData(const char *data, qint64 len)
{
Q_D(QProcess);
-#if defined(Q_OS_WINCE)
- Q_UNUSED(data);
- Q_UNUSED(len);
- d->setErrorAndEmit(QProcess::WriteError);
- return -1;
-#endif
-
if (d->stdinChannel.closed) {
#if defined QPROCESS_DEBUG
qDebug("QProcess::writeData(%p \"%s\", %lld) == 0 (write channel closing)",
@@ -2171,7 +2161,6 @@ void QProcessPrivate::start(QIODevice::OpenMode mode)
mode &= ~QIODevice::ReadOnly; // not open for reading
if (mode == 0)
mode = QIODevice::Unbuffered;
-#ifndef Q_OS_WINCE
if ((mode & QIODevice::ReadOnly) == 0) {
if (stdoutChannel.type == QProcessPrivate::Channel::Normal)
q->setStandardOutputFile(q->nullDevice());
@@ -2179,7 +2168,6 @@ void QProcessPrivate::start(QIODevice::OpenMode mode)
&& processChannelMode != QProcess::MergedChannels)
q->setStandardErrorFile(q->nullDevice());
}
-#endif
q->QIODevice::open(mode);
@@ -2537,7 +2525,7 @@ QT_BEGIN_INCLUDE_NAMESPACE
#if defined(Q_OS_MACX)
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
-#elif defined(Q_OS_WINCE) || defined(Q_OS_IOS)
+#elif defined(QT_PLATFORM_UIKIT)
static char *qt_empty_environ[] = { 0 };
#define environ qt_empty_environ
#elif !defined(Q_OS_WIN)
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 8c5589538d..1d425653a3 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -322,7 +322,7 @@ QT_END_INCLUDE_NAMESPACE
QProcessEnvironment QProcessEnvironment::systemEnvironment()
{
QProcessEnvironment env;
-#if !defined(Q_OS_IOS)
+#if !defined(QT_PLATFORM_UIKIT)
const char *entry;
for (int count = 0; (entry = environ[count]); ++count) {
const char *equal = strchr(entry, '=');
diff --git a/src/corelib/io/qprocess_wince.cpp b/src/corelib/io/qprocess_wince.cpp
deleted file mode 100644
index 824a6158dc..0000000000
--- a/src/corelib/io/qprocess_wince.cpp
+++ /dev/null
@@ -1,308 +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 "qprocess.h"
-#include "qprocess_p.h"
-
-#include <qdir.h>
-#include <qfileinfo.h>
-#include <qregexp.h>
-#include <qtimer.h>
-#include <qwineventnotifier.h>
-#include <qdebug.h>
-#include <private/qthread_p.h>
-
-#ifndef QT_NO_PROCESS
-
-QT_BEGIN_NAMESPACE
-
-//#define QPROCESS_DEBUG
-
-void QProcessPrivate::destroyPipe(Q_PIPE pipe[2])
-{
- Q_UNUSED(pipe);
-}
-
-void QProcessPrivate::closeChannel(Channel *channel)
-{
- Q_UNUSED(channel);
-}
-
-static QString qt_create_commandline(const QString &program, const QStringList &arguments)
-{
- QString args;
- if (!program.isEmpty()) {
- QString programName = program;
- if (!programName.startsWith(QLatin1Char('\"')) && !programName.endsWith(QLatin1Char('\"')) && programName.contains(QLatin1Char(' ')))
- programName = QLatin1Char('\"') + programName + QLatin1Char('\"');
- programName.replace(QLatin1Char('/'), QLatin1Char('\\'));
-
- // add the prgram as the first arg ... it works better
- args = programName + QLatin1Char(' ');
- }
-
- for (int i=0; i<arguments.size(); ++i) {
- QString tmp = arguments.at(i);
- // Quotes are escaped and their preceding backslashes are doubled.
- tmp.replace(QRegExp(QLatin1String("(\\\\*)\"")), QLatin1String("\\1\\1\\\""));
- if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) {
- // The argument must not end with a \ since this would be interpreted
- // as escaping the quote -- rather put the \ behind the quote: e.g.
- // rather use "foo"\ than "foo\"
- int i = tmp.length();
- while (i > 0 && tmp.at(i - 1) == QLatin1Char('\\'))
- --i;
- tmp.insert(i, QLatin1Char('"'));
- tmp.prepend(QLatin1Char('"'));
- }
- args += QLatin1Char(' ') + tmp;
- }
- return args;
-}
-
-QProcessEnvironment QProcessEnvironment::systemEnvironment()
-{
- QProcessEnvironment env;
- return env;
-}
-
-void QProcessPrivate::startProcess()
-{
- Q_Q(QProcess);
-
- bool success = false;
-
- if (pid) {
- CloseHandle(pid->hThread);
- CloseHandle(pid->hProcess);
- delete pid;
- pid = 0;
- }
- pid = new PROCESS_INFORMATION;
- memset(pid, 0, sizeof(PROCESS_INFORMATION));
-
- q->setProcessState(QProcess::Starting);
-
- QString args = qt_create_commandline(QString(), arguments);
- if (!nativeArguments.isEmpty()) {
- if (!args.isEmpty())
- args += QLatin1Char(' ');
- args += nativeArguments;
- }
-
-#if defined QPROCESS_DEBUG
- qDebug("Creating process");
- qDebug(" program : [%s]", program.toLatin1().constData());
- qDebug(" args : %s", args.toLatin1().constData());
- qDebug(" pass environment : %s", environment.isEmpty() ? "no" : "yes");
-#endif
-
- QString fullPathProgram = program;
- if (!QDir::isAbsolutePath(fullPathProgram))
- fullPathProgram = QFileInfo(fullPathProgram).absoluteFilePath();
- fullPathProgram.replace(QLatin1Char('/'), QLatin1Char('\\'));
- success = CreateProcess((wchar_t*)fullPathProgram.utf16(),
- (wchar_t*)args.utf16(),
- 0, 0, false, 0, 0, 0, 0, pid);
-
- if (!success) {
- cleanup();
- setErrorAndEmit(QProcess::FailedToStart);
- q->setProcessState(QProcess::NotRunning);
- return;
- }
-
- q->setProcessState(QProcess::Running);
- // User can call kill()/terminate() from the stateChanged() slot
- // so check before proceeding
- if (!pid)
- return;
-
- if (threadData->hasEventDispatcher()) {
- processFinishedNotifier = new QWinEventNotifier(pid->hProcess, q);
- QObject::connect(processFinishedNotifier, SIGNAL(activated(HANDLE)), q, SLOT(_q_processDied()));
- processFinishedNotifier->setEnabled(true);
- }
-
- // give the process a chance to start ...
- Sleep(20);
- _q_startupNotification();
-}
-
-bool QProcessPrivate::processStarted(QString * /*errorMessage*/)
-{
- return processState == QProcess::Running;
-}
-
-qint64 QProcessPrivate::bytesAvailableInChannel(const Channel *) const
-{
- return 0;
-}
-
-qint64 QProcessPrivate::readFromChannel(const Channel *, char *data, qint64 maxlen)
-{
- return -1;
-}
-
-static BOOL QT_WIN_CALLBACK qt_terminateApp(HWND hwnd, LPARAM procId)
-{
- DWORD currentProcId = 0;
- GetWindowThreadProcessId(hwnd, &currentProcId);
- if (currentProcId == (DWORD)procId)
- PostMessage(hwnd, WM_CLOSE, 0, 0);
-
- return TRUE;
-}
-
-void QProcessPrivate::terminateProcess()
-{
- if (pid) {
- EnumWindows(qt_terminateApp, (LPARAM)pid->dwProcessId);
- PostThreadMessage(pid->dwThreadId, WM_CLOSE, 0, 0);
- }
-}
-
-void QProcessPrivate::killProcess()
-{
- if (pid)
- TerminateProcess(pid->hProcess, 0xf291);
-}
-
-bool QProcessPrivate::waitForStarted(int)
-{
- Q_Q(QProcess);
-
- if (processStarted())
- return true;
-
- if (processError == QProcess::FailedToStart)
- return false;
-
- setError(QProcess::Timedout);
- return false;
-}
-
-bool QProcessPrivate::drainOutputPipes()
-{
- return true;
-}
-
-bool QProcessPrivate::waitForReadyRead(int msecs)
-{
- return false;
-}
-
-bool QProcessPrivate::waitForBytesWritten(int msecs)
-{
- return false;
-}
-
-bool QProcessPrivate::waitForFinished(int msecs)
-{
- Q_Q(QProcess);
-#if defined QPROCESS_DEBUG
- qDebug("QProcessPrivate::waitForFinished(%d)", msecs);
-#endif
-
- if (!pid)
- return true;
-
- if (WaitForSingleObject(pid->hProcess, msecs == -1 ? INFINITE : msecs) == WAIT_OBJECT_0) {
- _q_processDied();
- return true;
- }
-
- setError(QProcess::Timedout);
- return false;
-}
-
-void QProcessPrivate::findExitCode()
-{
- DWORD theExitCode;
- if (GetExitCodeProcess(pid->hProcess, &theExitCode)) {
- exitCode = theExitCode;
- //### for now we assume a crash if exit code is less than -1 or the magic number
- crashed = (exitCode == 0xf291 || (int)exitCode < 0);
- }
-}
-
-void QProcessPrivate::flushPipeWriter()
-{
-}
-
-qint64 QProcessPrivate::pipeWriterBytesToWrite() const
-{
- return 0;
-}
-
-bool QProcessPrivate::writeToStdin()
-{
- return false;
-}
-
-bool QProcessPrivate::startDetached(const QString &program, const QStringList &arguments, const QString &workingDir, qint64 *pid)
-{
- Q_UNUSED(workingDir);
- QString args = qt_create_commandline(QString(), arguments);
-
- bool success = false;
-
- PROCESS_INFORMATION pinfo;
-
- QString fullPathProgram = program;
- if (!QDir::isAbsolutePath(fullPathProgram))
- fullPathProgram.prepend(QDir::currentPath().append(QLatin1Char('/')));
- fullPathProgram.replace(QLatin1Char('/'), QLatin1Char('\\'));
- success = CreateProcess((wchar_t*)fullPathProgram.utf16(),
- (wchar_t*)args.utf16(),
- 0, 0, false, CREATE_NEW_CONSOLE, 0, 0, 0, &pinfo);
-
- if (success) {
- CloseHandle(pinfo.hThread);
- CloseHandle(pinfo.hProcess);
- if (pid)
- *pid = pinfo.dwProcessId;
- }
-
- return success;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_PROCESS
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 6e788d28f4..ed3273eb2e 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -81,7 +81,6 @@
#include <stdlib.h>
#ifdef Q_OS_WIN // for homedirpath reading from registry
-# include <private/qsystemlibrary_p.h>
# include <qt_windows.h>
# ifndef Q_OS_WINRT
# include <shlobj.h>
@@ -110,7 +109,7 @@ using namespace ABI::Windows::Storage;
#define Q_XDG_PLATFORM
#endif
-#if !defined(QT_NO_STANDARDPATHS) && (defined(Q_XDG_PLATFORM) || defined(Q_OS_IOS))
+#if !defined(QT_NO_STANDARDPATHS) && (defined(Q_XDG_PLATFORM) || defined(QT_PLATFORM_UIKIT))
#define QSETTINGS_USE_QSTANDARDPATHS
#endif
@@ -986,21 +985,12 @@ static QString windowsConfigPath(int type)
if (result.isEmpty()) {
switch (type) {
-#ifndef Q_OS_WINCE
case CSIDL_COMMON_APPDATA:
result = QLatin1String("C:\\temp\\qt-common");
break;
case CSIDL_APPDATA:
result = QLatin1String("C:\\temp\\qt-user");
break;
-#else
- case CSIDL_COMMON_APPDATA:
- result = QLatin1String("\\Temp\\qt-common");
- break;
- case CSIDL_APPDATA:
- result = QLatin1String("\\Temp\\qt-user");
- break;
-#endif
default:
;
}
diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp
index d73cc4d298..72160a4769 100644
--- a/src/corelib/io/qsettings_mac.cpp
+++ b/src/corelib/io/qsettings_mac.cpp
@@ -541,31 +541,7 @@ void QMacSettingsPrivate::sync()
domains[i].userName, hostNames[j]);
// only report failures for the primary file (the one we write to)
if (!ok && i == 0 && hostNames[j] == hostName && status == QSettings::NoError) {
-#if 1
- if (QSysInfo::macVersion() < QSysInfo::MV_10_7) {
- // work around what seems to be a bug in CFPreferences:
- // don't report an error if there are no preferences for the application
- QCFType<CFArrayRef> appIds = CFPreferencesCopyApplicationList(domains[i].userName,
- hostNames[j]);
-
- // iterate through all the applications and see if we're there
- CFIndex size = CFArrayGetCount(appIds);
- for (CFIndex k = 0; k < size; ++k) {
- const void *cfvalue = CFArrayGetValueAtIndex(appIds, k);
- if (CFGetTypeID(cfvalue) == CFStringGetTypeID()) {
- if (CFStringCompare(static_cast<CFStringRef>(cfvalue),
- domains[i].applicationOrSuiteId,
- kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
- setStatus(QSettings::AccessError);
- break;
- }
- }
- }
- } else
-#endif
- {
- setStatus(QSettings::AccessError);
- }
+ setStatus(QSettings::AccessError);
}
}
}
diff --git a/src/corelib/io/qsettings_win.cpp b/src/corelib/io/qsettings_win.cpp
index 05ed51e999..7c6b782acd 100644
--- a/src/corelib/io/qsettings_win.cpp
+++ b/src/corelib/io/qsettings_win.cpp
@@ -609,16 +609,12 @@ HKEY QWinSettingsPrivate::writeHandle() const
QWinSettingsPrivate::~QWinSettingsPrivate()
{
if (deleteWriteHandleOnExit && writeHandle() != 0) {
-#if defined(Q_OS_WINCE)
- remove(regList.at(0).key());
-#else
QString emptyKey;
DWORD res = RegDeleteKey(writeHandle(), reinterpret_cast<const wchar_t *>(emptyKey.utf16()));
if (res != ERROR_SUCCESS) {
qWarning("QSettings: Failed to delete key \"%s\": %s",
regList.at(0).key().toLatin1().data(), errorCodeToString(res).toLatin1().data());
}
-#endif
}
for (int i = 0; i < regList.size(); ++i)
@@ -660,10 +656,6 @@ void QWinSettingsPrivate::remove(const QString &uKey)
}
}
} else {
-#if defined(Q_OS_WINCE)
- // For WinCE always Close the handle first.
- RegCloseKey(handle);
-#endif
res = RegDeleteKey(writeHandle(), reinterpret_cast<const wchar_t *>(rKey.utf16()));
if (res != ERROR_SUCCESS) {
diff --git a/src/corelib/io/qstandardpaths_mac.mm b/src/corelib/io/qstandardpaths_mac.mm
index f08a6dac53..dc3d7737b6 100644
--- a/src/corelib/io/qstandardpaths_mac.mm
+++ b/src/corelib/io/qstandardpaths_mac.mm
@@ -117,7 +117,7 @@ static QString baseWritableLocation(QStandardPaths::StandardLocation type,
case QStandardPaths::TempLocation:
path = QDir::tempPath();
break;
-#ifdef Q_OS_IOS
+#if defined(QT_PLATFORM_UIKIT)
// These locations point to non-existing write-protected paths. Use sensible fallbacks.
case QStandardPaths::MusicLocation:
path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Music");
@@ -204,7 +204,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
{
QStringList dirs;
-#ifdef Q_OS_IOS
+#if defined(QT_PLATFORM_UIKIT)
if (type == PicturesLocation)
dirs << writableLocation(PicturesLocation) << QLatin1String("assets-library://");
#endif
diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp
index 9bd5a9e3b6..38c63553ea 100644
--- a/src/corelib/io/qstandardpaths_win.cpp
+++ b/src/corelib/io/qstandardpaths_win.cpp
@@ -51,13 +51,7 @@ const GUID qCLSID_FOLDERID_Downloads = { 0x374de290, 0x123f, 0x4565, { 0x91, 0x6
#include <qt_windows.h>
#include <shlobj.h>
-#if !defined(Q_OS_WINCE)
-# include <intshcut.h>
-#else
-# if !defined(STANDARDSHELL_UI_MODEL)
-# include <winx.h>
-# endif
-#endif
+#include <intshcut.h>
#ifndef CSIDL_MYMUSIC
#define CSIDL_MYMUSIC 13
@@ -117,7 +111,6 @@ static inline void appendTestMode(QString &path)
// Map QStandardPaths::StandardLocation to CLSID of SHGetSpecialFolderPath()
static int writableSpecialFolderClsid(QStandardPaths::StandardLocation type)
{
-#ifndef Q_OS_WINCE
static const int clsids[] = {
CSIDL_DESKTOPDIRECTORY, // DesktopLocation
CSIDL_PERSONAL, // DocumentsLocation
@@ -137,27 +130,6 @@ static int writableSpecialFolderClsid(QStandardPaths::StandardLocation type)
CSIDL_APPDATA, // AppDataLocation ("Roaming" path)
CSIDL_LOCAL_APPDATA, // AppConfigLocation ("Local" path)
};
-#else // !Q_OS_WINCE
- static const int clsids[] = {
- CSIDL_DESKTOPDIRECTORY, // DesktopLocation
- CSIDL_PERSONAL, // DocumentsLocation
- CSIDL_FONTS, // FontsLocation
- CSIDL_PROGRAMS, // ApplicationsLocation
- CSIDL_MYMUSIC, // MusicLocation
- CSIDL_MYVIDEO, // MoviesLocation
- CSIDL_MYPICTURES, // PicturesLocation
- -1, -1, // TempLocation/HomeLocation
- CSIDL_APPDATA, // AppLocalDataLocation, AppLocalDataLocation = DataLocation
- -1, // CacheLocation
- CSIDL_APPDATA, // GenericDataLocation
- -1, // RuntimeLocation
- CSIDL_APPDATA, // ConfigLocation
- -1, -1, // DownloadLocation/GenericCacheLocation
- CSIDL_APPDATA, // GenericConfigLocation
- CSIDL_APPDATA, // AppDataLocation
- CSIDL_APPDATA, // AppConfigLocation
- };
-#endif // Q_OS_WINCE
Q_STATIC_ASSERT(sizeof(clsids) / sizeof(clsids[0]) == size_t(QStandardPaths::AppConfigLocation + 1));
return size_t(type) < sizeof(clsids) / sizeof(clsids[0]) ? clsids[type] : -1;
@@ -183,7 +155,6 @@ static QString sHGetSpecialFolderPath(int clsid, QStandardPaths::StandardLocatio
static QString sHGetKnownFolderPath(const GUID &clsid, QStandardPaths::StandardLocation type, bool warn = false)
{
QString result;
-#ifndef Q_OS_WINCE
typedef HRESULT (WINAPI *GetKnownFolderPath)(const GUID&, DWORD, HANDLE, LPWSTR*);
static const GetKnownFolderPath sHGetKnownFolderPath = // Vista onwards.
@@ -199,11 +170,6 @@ static QString sHGetKnownFolderPath(const GUID &clsid, QStandardPaths::StandardL
qPrintable(displayName(type)));
}
}
-#else // !Q_OS_WINCE
- Q_UNUSED(clsid)
- Q_UNUSED(type)
- Q_UNUSED(warn)
-#endif
return result;
}
@@ -266,7 +232,6 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
dirs.append(localDir);
// type-specific handling goes here
-#ifndef Q_OS_WINCE
if (isConfigLocation(type)) {
QString programData = sHGetSpecialFolderPath(CSIDL_COMMON_APPDATA, type);
if (!programData.isEmpty()) {
@@ -274,12 +239,11 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
appendOrganizationAndApp(programData);
dirs.append(programData);
}
-# ifndef QT_BOOTSTRAPPED
+#ifndef QT_BOOTSTRAPPED
dirs.append(QCoreApplication::applicationDirPath());
dirs.append(QCoreApplication::applicationDirPath() + QLatin1String("/data"));
-# endif // !QT_BOOTSTRAPPED
+#endif // !QT_BOOTSTRAPPED
} // isConfigLocation()
-#endif // !Q_OS_WINCE
return dirs;
}
diff --git a/src/corelib/io/qstorageinfo_p.h b/src/corelib/io/qstorageinfo_p.h
index 744653ea42..9dc66f2d69 100644
--- a/src/corelib/io/qstorageinfo_p.h
+++ b/src/corelib/io/qstorageinfo_p.h
@@ -70,7 +70,7 @@ public:
static QStorageInfo root();
protected:
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
void retrieveVolumeInfo();
void retrieveDiskFreeSpace();
#elif defined(Q_OS_MAC)
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index 0b0446a37e..c430c7714a 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -404,7 +404,12 @@ bool QTemporaryFileEngine::close()
//************* QTemporaryFilePrivate
-QTemporaryFilePrivate::QTemporaryFilePrivate() : autoRemove(true)
+QTemporaryFilePrivate::QTemporaryFilePrivate()
+{
+}
+
+QTemporaryFilePrivate::QTemporaryFilePrivate(const QString &templateNameIn)
+ : templateName(templateNameIn)
{
}
@@ -498,15 +503,11 @@ QString QTemporaryFilePrivate::defaultTemplateName()
QTemporaryFile::QTemporaryFile()
: QFile(*new QTemporaryFilePrivate)
{
- Q_D(QTemporaryFile);
- d->templateName = QTemporaryFilePrivate::defaultTemplateName();
}
QTemporaryFile::QTemporaryFile(const QString &templateName)
- : QFile(*new QTemporaryFilePrivate)
+ : QFile(*new QTemporaryFilePrivate(templateName))
{
- Q_D(QTemporaryFile);
- d->templateName = templateName;
}
#else
@@ -519,10 +520,8 @@ QTemporaryFile::QTemporaryFile(const QString &templateName)
\sa setFileTemplate(), QDir::tempPath()
*/
QTemporaryFile::QTemporaryFile()
- : QFile(*new QTemporaryFilePrivate, 0)
+ : QTemporaryFile(nullptr)
{
- Q_D(QTemporaryFile);
- d->templateName = QTemporaryFilePrivate::defaultTemplateName();
}
/*!
@@ -540,10 +539,8 @@ QTemporaryFile::QTemporaryFile()
\sa open(), fileTemplate()
*/
QTemporaryFile::QTemporaryFile(const QString &templateName)
- : QFile(*new QTemporaryFilePrivate, 0)
+ : QTemporaryFile(templateName, nullptr)
{
- Q_D(QTemporaryFile);
- d->templateName = templateName;
}
/*!
@@ -557,8 +554,6 @@ QTemporaryFile::QTemporaryFile(const QString &templateName)
QTemporaryFile::QTemporaryFile(QObject *parent)
: QFile(*new QTemporaryFilePrivate, parent)
{
- Q_D(QTemporaryFile);
- d->templateName = QTemporaryFilePrivate::defaultTemplateName();
}
/*!
@@ -577,10 +572,8 @@ QTemporaryFile::QTemporaryFile(QObject *parent)
\sa open(), fileTemplate()
*/
QTemporaryFile::QTemporaryFile(const QString &templateName, QObject *parent)
- : QFile(*new QTemporaryFilePrivate, parent)
+ : QFile(*new QTemporaryFilePrivate(templateName), parent)
{
- Q_D(QTemporaryFile);
- d->templateName = templateName;
}
#endif
diff --git a/src/corelib/io/qtemporaryfile_p.h b/src/corelib/io/qtemporaryfile_p.h
index 58cc318ffd..d057603034 100644
--- a/src/corelib/io/qtemporaryfile_p.h
+++ b/src/corelib/io/qtemporaryfile_p.h
@@ -67,13 +67,14 @@ class QTemporaryFilePrivate : public QFilePrivate
protected:
QTemporaryFilePrivate();
+ explicit QTemporaryFilePrivate(const QString &templateNameIn);
~QTemporaryFilePrivate();
QAbstractFileEngine *engine() const;
void resetFileEngine() const;
- bool autoRemove;
- QString templateName;
+ bool autoRemove = true;
+ QString templateName = defaultTemplateName();
static QString defaultTemplateName();
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 27b7570226..b8db23329a 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -231,9 +231,7 @@ static const int QTEXTSTREAM_BUFFERSIZE = 16384;
#include "qnumeric.h"
#include "qvarlengtharray.h"
-#ifndef Q_OS_WINCE
#include <locale.h>
-#endif
#include "private/qlocale_p.h"
#include <stdlib.h>
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 451e3b2967..40fc492d91 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -413,9 +413,6 @@
#include "qtldurl_p.h"
#include "private/qipaddress_p.h"
#include "qurlquery.h"
-#if defined(Q_OS_WINCE_WM)
-#pragma optimize("g", off)
-#endif
QT_BEGIN_NAMESPACE
extern QString qt_normalizePathSegments(const QString &name, bool allowUncPaths); // qdir.cpp
@@ -3454,33 +3451,6 @@ QByteArray QUrl::toPercentEncoding(const QString &input, const QByteArray &exclu
return input.toUtf8().toPercentEncoding(exclude, include);
}
-/*! \fn QUrl QUrl::fromCFURL(CFURLRef url)
- \since 5.2
-
- Constructs a QUrl containing a copy of the CFURL \a url.
-*/
-
-/*! \fn CFURLRef QUrl::toCFURL() const
- \since 5.2
-
- Creates a CFURL from a QUrl. The caller owns the CFURL and is
- responsible for releasing it.
-*/
-
-/*!
- \fn QUrl QUrl::fromNSURL(const NSURL *url)
- \since 5.2
-
- Constructs a QUrl containing a copy of the NSURL \a url.
-*/
-
-/*!
- \fn NSURL* QUrl::toNSURL() const
- \since 5.2
-
- Creates a NSURL from a QUrl. The NSURL is autoreleased.
-*/
-
/*!
\internal
\since 5.0
diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h
index 947b3bbb55..bce271fcb1 100644
--- a/src/corelib/io/qurl.h
+++ b/src/corelib/io/qurl.h
@@ -48,11 +48,9 @@
#include <QtCore/qpair.h>
#include <QtCore/qglobal.h>
-#ifdef Q_OS_MAC
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_FORWARD_DECLARE_CF_TYPE(CFURL);
-# ifdef __OBJC__
Q_FORWARD_DECLARE_OBJC_CLASS(NSURL);
-# endif
#endif
QT_BEGIN_NAMESPACE
@@ -164,6 +162,12 @@ public:
};
Q_DECLARE_FLAGS(ComponentFormattingOptions, ComponentFormattingOption)
#ifdef Q_QDOC
+private:
+ // We need to let qdoc think that FormattingOptions is a normal QFlags, but
+ // it needs to be a QUrlTwoFlags for compiling default arguments of somme functions.
+ template<typename T> struct QFlags : QUrlTwoFlags<T, ComponentFormattingOption>
+ { using QUrlTwoFlags<T, ComponentFormattingOption>::QUrlTwoFlags; };
+public:
Q_DECLARE_FLAGS(FormattingOptions, UrlFormattingOption)
#else
typedef QUrlTwoFlags<UrlFormattingOption, ComponentFormattingOption> FormattingOptions;
@@ -271,13 +275,11 @@ public:
static QByteArray toPercentEncoding(const QString &,
const QByteArray &exclude = QByteArray(),
const QByteArray &include = QByteArray());
-#if defined(Q_OS_MAC) || defined(Q_QDOC)
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
static QUrl fromCFURL(CFURLRef url);
CFURLRef toCFURL() const Q_DECL_CF_RETURNS_RETAINED;
-# if defined(__OBJC__) || defined(Q_QDOC)
static QUrl fromNSURL(const NSURL *url);
NSURL *toNSURL() const Q_DECL_NS_RETURNS_AUTORELEASED;
-# endif
#endif
#if QT_DEPRECATED_SINCE(5,0)
@@ -372,6 +374,7 @@ Q_DECLARE_SHARED(QUrl)
Q_DECLARE_OPERATORS_FOR_FLAGS(QUrl::ComponentFormattingOptions)
//Q_DECLARE_OPERATORS_FOR_FLAGS(QUrl::FormattingOptions)
+#ifndef Q_QDOC
Q_DECL_CONSTEXPR inline QUrl::FormattingOptions operator|(QUrl::UrlFormattingOption f1, QUrl::UrlFormattingOption f2)
{ return QUrl::FormattingOptions(f1) | f2; }
Q_DECL_CONSTEXPR inline QUrl::FormattingOptions operator|(QUrl::UrlFormattingOption f1, QUrl::FormattingOptions f2)
@@ -399,6 +402,7 @@ Q_DECL_CONSTEXPR inline QUrl::FormattingOptions operator|(QUrl::ComponentFormatt
//inline QUrl::UrlFormattingOption &operator=(const QUrl::UrlFormattingOption &i, QUrl::ComponentFormattingOptions f)
//{ i = int(f); f; }
+#endif // Q_QDOC
#ifndef QT_NO_DATASTREAM
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QUrl &);
diff --git a/src/corelib/io/qurl_mac.mm b/src/corelib/io/qurl_mac.mm
deleted file mode 100644
index 04d05f1b23..0000000000
--- a/src/corelib/io/qurl_mac.mm
+++ /dev/null
@@ -1,74 +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 "qurl.h"
-
-#ifdef Q_OS_MAC
-#include <Foundation/Foundation.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-QUrl QUrl::fromCFURL(CFURLRef url)
-{
- return QUrl(QString::fromCFString(CFURLGetString(url)));
-}
-
-CFURLRef QUrl::toCFURL() const
-{
- CFURLRef url = 0;
- CFStringRef str = toString(FullyEncoded).toCFString();
- if (str) {
- url = CFURLCreateWithString(0, str, 0);
- CFRelease(str);
- }
- return url;
-}
-
-QUrl QUrl::fromNSURL(const NSURL *url)
-{
- return QUrl(QString::fromNSString([url absoluteString]));
-}
-
-NSURL *QUrl::toNSURL() const
-{
- return [NSURL URLWithString:toString(FullyEncoded).toNSString()];
-}
-
-QT_END_NAMESPACE
diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp
index 15fb276be9..b8df8e8084 100644
--- a/src/corelib/io/qwindowspipereader.cpp
+++ b/src/corelib/io/qwindowspipereader.cpp
@@ -71,21 +71,6 @@ QWindowsPipeReader::QWindowsPipeReader(QObject *parent)
this, &QWindowsPipeReader::emitPendingReadyRead, Qt::QueuedConnection);
}
-bool qt_cancelIo(HANDLE handle, OVERLAPPED *overlapped)
-{
- typedef BOOL (WINAPI *PtrCancelIoEx)(HANDLE, LPOVERLAPPED);
- static PtrCancelIoEx ptrCancelIoEx = 0;
- if (!ptrCancelIoEx) {
- HMODULE kernel32 = GetModuleHandleA("kernel32");
- if (kernel32)
- ptrCancelIoEx = PtrCancelIoEx(GetProcAddress(kernel32, "CancelIoEx"));
- }
- if (ptrCancelIoEx)
- return ptrCancelIoEx(handle, overlapped);
- else
- return CancelIo(handle);
-}
-
QWindowsPipeReader::~QWindowsPipeReader()
{
stop();
@@ -110,7 +95,7 @@ void QWindowsPipeReader::stop()
{
stopped = true;
if (readSequenceStarted) {
- if (!qt_cancelIo(handle, &overlapped)) {
+ if (!CancelIoEx(handle, &overlapped)) {
const DWORD dwError = GetLastError();
if (dwError != ERROR_NOT_FOUND) {
qErrnoWarning(dwError, "QWindowsPipeReader: qt_cancelIo on handle %x failed.",
diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp
index b0ca0d979b..3ab2c70c75 100644
--- a/src/corelib/io/qwindowspipewriter.cpp
+++ b/src/corelib/io/qwindowspipewriter.cpp
@@ -42,9 +42,6 @@
QT_BEGIN_NAMESPACE
-extern bool qt_cancelIo(HANDLE handle, OVERLAPPED *overlapped); // from qwindowspipereader.cpp
-
-
QWindowsPipeWriter::Overlapped::Overlapped(QWindowsPipeWriter *pipeWriter)
: pipeWriter(pipeWriter)
{
@@ -211,7 +208,7 @@ void QWindowsPipeWriter::stop()
bytesWrittenPending = false;
pendingBytesWrittenValue = 0;
if (writeSequenceStarted) {
- if (!qt_cancelIo(handle, &overlapped)) {
+ if (!CancelIoEx(handle, &overlapped)) {
const DWORD dwError = GetLastError();
if (dwError != ERROR_NOT_FOUND) {
qErrnoWarning(dwError, "QWindowsPipeWriter: qt_cancelIo on handle %x failed.",
diff --git a/src/corelib/json/qjson_p.h b/src/corelib/json/qjson_p.h
index b0a634cb4a..f2fcb767d5 100644
--- a/src/corelib/json/qjson_p.h
+++ b/src/corelib/json/qjson_p.h
@@ -396,7 +396,7 @@ public:
const ushort *uc = (const ushort *)str.unicode();
int i = 0;
#ifdef __SSE2__
- for ( ; i + 16 < len; i += 16) {
+ for ( ; i + 16 <= len; i += 16) {
__m128i chunk1 = _mm_loadu_si128((__m128i*)&uc[i]); // load
__m128i chunk2 = _mm_loadu_si128((__m128i*)&uc[i + 8]); // load
// pack the two vector to 16 x 8bits elements
@@ -405,7 +405,7 @@ public:
}
# ifdef Q_PROCESSOR_X86_64
// we can do one more round, of 8 characters
- if (i + 8 < len) {
+ if (i + 8 <= len) {
__m128i chunk = _mm_loadu_si128((__m128i*)&uc[i]); // load
// pack with itself, we'll discard the high part anyway
chunk = _mm_packus_epi16(chunk, chunk);
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index 8c16e10c27..991b73812a 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -84,14 +84,6 @@ win32 {
}
}
-wince {
- SOURCES += \
- kernel/qfunctions_wince.cpp
- HEADERS += \
- kernel/qfunctions_fake_env_p.h \
- kernel/qfunctions_wince.h
-}
-
winrt {
SOURCES += \
kernel/qfunctions_winrt.cpp
@@ -109,7 +101,8 @@ mac {
SOURCES += \
kernel/qcfsocketnotifier.cpp \
kernel/qcoreapplication_mac.cpp \
- kernel/qcore_mac.cpp
+ kernel/qcore_mac.cpp \
+ kernel/qcore_foundation.mm
OBJECTIVE_SOURCES += \
kernel/qcore_mac_objc.mm \
@@ -119,7 +112,7 @@ mac {
osx: LIBS_PRIVATE += -framework CoreServices -framework AppKit
- ios {
+ uikit {
# We need UIKit for UIDevice
LIBS_PRIVATE += -framework UIKit
}
@@ -156,8 +149,8 @@ unix|integrity {
kernel/qeventdispatcher_glib.cpp
HEADERS += \
kernel/qeventdispatcher_glib_p.h
- QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB
- LIBS_PRIVATE +=$$QT_LIBS_GLIB
+ QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_GLIB
+ LIBS_PRIVATE +=$$QMAKE_LIBS_GLIB
}
contains(QT_CONFIG, clock-gettime):include($$QT_SOURCE_TREE/config.tests/unix/clock-gettime/clock-gettime.pri)
diff --git a/src/corelib/kernel/qcore_foundation.mm b/src/corelib/kernel/qcore_foundation.mm
new file mode 100644
index 0000000000..a488f4066d
--- /dev/null
+++ b/src/corelib/kernel/qcore_foundation.mm
@@ -0,0 +1,462 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2014 Samuel Gaist <samuel.gaist@edeltech.ch>
+** Copyright (C) 2014 Petroules Corporation.
+** 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 <QtCore/qstring.h>
+#include <QtCore/qurl.h>
+#include <QtCore/qdatetime.h>
+#include <QtCore/quuid.h>
+#include <QtCore/qbytearray.h>
+#include <QtCore/qrect.h>
+
+#import <Foundation/Foundation.h>
+
+#if defined(QT_PLATFORM_UIKIT)
+#import <CoreGraphics/CoreGraphics.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \since 5.3
+
+ Constructs a new QByteArray containing a copy of the CFData \a data.
+
+ \sa fromRawCFData(), fromRawData(), toRawCFData(), toCFData()
+*/
+QByteArray QByteArray::fromCFData(CFDataRef data)
+{
+ if (!data)
+ return QByteArray();
+
+ return QByteArray(reinterpret_cast<const char *>(CFDataGetBytePtr(data)), CFDataGetLength(data));
+}
+
+/*!
+ \since 5.3
+
+ Constructs a QByteArray that uses the bytes of the CFData \a data.
+
+ The \a data's bytes are not copied.
+
+ The caller guarantees that the CFData will not be deleted
+ or modified as long as this QByteArray object exists.
+
+ \sa fromCFData(), fromRawData(), toRawCFData(), toCFData()
+*/
+QByteArray QByteArray::fromRawCFData(CFDataRef data)
+{
+ if (!data)
+ return QByteArray();
+
+ return QByteArray::fromRawData(reinterpret_cast<const char *>(CFDataGetBytePtr(data)), CFDataGetLength(data));
+}
+
+/*!
+ \since 5.3
+
+ Creates a CFData from a QByteArray. The caller owns the CFData object
+ and is responsible for releasing it.
+
+ \sa toRawCFData(), fromCFData(), fromRawCFData(), fromRawData()
+*/
+CFDataRef QByteArray::toCFData() const
+{
+ return CFDataCreate(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(data()), length());
+}
+
+/*!
+ \since 5.3
+
+ Constructs a CFData that uses the bytes of the QByteArray.
+
+ The QByteArray's bytes are not copied.
+
+ The caller guarantees that the QByteArray will not be deleted
+ or modified as long as this CFData object exists.
+
+ \sa toCFData(), fromRawCFData(), fromCFData(), fromRawData()
+*/
+CFDataRef QByteArray::toRawCFData() const
+{
+ return CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(data()),
+ length(), kCFAllocatorNull);
+}
+
+/*!
+ \since 5.3
+
+ Constructs a new QByteArray containing a copy of the NSData \a data.
+
+ \sa fromRawNSData(), fromRawData(), toNSData(), toRawNSData()
+*/
+QByteArray QByteArray::fromNSData(const NSData *data)
+{
+ if (!data)
+ return QByteArray();
+ return QByteArray(reinterpret_cast<const char *>([data bytes]), [data length]);
+}
+
+/*!
+ \since 5.3
+
+ Constructs a QByteArray that uses the bytes of the NSData \a data.
+
+ The \a data's bytes are not copied.
+
+ The caller guarantees that the NSData will not be deleted
+ or modified as long as this QByteArray object exists.
+
+ \sa fromNSData(), fromRawData(), toRawNSData(), toNSData()
+*/
+QByteArray QByteArray::fromRawNSData(const NSData *data)
+{
+ if (!data)
+ return QByteArray();
+ return QByteArray::fromRawData(reinterpret_cast<const char *>([data bytes]), [data length]);
+}
+
+/*!
+ \since 5.3
+
+ Creates a NSData from a QByteArray. The NSData object is autoreleased.
+
+ \sa fromNSData(), fromRawNSData(), fromRawData(), toRawNSData()
+*/
+NSData *QByteArray::toNSData() const
+{
+ return [NSData dataWithBytes:constData() length:size()];
+}
+
+/*!
+ \since 5.3
+
+ Constructs a NSData that uses the bytes of the QByteArray.
+
+ The QByteArray's bytes are not copied.
+
+ The caller guarantees that the QByteArray will not be deleted
+ or modified as long as this NSData object exists.
+
+ \sa fromRawNSData(), fromNSData(), fromRawData(), toNSData()
+*/
+NSData *QByteArray::toRawNSData() const
+{
+ // const_cast is fine here because NSData is immutable thus will never modify bytes we're giving it
+ return [NSData dataWithBytesNoCopy:const_cast<char *>(constData()) length:size() freeWhenDone:NO];
+}
+
+// ----------------------------------------------------------------------------
+
+/*!
+ \since 5.2
+
+ Constructs a new QString containing a copy of the \a string CFString.
+
+ \note this function is only available on OS X and iOS.
+*/
+QString QString::fromCFString(CFStringRef string)
+{
+ if (!string)
+ return QString();
+ CFIndex length = CFStringGetLength(string);
+
+ // Fast path: CFStringGetCharactersPtr does not copy but may
+ // return null for any and no reason.
+ const UniChar *chars = CFStringGetCharactersPtr(string);
+ if (chars)
+ return QString(reinterpret_cast<const QChar *>(chars), length);
+
+ QString ret(length, Qt::Uninitialized);
+ CFStringGetCharacters(string, CFRangeMake(0, length), reinterpret_cast<UniChar *>(ret.data()));
+ return ret;
+}
+
+/*!
+ \since 5.2
+
+ Creates a CFString from a QString. The caller owns the CFString and is
+ responsible for releasing it.
+
+ \note this function is only available on OS X and iOS.
+*/
+CFStringRef QString::toCFString() const
+{
+ return CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar *>(unicode()), length());
+}
+
+/*!
+ \since 5.2
+
+ Constructs a new QString containing a copy of the \a string NSString.
+
+ \note this function is only available on OS X and iOS.
+*/
+QString QString::fromNSString(const NSString *string)
+{
+ if (!string)
+ return QString();
+ QString qstring;
+ qstring.resize([string length]);
+ [string getCharacters: reinterpret_cast<unichar*>(qstring.data()) range: NSMakeRange(0, [string length])];
+ return qstring;
+}
+
+/*!
+ \since 5.2
+
+ Creates a NSString from a QString. The NSString is autoreleased.
+
+ \note this function is only available on OS X and iOS.
+*/
+NSString *QString::toNSString() const
+{
+ return [NSString stringWithCharacters: reinterpret_cast<const UniChar*>(unicode()) length: length()];
+}
+
+// ----------------------------------------------------------------------------
+
+/*!
+ \since 5.7
+
+ Constructs a new QUuid containing a copy of the \a uuid CFUUID.
+
+ \note this function is only available on Apple platforms.
+*/
+QUuid QUuid::fromCFUUID(CFUUIDRef uuid)
+{
+ if (!uuid)
+ return QUuid();
+ const CFUUIDBytes bytes = CFUUIDGetUUIDBytes(uuid);
+ return QUuid::fromRfc4122(QByteArray::fromRawData(reinterpret_cast<const char *>(&bytes), sizeof(bytes)));
+}
+
+/*!
+ \since 5.7
+
+ Creates a CFUUID from a QUuid. The caller owns the CFUUID and is
+ responsible for releasing it.
+
+ \note this function is only available on Apple platforms.
+*/
+CFUUIDRef QUuid::toCFUUID() const
+{
+ const QByteArray bytes = toRfc4122();
+ return CFUUIDCreateFromUUIDBytes(0, *reinterpret_cast<const CFUUIDBytes *>(bytes.constData()));
+}
+
+/*!
+ \since 5.7
+
+ Constructs a new QUuid containing a copy of the \a uuid NSUUID.
+
+ \note this function is only available on Apple platforms.
+*/
+QUuid QUuid::fromNSUUID(const NSUUID *uuid)
+{
+ if (!uuid)
+ return QUuid();
+ uuid_t bytes;
+ [uuid getUUIDBytes:bytes];
+ return QUuid::fromRfc4122(QByteArray::fromRawData(reinterpret_cast<const char *>(bytes), sizeof(bytes)));
+}
+
+/*!
+ \since 5.7
+
+ Creates a NSUUID from a QUuid. The NSUUID is autoreleased.
+
+ \note this function is only available on Apple platforms.
+*/
+NSUUID *QUuid::toNSUUID() const
+{
+ const QByteArray bytes = toRfc4122();
+ return [[[NSUUID alloc] initWithUUIDBytes:*reinterpret_cast<const uuid_t *>(bytes.constData())] autorelease];
+}
+
+// ----------------------------------------------------------------------------
+
+
+/*!
+ \since 5.2
+
+ Constructs a QUrl containing a copy of the CFURL \a url.
+*/
+QUrl QUrl::fromCFURL(CFURLRef url)
+{
+ return QUrl(QString::fromCFString(CFURLGetString(url)));
+}
+
+/*!
+ \since 5.2
+
+ Creates a CFURL from a QUrl. The caller owns the CFURL and is
+ responsible for releasing it.
+*/
+CFURLRef QUrl::toCFURL() const
+{
+ CFURLRef url = 0;
+ CFStringRef str = toString(FullyEncoded).toCFString();
+ if (str) {
+ url = CFURLCreateWithString(0, str, 0);
+ CFRelease(str);
+ }
+ return url;
+}
+
+/*!
+ \since 5.2
+
+ Constructs a QUrl containing a copy of the NSURL \a url.
+*/
+QUrl QUrl::fromNSURL(const NSURL *url)
+{
+ return QUrl(QString::fromNSString([url absoluteString]));
+}
+
+/*!
+ \since 5.2
+
+ Creates a NSURL from a QUrl. The NSURL is autoreleased.
+*/
+NSURL *QUrl::toNSURL() const
+{
+ return [NSURL URLWithString:toString(FullyEncoded).toNSString()];
+}
+
+// ----------------------------------------------------------------------------
+
+
+/*!
+ \since 5.5
+
+ Constructs a new QDateTime containing a copy of the CFDate \a date.
+
+ \sa toCFDate()
+*/
+QDateTime QDateTime::fromCFDate(CFDateRef date)
+{
+ if (!date)
+ return QDateTime();
+ return QDateTime::fromMSecsSinceEpoch(static_cast<qint64>((CFDateGetAbsoluteTime(date)
+ + kCFAbsoluteTimeIntervalSince1970) * 1000));
+}
+
+/*!
+ \since 5.5
+
+ Creates a CFDate from a QDateTime. The caller owns the CFDate object
+ and is responsible for releasing it.
+
+ \sa fromCFDate()
+*/
+CFDateRef QDateTime::toCFDate() const
+{
+ return CFDateCreate(kCFAllocatorDefault, (static_cast<CFAbsoluteTime>(toMSecsSinceEpoch())
+ / 1000) - kCFAbsoluteTimeIntervalSince1970);
+}
+
+/*!
+ \since 5.5
+
+ Constructs a new QDateTime containing a copy of the NSDate \a date.
+
+ \sa toNSDate()
+*/
+QDateTime QDateTime::fromNSDate(const NSDate *date)
+{
+ if (!date)
+ return QDateTime();
+ return QDateTime::fromMSecsSinceEpoch(static_cast<qint64>([date timeIntervalSince1970] * 1000));
+}
+
+/*!
+ \since 5.5
+
+ Creates an NSDate from a QDateTime. The NSDate object is autoreleased.
+
+ \sa fromNSDate()
+*/
+NSDate *QDateTime::toNSDate() const
+{
+ return [NSDate
+ dateWithTimeIntervalSince1970:static_cast<NSTimeInterval>(toMSecsSinceEpoch()) / 1000];
+}
+
+// ----------------------------------------------------------------------------
+
+/*!
+ \since 5.8
+
+ Creates a CGRect from a QRect.
+
+ \sa fromCGRect()
+*/
+CGRect QRect::toCGRect() const Q_DECL_NOTHROW
+{
+ return CGRectMake(x(), y(), width(), height());
+}
+
+/*!
+ \since 5.8
+
+ Creates a CGRect from a QRectF.
+
+ \sa fromCGRect()
+*/
+CGRect QRectF::toCGRect() const Q_DECL_NOTHROW
+{
+ return CGRectMake(x(), y(), width(), height());
+}
+
+/*!
+ \since 5.8
+
+ Creates a QRectF from a CGRect.
+
+ \sa toCGRect()
+*/
+QRectF QRectF::fromCGRect(CGRect rect) Q_DECL_NOTHROW
+{
+ return QRectF(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm
index de491dd43d..068b6b0440 100644
--- a/src/corelib/kernel/qcore_mac_objc.mm
+++ b/src/corelib/kernel/qcore_mac_objc.mm
@@ -47,7 +47,7 @@
#include <qdebug.h>
-#ifdef Q_OS_IOS
+#if defined(Q_OS_IOS)
#import <UIKit/UIKit.h>
#endif
@@ -101,7 +101,7 @@ QT_FOR_EACH_MUTABLE_CORE_GRAPHICS_TYPE(QT_DECLARE_WEAK_QDEBUG_OPERATOR_FOR_CF_TY
QAppleOperatingSystemVersion qt_apple_os_version()
{
QAppleOperatingSystemVersion v = {0, 0, 0};
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_10, __IPHONE_8_0)
+#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_10, __IPHONE_8_0) || defined(Q_OS_TVOS)
if ([NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)]) {
NSOperatingSystemVersion osv = NSProcessInfo.processInfo.operatingSystemVersion;
v.major = osv.majorVersion;
diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h
index 53f2a50191..6ed316254b 100644
--- a/src/corelib/kernel/qcore_unix_p.h
+++ b/src/corelib/kernel/qcore_unix_p.h
@@ -294,8 +294,8 @@ static inline int qt_safe_close(int fd)
#undef QT_CLOSE
#define QT_CLOSE qt_safe_close
-// - VxWorks doesn't have processes
-#if !defined(Q_OS_VXWORKS)
+// - VxWorks & iOS/tvOS don't have processes
+#if !defined(Q_OS_VXWORKS) && !defined(QT_NO_PROCESS)
static inline int qt_safe_execve(const char *filename, char *const argv[],
char *const envp[])
{
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 7bb2e7a78c..aa08a23f6b 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -1299,19 +1299,6 @@ void QCoreApplication::exit(int returnCode)
QEventLoop *eventLoop = data->eventLoops.at(i);
eventLoop->exit(returnCode);
}
-#ifdef Q_OS_WINRT
- qWarning("QCoreApplication::exit: It is not recommended to explicitly exit an application on Windows Store Apps");
- ComPtr<ICoreApplication> app;
- HRESULT hr = RoGetActivationFactory(Wrappers::HString::MakeReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(),
- IID_PPV_ARGS(&app));
- RETURN_VOID_IF_FAILED("Could not acquire ICoreApplication object");
- ComPtr<ICoreApplicationExit> appExit;
-
- hr = app.As(&appExit);
- RETURN_VOID_IF_FAILED("Could not acquire ICoreApplicationExit object");
- hr = appExit->Exit();
- RETURN_VOID_IF_FAILED("Could not exit application");
-#endif // Q_OS_WINRT
}
/*****************************************************************************
@@ -2261,14 +2248,6 @@ QStringList QCoreApplication::arguments()
// classes by index.
QString cmdline = QString::fromWCharArray(GetCommandLine());
-#if defined(Q_OS_WINCE)
- wchar_t tempFilename[MAX_PATH+1];
- if (GetModuleFileName(0, tempFilename, MAX_PATH)) {
- tempFilename[MAX_PATH] = 0;
- cmdline.prepend(QLatin1Char('\"') + QString::fromWCharArray(tempFilename) + QLatin1String("\" "));
- }
-#endif // Q_OS_WINCE
-
const QCoreApplicationPrivate *d = self->d_func();
if (d->origArgv) {
const QStringList allArguments = qWinCmdArgs(cmdline);
@@ -2499,6 +2478,26 @@ QStringList QCoreApplication::libraryPaths()
}
}
+#ifdef Q_OS_DARWIN
+ // Check the main bundle's PlugIns directory as this is a standard location for Apple OSes.
+ // Note that the QLibraryInfo::PluginsPath below will coincidentally be the same as this value
+ // but with a different casing, so it can't be relied upon when the underlying filesystem
+ // is case sensitive (and this is always the case on newer OSes like iOS).
+ if (CFBundleRef bundleRef = CFBundleGetMainBundle()) {
+ if (QCFType<CFURLRef> urlRef = CFBundleCopyBuiltInPlugInsURL(bundleRef)) {
+ if (QCFType<CFURLRef> absoluteUrlRef = CFURLCopyAbsoluteURL(urlRef)) {
+ if (QCFString path = CFURLCopyFileSystemPath(absoluteUrlRef, kCFURLPOSIXPathStyle)) {
+ if (QFile::exists(path)) {
+ path = QDir(path).canonicalPath();
+ if (!app_libpaths->contains(path))
+ app_libpaths->append(path);
+ }
+ }
+ }
+ }
+ }
+#endif // Q_OS_DARWIN
+
QString installPathPlugins = QLibraryInfo::location(QLibraryInfo::PluginsPath);
if (QFile::exists(installPathPlugins)) {
// Make sure we convert from backslashes to slashes.
diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp
index 601733b939..342e6227f2 100644
--- a/src/corelib/kernel/qcoreapplication_win.cpp
+++ b/src/corelib/kernel/qcoreapplication_win.cpp
@@ -81,16 +81,12 @@ Q_CORE_EXPORT HINSTANCE qWinAppPrevInst() // get Windows prev app
Q_CORE_EXPORT int qWinAppCmdShow() // get main window show command
{
-#if defined(Q_OS_WINCE)
- return appCmdShow;
-#else
STARTUPINFO startupInfo;
GetStartupInfo(&startupInfo);
return (startupInfo.dwFlags & STARTF_USESHOWWINDOW)
? startupInfo.wShowWindow
: SW_SHOWDEFAULT;
-#endif
}
Q_CORE_EXPORT QString qAppFileName() // get application file name
@@ -143,7 +139,7 @@ QString QCoreApplicationPrivate::appName() const
qWinMain() - Initializes Windows. Called from WinMain() in qtmain_win.cpp
*****************************************************************************/
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
// ### Qt6: FIXME: Consider removing this function. It is here for Active Qt
// servers and for binary for compatibility to applications built with Qt 5.3
@@ -164,30 +160,7 @@ void qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam,
argv.append(_strdup(wArg.toLocal8Bit().constData()));
}
-#elif defined(Q_OS_WINCE)
-
-Q_CORE_EXPORT void __cdecl qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam,
- int cmdShow, int &argc, QVector<char *> &argv)
-{
- static bool already_called = false;
-
- if (already_called) {
- qWarning("Qt: Internal error: qWinMain should be called only once");
- return;
- }
- already_called = true;
-
- // Create command line
- argv = qWinCmdLine<char>(cmdParam, int(strlen(cmdParam)), argc);
-
- appCmdShow = cmdShow;
-
- // Ignore Windows parameters
- Q_UNUSED(instance);
- Q_UNUSED(prevInstance);
-}
-
-#endif // Q_OS_WINCE
+#endif // !Q_OS_WINRT
#ifndef QT_NO_QOBJECT
@@ -205,11 +178,6 @@ QT_END_INCLUDE_NAMESPACE
# define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
# define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
#endif
-#ifdef _WIN32_WCE
-# ifndef WM_NCACTIVATE
-# define WM_NCACTIVATE 0x86
-# endif
-#endif
// The values below should never change. Note that none of the usual
// WM_...FIRST & WM_...LAST values are in the list, as they normally have other
diff --git a/src/corelib/kernel/qcorecmdlineargs_p.h b/src/corelib/kernel/qcorecmdlineargs_p.h
index 2d8de08f2d..c5d9d130f0 100644
--- a/src/corelib/kernel/qcorecmdlineargs_p.h
+++ b/src/corelib/kernel/qcorecmdlineargs_p.h
@@ -81,93 +81,7 @@ static inline QStringList qWinCmdArgs(const QString &cmdLine)
return result;
}
-#elif defined(Q_OS_WINCE) // Q_OS_WIN32
-
-// template implementation of the parsing algorithm
-// this is used from qcoreapplication_win.cpp and the tools (rcc, uic...)
-
-template<typename Char>
-static QVector<Char*> qWinCmdLine(Char *cmdParam, int length, int &argc)
-{
- QVector<Char*> argv(8);
- Char *p = cmdParam;
- Char *p_end = p + length;
-
- argc = 0;
-
- while (*p && p < p_end) { // parse cmd line arguments
- while (QChar((short)(*p)).isSpace()) // skip white space
- p++;
- if (*p && p < p_end) { // arg starts
- int quote;
- Char *start, *r;
- if (*p == Char('\"')) {
- quote = *p;
- start = ++p;
- } else {
- quote = 0;
- start = p;
- }
- r = start;
- while (*p && p < p_end) {
- if (quote) {
- if (*p == quote) {
- p++;
- if (QChar((short)(*p)).isSpace())
- break;
- quote = 0;
- }
- }
- if (*p == '\\') { // escape char?
- // testing by looking at argc, argv shows that it only escapes quotes
- if (p < p_end && (*(p+1) == Char('\"')))
- p++;
- } else {
- if (!quote && (*p == Char('\"'))) {
- quote = *p++;
- continue;
- } else if (QChar((short)(*p)).isSpace() && !quote)
- break;
- }
- if (*p)
- *r++ = *p++;
- }
- if (*p && p < p_end)
- p++;
- *r = Char('\0');
-
- if (argc >= (int)argv.size()-1) // expand array
- argv.resize(argv.size()*2);
- argv[argc++] = start;
- }
- }
- argv[argc] = 0;
-
- return argv;
-}
-
-static inline QStringList qWinCmdArgs(QString cmdLine) // not const-ref: this might be modified
-{
- QStringList args;
-
- int argc = 0;
- QVector<wchar_t*> argv = qWinCmdLine<wchar_t>((wchar_t *)cmdLine.utf16(), cmdLine.length(), argc);
- for (int a = 0; a < argc; ++a) {
- args << QString::fromWCharArray(argv[a]);
- }
-
- return args;
-}
-
-static inline QStringList qCmdLineArgs(int argc, char *argv[])
-{
- Q_UNUSED(argc)
- Q_UNUSED(argv)
- QString cmdLine = QString::fromWCharArray(GetCommandLine());
- return qWinCmdArgs(cmdLine);
-}
-
-#elif defined(Q_OS_WINRT) // Q_OS_WINCE
+#elif defined(Q_OS_WINRT) // Q_OS_WIN32
static inline QStringList qCmdLineArgs(int argc, char *argv[])
{
diff --git a/src/corelib/kernel/qeventdispatcher_cf.mm b/src/corelib/kernel/qeventdispatcher_cf.mm
index 55f27a5b60..437e4062ad 100644
--- a/src/corelib/kernel/qeventdispatcher_cf.mm
+++ b/src/corelib/kernel/qeventdispatcher_cf.mm
@@ -210,6 +210,13 @@ QEventDispatcherCoreFoundation::~QEventDispatcherCoreFoundation()
m_cfSocketNotifier.removeSocketNotifiers();
}
+QEventLoop *QEventDispatcherCoreFoundation::currentEventLoop() const
+{
+ QEventLoop *eventLoop = QThreadData::current()->eventLoops.top();
+ Q_ASSERT(eventLoop);
+ return eventLoop;
+}
+
/*!
Processes all pending events that match \a flags until there are no
more events to process. Returns \c true if pending events were handled;
@@ -302,10 +309,7 @@ bool QEventDispatcherCoreFoundation::processEvents(QEventLoop::ProcessEventsFlag
// to exit, and then unwind back to the previous event loop which will break
// immediately, since it has already been exited.
- QEventLoop *currentEventLoop = QThreadData::current()->eventLoops.top();
- Q_ASSERT(currentEventLoop);
-
- if (!currentEventLoop->isRunning()) {
+ if (!currentEventLoop()->isRunning()) {
qEventDispatcherDebug() << "Top level event loop was exited";
break;
} else {
diff --git a/src/corelib/kernel/qeventdispatcher_cf_p.h b/src/corelib/kernel/qeventdispatcher_cf_p.h
index c2592cacc8..e6581e2bac 100644
--- a/src/corelib/kernel/qeventdispatcher_cf_p.h
+++ b/src/corelib/kernel/qeventdispatcher_cf_p.h
@@ -228,6 +228,8 @@ public:
void flush();
protected:
+ QEventLoop *currentEventLoop() const;
+
virtual bool processPostedEvents();
struct ProcessEventsState
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index 166e509635..e05de4f085 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -63,11 +63,7 @@ extern uint qGlobalPostedEventsCount();
#endif
#ifndef QS_RAWINPUT
-# ifdef Q_OS_WINCE
-# define QS_RAWINPUT 0x0000
-# else
# define QS_RAWINPUT 0x0400
-# endif
#endif
#ifndef WM_TOUCH
@@ -89,230 +85,14 @@ enum {
SendPostedEventsWindowsTimerId = ~1u
};
-#if defined(Q_OS_WINCE)
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <winsock.h>
-QT_END_INCLUDE_NAMESPACE
-// Asynchronous Winsocks ------------------------------------------
-#ifndef QT_NO_THREAD
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <qthread.h>
-#include <qmap.h>
-#include <qmutex.h>
-QT_END_INCLUDE_NAMESPACE
-
-//#define QCE_ASYNC_DEBUG
-
-namespace {
- class SocketAsyncHandler;
-
- class SocketAsyncHandler : public QThread
- {
- public:
- SocketAsyncHandler();
- ~SocketAsyncHandler();
- void run();
- void select(SOCKET sock, HWND handle, unsigned int msg, long ev);
- void removeSelect(SOCKET sock);
- void safeRemove(SOCKET sock);
- private:
- struct SockInfo {
- HWND handle;
- unsigned int msg;
- long ev;
- };
- QMap<SOCKET, SockInfo> sockets;
- QMutex mutex;
- QWaitCondition cond;
- bool supposedToDie;
- };
-
- SocketAsyncHandler::SocketAsyncHandler()
- : supposedToDie(false)
- {
- }
-
- SocketAsyncHandler::~SocketAsyncHandler()
- {
- mutex.lock();
- supposedToDie = true;
- mutex.unlock();
- cond.wakeOne();
- wait();
- while (sockets.size() > 0)
- removeSelect(sockets.begin().key());
- }
-
- void SocketAsyncHandler::removeSelect(SOCKET sock)
- {
- if (!sockets.contains(sock))
- return;
- sockets.remove(sock);
- return;
- }
-
- void SocketAsyncHandler::safeRemove(SOCKET sock)
- {
- QMutexLocker locker(&mutex);
- removeSelect(sock);
- }
-
- void SocketAsyncHandler::select(SOCKET sock, HWND handle, unsigned int msg, long ev)
- {
- QMutexLocker locker(&mutex);
-
- if (sockets.contains(sock))
- sockets.remove(sock);
-
- SockInfo info;
- info.handle = handle;
- info.msg = msg;
- info.ev = ev;
- sockets.insert(sock, info);
- cond.wakeOne();
- }
-
- void SocketAsyncHandler::run()
- {
- do {
- mutex.lock();
-
- while (!supposedToDie && sockets.isEmpty()) {
- cond.wait(&mutex);
- }
-
- if (supposedToDie) {
- mutex.unlock();
- break;
- }
-
- // Copy current items to reduce lock time
- // and to be able to use SendMessage
- QMap<SOCKET, SockInfo> currentSockets = sockets;
- mutex.unlock();
-
- fd_set readS, writeS, exS;
- FD_ZERO(&readS);
- FD_ZERO(&writeS);
- FD_ZERO(&exS);
-
- int maxFd = 0;
-
- for (QMap<SOCKET, SockInfo>::iterator it = currentSockets.begin(); it != currentSockets.end(); ++it) {
- const SockInfo &info = it.value();
- int socket = it.key();
- maxFd = qMax(maxFd, socket);
-
- if ((info.ev & FD_READ) || (info.ev & FD_CLOSE) || (info.ev & FD_ACCEPT))
- FD_SET(socket, &readS);
- if ((info.ev & FD_WRITE)|| (info.ev & FD_CONNECT))
- FD_SET(socket, &writeS);
- if (info.ev & FD_OOB)
- FD_SET(socket, &exS);
- }
-
- timeval timeout;
- timeout.tv_sec = 0;
- timeout.tv_usec = 50000;
- int result = ::select(maxFd + 1, &readS, &writeS, &exS, &timeout);
- if (result > 0) {
- HWND handle;
- unsigned int tmpMsg;
- SOCKET sock;
- HRESULT ret;
- for (QMap<SOCKET, SockInfo>::const_iterator it = currentSockets.constBegin();
- it != currentSockets.constEnd(); ++it) {
- handle = (*it).handle;
- tmpMsg = (*it).msg;
- sock = it.key();
- if (FD_ISSET(sock, &readS))
- ret = SendMessage(handle, tmpMsg, sock, FD_READ);
-
- if (FD_ISSET(sock, &writeS))
- ret = SendMessage(handle, tmpMsg, sock, FD_WRITE);
-
- if (FD_ISSET(sock, &exS))
- ret = SendMessage(handle, tmpMsg, sock, FD_OOB);
- }
- }
-
-#ifdef QCE_ASYNC_DEBUG
- else if (result == 0) { //timeout
- qDebug(" WSAAsync select timeout");
- } else if (result < 0) { // SocketError
- // This might happen because of two reasons
- // 1. We already closed a socket in between the copy and the select
- // and thus select() returns an error
- // 2. Something is really wrong, then
- // ### Loop on all descriptors, try to select and remove the
- // ### broken one.
- qWarning("WSAAsync select error %d", WSAGetLastError());
- }
-#endif
- } while(true);
- }
-} // namespace
-
-Q_GLOBAL_STATIC(SocketAsyncHandler, qt_async_handler)
-
-int WSAAsyncSelect(SOCKET sock, HWND handle, unsigned int msg, long ev)
-{
- if (sock == 0 || handle == 0 || handle == INVALID_HANDLE_VALUE) {
- WSASetLastError(WSAEINVAL);
- return SOCKET_ERROR;
- }
-
- if (msg == 0 && ev == 0)
- qt_async_handler()->safeRemove(sock);
- else
- qt_async_handler()->select(sock, handle, msg, ev);
-
- qt_async_handler()->start(QThread::LowPriority);
- WSASetLastError(0);
- return 0;
-}
-#else // QT_NO_THREAD
-int WSAAsyncSelect(SOCKET, HWND, unsigned int, long)
-{
- return SOCKET_ERROR;
-}
-#endif
-#endif // Q_OS_WINCE
-
class QEventDispatcherWin32Private;
#if !defined(DWORD_PTR) && !defined(Q_OS_WIN64)
#define DWORD_PTR DWORD
#endif
-typedef MMRESULT(WINAPI *ptimeSetEvent)(UINT, UINT, LPTIMECALLBACK, DWORD_PTR, UINT);
-typedef MMRESULT(WINAPI *ptimeKillEvent)(UINT);
-
-static ptimeSetEvent qtimeSetEvent = 0;
-static ptimeKillEvent qtimeKillEvent = 0;
-
LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp);
-static void resolveTimerAPI()
-{
- static bool triedResolve = false;
- if (!triedResolve) {
-#ifndef QT_NO_THREAD
- QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve));
- if (triedResolve)
- return;
-#endif
- triedResolve = true;
-#if !defined(Q_OS_WINCE)
- qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeSetEvent");
- qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeKillEvent");
-#else
- qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("Mmtimer"), "timeSetEvent");
- qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("Mmtimer"), "timeKillEvent");
-#endif
- }
-}
-
QEventDispatcherWin32Private::QEventDispatcherWin32Private()
: threadId(GetCurrentThreadId()), interrupt(false), closingDown(false), internalHwnd(0),
getMessageHook(0), serialNumber(0), lastSerialNumber(0), sendPostedEventsWindowsTimerId(0),
@@ -321,7 +101,6 @@ QEventDispatcherWin32Private::QEventDispatcherWin32Private()
, activateNotifiersPosted(false)
#endif
{
- resolveTimerAPI();
}
QEventDispatcherWin32Private::~QEventDispatcherWin32Private()
@@ -502,11 +281,7 @@ LRESULT QT_WIN_CALLBACK qt_GetMessageHook(int code, WPARAM wp, LPARAM lp)
}
}
}
-#ifdef Q_OS_WINCE
- return 0;
-#else
return q->d_func()->getMessageHook ? CallNextHookEx(0, code, wp, lp) : 0;
-#endif
}
// Provide class name and atom for the message window used by
@@ -564,16 +339,11 @@ static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatch
QWindowsMessageWindowClassContext *ctx = qWindowsMessageWindowClassContext();
if (!ctx->atom)
return 0;
-#ifdef Q_OS_WINCE
- HWND parent = 0;
-#else
- HWND parent = HWND_MESSAGE;
-#endif
HWND wnd = CreateWindow(ctx->className, // classname
ctx->className, // window name
0, // style
0, 0, 0, 0, // geometry
- parent, // parent
+ HWND_MESSAGE, // parent
0, // menu handle
qWinAppInst(), // application
0); // windows creation data.
@@ -609,24 +379,27 @@ void QEventDispatcherWin32Private::registerTimer(WinTimerInfo *t)
Q_Q(QEventDispatcherWin32);
- int ok = 0;
+ bool ok = false;
calculateNextTimeout(t, qt_msectime());
uint interval = t->interval;
if (interval == 0u) {
// optimization for single-shot-zero-timer
QCoreApplication::postEvent(q, new QZeroTimerEvent(t->timerId));
- ok = 1;
- } else if ((interval < 20u || t->timerType == Qt::PreciseTimer) && qtimeSetEvent) {
- ok = t->fastTimerId = qtimeSetEvent(interval, 1, qt_fast_timer_proc, (DWORD_PTR)t,
- TIME_CALLBACK_FUNCTION | TIME_PERIODIC | TIME_KILL_SYNCHRONOUS);
+ ok = true;
+ } else if (interval < 20u || t->timerType == Qt::PreciseTimer) {
+ // 3/2016: Although MSDN states timeSetEvent() is deprecated, the function
+ // is still deemed to be the most reliable precision timer.
+ t->fastTimerId = timeSetEvent(interval, 1, qt_fast_timer_proc, DWORD_PTR(t),
+ TIME_CALLBACK_FUNCTION | TIME_PERIODIC | TIME_KILL_SYNCHRONOUS);
+ ok = t->fastTimerId;
}
- if (ok == 0) {
+ if (!ok) {
// user normal timers for (Very)CoarseTimers, or if no more multimedia timers available
ok = SetTimer(internalHwnd, t->timerId, interval, 0);
}
- if (ok == 0)
+ if (!ok)
qErrnoWarning("QEventDispatcherWin32::registerTimer: Failed to create a timer");
}
@@ -635,7 +408,7 @@ void QEventDispatcherWin32Private::unregisterTimer(WinTimerInfo *t)
if (t->interval == 0) {
QCoreApplicationPrivate::removePostedTimerEvent(t->dispatcher, t->timerId);
} else if (t->fastTimerId != 0) {
- qtimeKillEvent(t->fastTimerId);
+ timeKillEvent(t->fastTimerId);
QCoreApplicationPrivate::removePostedTimerEvent(t->dispatcher, t->timerId);
} else if (internalHwnd) {
KillTimer(internalHwnd, t->timerId);
@@ -702,7 +475,6 @@ void QEventDispatcherWin32::installMessageHook()
if (d->getMessageHook)
return;
-#ifndef Q_OS_WINCE
// setup GetMessage hook needed to drive our posted events
d->getMessageHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC) qt_GetMessageHook, NULL, GetCurrentThreadId());
if (Q_UNLIKELY(!d->getMessageHook)) {
@@ -710,17 +482,14 @@ void QEventDispatcherWin32::installMessageHook()
qFatal("Qt: INTERNAL ERROR: failed to install GetMessage hook: %d, %s",
errorCode, qPrintable(qt_error_string(errorCode)));
}
-#endif
}
void QEventDispatcherWin32::uninstallMessageHook()
{
Q_D(QEventDispatcherWin32);
-#ifndef Q_OS_WINCE
if (d->getMessageHook)
UnhookWindowsHookEx(d->getMessageHook);
-#endif
d->getMessageHook = 0;
}
@@ -1166,11 +935,7 @@ void QEventDispatcherWin32::activateEventNotifiers()
Q_D(QEventDispatcherWin32);
//### this could break if events are removed/added in the activation
for (int i=0; i<d->winEventNotifierList.count(); i++) {
-#if !defined(Q_OS_WINCE)
if (WaitForSingleObjectEx(d->winEventNotifierList.at(i)->handle(), 0, TRUE) == WAIT_OBJECT_0)
-#else
- if (WaitForSingleObject(d->winEventNotifierList.at(i)->handle(), 0) == WAIT_OBJECT_0)
-#endif
d->activateEventNotifier(d->winEventNotifierList.at(i));
}
}
diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h
index a87b56cd38..773315c04f 100644
--- a/src/corelib/kernel/qeventdispatcher_win_p.h
+++ b/src/corelib/kernel/qeventdispatcher_win_p.h
@@ -138,7 +138,7 @@ struct WinTimerInfo { // internal timer info
quint64 timeout; // - when to actually fire
QObject *obj; // - object to receive events
bool inTimerEvent;
- int fastTimerId;
+ UINT fastTimerId;
};
class QZeroTimerEvent : public QTimerEvent
diff --git a/src/corelib/kernel/qfunctions_p.h b/src/corelib/kernel/qfunctions_p.h
index 06f5ea09da..ff035fcb11 100644
--- a/src/corelib/kernel/qfunctions_p.h
+++ b/src/corelib/kernel/qfunctions_p.h
@@ -53,9 +53,7 @@
#include <QtCore/qglobal.h>
-#if defined(Q_OS_WINCE)
-# include "QtCore/qfunctions_wince.h"
-#elif defined(Q_OS_VXWORKS)
+#if defined(Q_OS_VXWORKS)
# include "QtCore/qfunctions_vxworks.h"
#elif defined(Q_OS_NACL)
# include "QtCore/qfunctions_nacl.h"
diff --git a/src/corelib/kernel/qfunctions_wince.cpp b/src/corelib/kernel/qfunctions_wince.cpp
deleted file mode 100644
index 104c6fb27c..0000000000
--- a/src/corelib/kernel/qfunctions_wince.cpp
+++ /dev/null
@@ -1,407 +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$
-**
-****************************************************************************/
-#ifdef _WIN32_WCE //Q_OS_WINCE
-
-#include <windows.h>
-#include <winbase.h>
-#include <kfuncs.h>
-#include <stdio.h>
-#if _WIN32_WCE < 0x800
-# include <altcecrt.h>
-#else
-# include <fcntl.h>
-#endif
-
-#include "qplatformdefs.h"
-#include "qfunctions_wince.h"
-#include "qfunctions_fake_env_p.h"
-#include "qstring.h"
-
-QT_USE_NAMESPACE
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-wchar_t* CEPrivConvCharToWide(const char* string)
-{
- size_t length = strlen(string);
- wchar_t* wString = new wchar_t[length +1];
- for (unsigned int i = 0; i < (length +1); i++)
- wString[i] = string[i];
- return wString;
-}
-
-// Time -------------------------------------------------------------
-time_t qt_wince_ftToTime_t( const FILETIME ft )
-{
- ULARGE_INTEGER li;
- li.LowPart = ft.dwLowDateTime;
- li.HighPart = ft.dwHighDateTime;
-
- // 100-nanosec to seconds
- li.QuadPart /= 10000000;
-
- // FILETIME is from 1601-01-01 T 00:00:00
- // time_t is from 1970-01-01 T 00:00:00
- // 1970 - 1601 = 369 year (89 leap years)
- //
- // ((369y*365d) + 89d) *24h *60min *60sec
- // = 11644473600 seconds
- li.QuadPart -= 11644473600;
- return li.LowPart;
-}
-
-FILETIME qt_wince_time_tToFt( time_t tt )
-{
- ULARGE_INTEGER li;
- li.QuadPart = tt;
- li.QuadPart += 11644473600;
- li.QuadPart *= 10000000;
-
- FILETIME ft;
- ft.dwLowDateTime = li.LowPart;
- ft.dwHighDateTime = li.HighPart;
- return ft;
-}
-
-// File I/O ---------------------------------------------------------
-#if _WIN32_WCE < 0x800
-int errno = 0;
-#endif
-
-int qt_wince__getdrive( void )
-{
- return 1;
-}
-
-int qt_wince__waccess( const wchar_t *path, int pmode )
-{
- DWORD res = GetFileAttributes( path );
- if ( 0xFFFFFFFF == res )
- return -1;
-
- if ( (pmode & W_OK) && (res & FILE_ATTRIBUTE_READONLY) )
- return -1;
-
- if ( (pmode & X_OK) && !(res & FILE_ATTRIBUTE_DIRECTORY) ) {
- QString file = QString::fromWCharArray(path);
- if ( !(file.endsWith(QString::fromLatin1(".exe")) ||
- file.endsWith(QString::fromLatin1(".com"))) )
- return -1;
- }
-
- return 0;
-}
-
-int qt_wince_open( const char *filename, int oflag, int pmode )
-{
- QString fn( QString::fromLatin1(filename) );
- return _wopen( (wchar_t*)fn.utf16(), oflag, pmode );
-}
-
-int qt_wince__wopen( const wchar_t *filename, int oflag, int /*pmode*/ )
-{
- wchar_t *flag;
-
- if ( oflag & _O_APPEND ) {
- if ( oflag & _O_WRONLY ) {
- flag = L"a";
- } else if ( oflag & _O_RDWR ) {
- flag = L"a+";
- }
- } else if (oflag & _O_BINARY) {
- if ( oflag & _O_WRONLY ) {
- flag = L"wb";
- } else if ( oflag & _O_RDWR ) {
- flag = L"w+b"; // slightly different from "r+" where the file must exist
- } else if ( oflag & _O_RDONLY ) {
- flag = L"rb";
- } else {
- flag = L"b";
- }
- } else {
- if ( oflag & _O_WRONLY ) {
- flag = L"wt";
- } else if ( oflag & _O_RDWR ) {
- flag = L"w+t"; // slightly different from "r+" where the file must exist
- } else if ( oflag & _O_RDONLY ) {
- flag = L"rt";
- } else {
- flag = L"t";
- }
- }
-
- int retval = (int)_wfopen( filename, flag );
- return (retval == NULL) ? -1 : retval;
-}
-
-long qt_wince__lseek( int handle, long offset, int origin )
-{
- return fseek( (FILE*)handle, offset, origin );
-}
-
-int qt_wince__read( int handle, void *buffer, unsigned int count )
-{
- return fread( buffer, 1, count, (FILE*)handle );
-}
-
-int qt_wince__write( int handle, const void *buffer, unsigned int count )
-{
- return fwrite( buffer, 1, count, (FILE*)handle );
-}
-
-int qt_wince__close( int handle )
-{
- if (!handle)
- return 0;
- return fclose( (FILE*)handle );
-}
-
-FILE *qt_wince__fdopen(int handle, const char* /*mode*/)
-{
- return (FILE*)handle;
-}
-
-FILE *qt_wince_fdopen( int handle, const char* /*mode*/ )
-{
- return (FILE*)handle;
-}
-
-void qt_wince_rewind( FILE *stream )
-{
- fseek( stream, 0L, SEEK_SET );
-}
-
-int qt_wince___fileno(FILE *f)
-{
- return (int) _fileno(f);
-}
-
-FILE *qt_wince_tmpfile( void )
-{
- static long i = 0;
- char name[16];
- sprintf( name, "tmp%i", i++ );
- return fopen( name, "r+" );
-}
-
-int qt_wince__mkdir(const char *dirname)
-{
- return CreateDirectory(reinterpret_cast<const wchar_t *> (QString(QString::fromLatin1(dirname)).utf16()), 0) ? 0 : -1;
-}
-
-int qt_wince__rmdir(const char *dirname)
-{
- return RemoveDirectory(reinterpret_cast<const wchar_t *> (QString::fromLatin1(dirname).utf16())) ? 0 : -1;
-}
-
-int qt_wince__access( const char *path, int pmode )
-{
- return _waccess(reinterpret_cast<const wchar_t *> (QString::fromLatin1(path).utf16()),pmode);
-}
-
-int qt_wince__rename( const char *oldname, const char *newname )
-{
- return !MoveFile(reinterpret_cast<const wchar_t *> (QString::fromLatin1(oldname).utf16()), reinterpret_cast<const wchar_t *> (QString::fromLatin1(newname).utf16()));
-}
-
-int qt_wince__remove( const char *name )
-{
- return !DeleteFile(reinterpret_cast<const wchar_t *> (QString::fromLatin1(name).utf16()));
-}
-
-int qt_wince_stat( const char *path, struct stat *buffer )
-{
- WIN32_FIND_DATA finfo;
- HANDLE ff = FindFirstFile( reinterpret_cast<const wchar_t *> (QString::fromLatin1(path).utf16()), &finfo );
-
- if ( ff == INVALID_HANDLE_VALUE )
- return -1;
-
- buffer->st_ctime = qt_wince_ftToTime_t( finfo.ftCreationTime );
- buffer->st_atime = qt_wince_ftToTime_t( finfo.ftLastAccessTime );
- buffer->st_mtime = qt_wince_ftToTime_t( finfo.ftLastWriteTime );
- buffer->st_nlink = 0;
- buffer->st_size = finfo.nFileSizeLow; // ### missing high!
- buffer->st_mode = (finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR : _S_IFREG;
- buffer->st_mode |= (finfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? _O_RDONLY : _O_RDWR;
- return (FindClose(ff) == 0);
-}
-
-int qt_wince__fstat( int handle, struct stat *buffer)
-{
- BY_HANDLE_FILE_INFORMATION fInfo;
- BOOL res = GetFileInformationByHandle((HANDLE)handle, &fInfo);
-
- buffer->st_ctime = qt_wince_ftToTime_t( fInfo.ftCreationTime );
- buffer->st_atime = qt_wince_ftToTime_t( fInfo.ftLastAccessTime );
- buffer->st_mtime = qt_wince_ftToTime_t( fInfo.ftLastWriteTime );
- buffer->st_nlink = 0;
- buffer->st_size = fInfo.nFileSizeLow; // ### missing high!
- buffer->st_mode = (fInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR : _S_IFREG;
- buffer->st_mode |= (fInfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? _O_RDONLY : _O_RDWR;
- return (res == 0);
-}
-
-int qt_wince_SetErrorMode(int newValue)
-{
- static int oldValue;
- int result = oldValue;
- oldValue = newValue;
- return result;
-}
-
-bool qt_wince__chmod(const char *file, int mode)
-{
- return _wchmod( reinterpret_cast<const wchar_t *> (QString::fromLatin1(file).utf16()), mode);
-}
-
-bool qt_wince__wchmod(const wchar_t *file, int mode)
-{
- BOOL success = FALSE;
- // ### Does not work properly, what about just adding one property?
- if(mode&_S_IWRITE) {
- success = SetFileAttributes(file, FILE_ATTRIBUTE_NORMAL);
- } else if((mode&_S_IREAD) && !(mode&_S_IWRITE)) {
- success = SetFileAttributes(file, FILE_ATTRIBUTE_READONLY);
- }
- return success ? 0 : -1;
-}
-
-HANDLE qt_wince_CreateFileA(LPCSTR filename, DWORD access, DWORD share, LPSECURITY_ATTRIBUTES attr, DWORD dispo, DWORD flags, HANDLE tempFile)
-{
- return CreateFileW( reinterpret_cast<const wchar_t *>(QString::fromLatin1(filename).utf16()), access, share, attr, dispo, flags, tempFile);
-}
-
-// Graphics ---------------------------------------------------------
-BOOL qt_wince_SetWindowOrgEx( HDC /*hdc*/, int /*X*/, int /*Y*/, LPPOINT /*lpPoint*/) {
- return TRUE;
-}
-
-// Threading --------------------------------------------------------
-HANDLE qt_wince__beginthread(void( *start_address )( void * ), unsigned stack_size, void *arglist)
-{
- unsigned initflag = 0;
- if (stack_size > 0)
- initflag |= STACK_SIZE_PARAM_IS_A_RESERVATION;
- return CreateThread(NULL, stack_size, (LPTHREAD_START_ROUTINE)start_address, arglist, initflag, NULL);
-}
-
-unsigned long qt_wince__beginthreadex( void *security,
- unsigned stack_size,
- unsigned (__stdcall *start_address)(void *),
- void *arglist,
- unsigned initflag,
- unsigned *thrdaddr)
-{
- if (stack_size > 0)
- initflag |= STACK_SIZE_PARAM_IS_A_RESERVATION;
- return (unsigned long)
- CreateThread( (LPSECURITY_ATTRIBUTES)security,
- (DWORD)stack_size,
- (LPTHREAD_START_ROUTINE)start_address,
- (LPVOID)arglist,
- (DWORD)initflag | CREATE_SUSPENDED,
- (LPDWORD)thrdaddr);
-}
-
-void qt_wince__endthreadex(unsigned nExitCode) {
- ExitThread((DWORD)nExitCode);
-}
-
-void *qt_wince_bsearch(const void *key,
- const void *base,
- size_t num,
- size_t size,
- int (__cdecl *compare)(const void *, const void *))
-{
- size_t low = 0;
- size_t high = num - 1;
- while (low <= high) {
- size_t mid = (low + high) >> 1;
- int c = compare(key, (char*)base + mid * size);
- if (c < 0) {
- if (!mid)
- break;
- high = mid - 1;
- } else if (c > 0)
- low = mid + 1;
- else
- return (char*) base + mid * size;
- }
- return 0;
-}
-
-void *lfind(const void* key, const void* base, size_t* elements, size_t size,
- int (__cdecl *compare)(const void*, const void*))
-{
- const char* current = (char*) base;
- const char* const end = (char*) (current + (*elements) * size);
- while (current != end) {
- if (compare(current, key) == 0)
- return (void*)current;
- current += size;
- }
- return 0;
-}
-
-DWORD qt_wince_GetThreadLocale(void)
-{
- return GetUserDefaultLCID();
-}
-
-void *qt_wince_calloc( size_t num, size_t size )
-{
- void *ptr = malloc( num * size );
- if( ptr )
- memset( ptr, 0, num * size );
- return ptr;
-}
-
-// _getpid is currently only used for creating a temporary filename
-int qt_wince__getpid()
-{
- return qAbs((int)GetCurrentProcessId());
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-#endif // Q_OS_WINCE
diff --git a/src/corelib/kernel/qfunctions_wince.h b/src/corelib/kernel/qfunctions_wince.h
deleted file mode 100644
index 030950e1bd..0000000000
--- a/src/corelib/kernel/qfunctions_wince.h
+++ /dev/null
@@ -1,473 +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_WINCE_H
-#define QFUNCTIONS_WINCE_H
-
-#include <QtCore/qglobal.h>
-
-#ifdef Q_OS_WINCE
-# ifndef NOMINMAX
-# define NOMINMAX
-# endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-#include <winuser.h>
-#include <winbase.h>
-#include <objbase.h>
-#include <kfuncs.h>
-#include <ctype.h>
-#include <time.h>
-#include <crtdefs.h>
-#if _WIN32_WCE < 0x800
-# include <altcecrt.h>
-#else
-# include <fcntl.h>
-# include <stat.h>
-#endif
-#include <winsock.h>
-#include <ceconfig.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifdef QT_BUILD_CORE_LIB
-#endif
-
-QT_END_NAMESPACE
-
-// The standard SDK misses this define...
-#define _control87 _controlfp
-
-#if !defined __cplusplus
-#define bool int
-#define true 1
-#define false 0
-#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*);
-
-#ifdef __cplusplus // have this as tiff plugin is written in C
-extern "C" {
-#endif
-
-#if !defined(NO_ERRNO_H)
-#define NO_ERRNO_H
-#endif
-
-// Environment ------------------------------------------------------
-int qt_wince__getpid(void);
-
-
-// Time -------------------------------------------------------------
-#ifndef _TM_DEFINED
-#define _TM_DEFINED
-struct tm {
- int tm_sec; /* seconds after the minute - [0,59] */
- int tm_min; /* minutes after the hour - [0,59] */
- int tm_hour; /* hours since midnight - [0,23] */
- int tm_mday; /* day of the month - [1,31] */
- int tm_mon; /* months since January - [0,11] */
- int tm_year; /* years since 1900 */
- int tm_wday; /* days since Sunday - [0,6] */
- int tm_yday; /* days since January 1 - [0,365] */
- int tm_isdst; /* daylight-saving time flag */
-};
-#endif // _TM_DEFINED
-
-FILETIME qt_wince_time_tToFt( time_t tt );
-time_t qt_wince_ftToTime_t( const FILETIME ft );
-
-#if _WIN32_WCE < 0x800
-
-// File I/O ---------------------------------------------------------
-#define _O_RDONLY 0x0001
-#define _O_RDWR 0x0002
-#define _O_WRONLY 0x0004
-#define _O_CREAT 0x0008
-#define _O_TRUNC 0x0010
-#define _O_APPEND 0x0020
-#define _O_EXCL 0x0040
-
-#define O_RDONLY _O_RDONLY
-#define O_RDWR _O_RDWR
-#define O_WRONLY _O_WRONLY
-#define O_CREAT _O_CREAT
-#define O_TRUNC _O_TRUNC
-#define O_APPEND _O_APPEND
-#define O_EXCL _O_EXCL
-
-#define _S_IFMT 0x0600
-#define _S_IFDIR 0x0200
-#define _S_IFCHR 0x0100
-#define _S_IFREG 0x0400
-#define _S_IREAD 0x0010
-#define _S_IWRITE 0x0008
-
-#define S_IFMT _S_IFMT
-#define S_IFDIR _S_IFDIR
-#define S_IFCHR _S_IFCHR
-#define S_IFREG _S_IFREG
-#define S_IREAD _S_IREAD
-#define S_IWRITE _S_IWRITE
-
-#ifndef _IOFBF
-#define _IOFBF 0x0000
-#endif
-
-#ifndef _IOLBF
-#define _IOLBF 0x0040
-#endif
-
-#ifndef _IONBF
-#define _IONBF 0x0004
-#endif
-
-// Regular Berkeley error constants
-#ifndef _STAT_DEFINED
-#define _STAT_DEFINED
-struct stat
-{
- int st_mode;
- int st_size;
- int st_nlink;
- time_t st_mtime;
- time_t st_atime;
- time_t st_ctime;
-};
-#endif
-
-typedef int mode_t;
-extern int errno;
-#endif // _WIN32_WCE < 0x800
-
-int qt_wince__getdrive( void );
-int qt_wince__waccess( const wchar_t *path, int pmode );
-int qt_wince__wopen( const wchar_t *filename, int oflag, int pmode );
-long qt_wince__lseek( int handle, long offset, int origin );
-int qt_wince__read( int handle, void *buffer, unsigned int count );
-int qt_wince__write( int handle, const void *buffer, unsigned int count );
-int qt_wince__close( int handle );
-FILE *qt_wince__fdopen(int handle, const char *mode);
-FILE *qt_wince_fdopen(int handle, const char *mode);
-void qt_wince_rewind( FILE *stream );
-int qt_wince___fileno(FILE *);
-FILE *qt_wince_tmpfile( void );
-
-//For zlib we need these helper functions, but they break the build when
-//set globally, so just set them for zlib use
-#ifdef ZLIB_H
-#define open qt_wince_open
-#define close qt_wince__close
-#define lseek qt_wince__lseek
-#define read qt_wince__read
-#define write qt_wince__write
-#endif
-
-int qt_wince__mkdir(const char *dirname);
-int qt_wince__rmdir(const char *dirname);
-int qt_wince__access( const char *path, int pmode );
-int qt_wince__rename( const char *oldname, const char *newname );
-int qt_wince__remove( const char *name );
-#ifdef __cplusplus
-int qt_wince_open( const char *filename, int oflag, int pmode = 0 );
-#else
-int qt_wince_open( const char *filename, int oflag, int pmode );
-#endif
-int qt_wince_stat( const char *path, struct stat *buffer );
-int qt_wince__fstat( int handle, struct stat *buffer);
-
-#define SEM_FAILCRITICALERRORS 0x0001
-#define SEM_NOOPENFILEERRORBOX 0x0002
-int qt_wince_SetErrorMode(int);
-#ifndef CoInitialize
-#define CoInitialize(x) CoInitializeEx(x, COINIT_MULTITHREADED)
-#endif
-
-bool qt_wince__chmod(const char *file, int mode);
-bool qt_wince__wchmod(const wchar_t *file, int mode);
-
-QT_WARNING_DISABLE_MSVC(4273)
-HANDLE qt_wince_CreateFileA(LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
-
-// Printer ----------------------------------------------------------
-#define ETO_GLYPH_INDEX 0x0010
-
-// Graphics ---------------------------------------------------------
-#ifndef SM_CXCURSOR
-# define SM_CXCURSOR 13
-#endif
-#ifndef SM_CYCURSOR
-# define SM_CYCURSOR 14
-#endif
-BOOL qt_wince_SetWindowOrgEx( HDC hdc, int X, int Y, LPPOINT lpPoint );
-
-// Other stuff ------------------------------------------------------
-#define MWMO_ALERTABLE 0x0002
-// ### not the real values
-#define CREATE_NO_WINDOW 2
-#define CF_HDROP 15
-
-void *qt_wince_calloc(size_t num, size_t size);
-#if !defined(TLS_OUT_OF_INDEXES)
-# define TLS_OUT_OF_INDEXES 0xffffffff
-#endif
-DWORD qt_wince_GetThreadLocale(void);
-
-HANDLE qt_wince__beginthread(void( *start_address )( void * ), unsigned stack_size, void *arglist);
-
-unsigned long qt_wince__beginthreadex( void *security,
- unsigned stack_size,
- unsigned (__stdcall *start_address)(void *),
- void *arglist,
- unsigned initflag,
- unsigned *thrdaddr );
-void qt_wince__endthreadex(unsigned nExitCode);
-
-
-// bsearch is needed for building the tiff plugin
-// otherwise it could go into qguifunctions_wce
-void *qt_wince_bsearch(const void *key,
- const void *base,
- size_t num,
- size_t size,
- int (__cdecl *compare)(const void *, const void *));
-
-// Missing typedefs
-#ifndef _TIME_T_DEFINED
-typedef unsigned long time_t;
-#define _TIME_T_DEFINED
-#endif
-typedef HANDLE HDROP;
-
-#ifndef WS_THICKFRAME
-#define WS_THICKFRAME WS_DLGFRAME
-#endif
-
-typedef UINT UWORD;
-
-// Missing definitions: not necessary equal to their Win32 values
-// (the goal is to just have a clean compilation of MFC)
-#define WS_MAXIMIZE 0
-#define WS_MINIMIZE 0
-#ifndef WS_EX_TOOLWINDOW
-#define WS_EX_TOOLWINDOW 0
-#endif
-#define WS_EX_NOPARENTNOTIFY 0
-#define WM_ENTERIDLE 0x0121
-#define WM_PRINT WM_PAINT
-#define WM_NCCREATE (0x0081)
-#define WM_PARENTNOTIFY 0
-#define WM_NCDESTROY (WM_APP-1)
-#ifndef SW_RESTORE
-#define SW_RESTORE (SW_SHOWNORMAL)
-#endif
-#define SW_NORMAL (SW_SHOWNORMAL)
-#define WAIT_OBJECT_0 0x00000000L
-#define DEFAULT_GUI_FONT SYSTEM_FONT
-#ifndef SWP_NOREDRAW
-#define SWP_NOREDRAW 0
-#endif
-#define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
-#define HWND_TOPMOST ((HWND)-1)
-#define HWND_NOTOPMOST ((HWND)-2)
-#define PS_DOT 2
-#define PD_ALLPAGES 0
-#define PD_USEDEVMODECOPIES 0
-#define PD_NOSELECTION 0
-#define PD_HIDEPRINTTOFILE 0
-#define PD_NOPAGENUMS 0
-#define CF_METAFILEPICT 3
-#define MM_ANISOTROPIC 8
-#define KF_ALTDOWN 0x2000
-#define SPI_GETWORKAREA 48
-
-#ifndef WM_SETCURSOR
- #define WM_SETCURSOR 0x0020
- #define IDC_ARROW MAKEINTRESOURCE(32512)
- #define IDC_IBEAM MAKEINTRESOURCE(32513)
- #define IDC_WAIT MAKEINTRESOURCE(32514)
- #define IDC_CROSS MAKEINTRESOURCE(32515)
- #define IDC_UPARROW MAKEINTRESOURCE(32516)
- #define IDC_SIZE MAKEINTRESOURCE(32646)
- #define IDC_ICON MAKEINTRESOURCE(32512)
- #define IDC_SIZENWSE MAKEINTRESOURCE(32642)
- #define IDC_SIZENESW MAKEINTRESOURCE(32643)
- #define IDC_SIZEWE MAKEINTRESOURCE(32644)
- #define IDC_SIZENS MAKEINTRESOURCE(32645)
- #define IDC_SIZEALL MAKEINTRESOURCE(32646)
- #define IDC_NO MAKEINTRESOURCE(32648)
- #define IDC_APPSTARTING MAKEINTRESOURCE(32650)
- #define IDC_HELP MAKEINTRESOURCE(32651)
- #define IDC_HAND MAKEINTRESOURCE(32649)
-#endif
-
-#define GMEM_MOVEABLE LMEM_MOVEABLE
-#define GPTR LPTR
-
-// WinCE: CESYSGEN prunes the following FRP defines,
-// and INTERNET_TRANSFER_TYPE_ASCII breaks in wininet.h
-#undef FTP_TRANSFER_TYPE_ASCII
-#define FTP_TRANSFER_TYPE_ASCII 0x00000001
-#undef FTP_TRANSFER_TYPE_BINARY
-#define FTP_TRANSFER_TYPE_BINARY 0x00000002
-
-typedef DWORD OLE_COLOR;
-
-// Define the Windows Styles which are not defined by MS
-#ifndef WS_POPUPWINDOW
-#define WS_POPUPWINDOW WS_POPUP|WS_BORDER|WS_SYSMENU|WS_CAPTION
-#endif
-
-#ifndef WS_OVERLAPPEDWINDOW
-#define WS_OVERLAPPEDWINDOW WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX
-#endif
-
-#ifndef WS_TILED
-#define WS_TILED WS_OVERLAPPED
-#endif
-
-#ifndef WS_TILEDWINDOW
-#define WS_TILEDWINDOW WS_OVERLAPPEDWINDOW
-#endif
-
-#ifndef WS_EX_CAPTIONOKBTN
-#define WS_EX_CAPTIONOKBTN 0x80000000L
-#endif
-
-#ifndef WS_EX_NODRAG
-#define WS_EX_NODRAG 0x40000000L
-#endif
-
-#ifdef __cplusplus
-} // Extern C.
-#endif
-
-#ifdef __cplusplus
-
-
-// As Windows CE 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. Also inline functions are only supported by C++, so just define
-// them for C++, as only 3rd party dependencies are C, this is no issue.
-// The other declarations available in this file are being used per
-// define inside qplatformdefs.h of the corresponding WinCE mkspec.
-
-#define generate_inline_return_func0(funcname, returntype) \
- inline returntype funcname() \
- { \
- return qt_wince_##funcname(); \
- }
-#define generate_inline_return_func1(funcname, returntype, param1) \
- inline returntype funcname(param1 p1) \
- { \
- return qt_wince_##funcname(p1); \
- }
-#define generate_inline_return_func2(funcname, returntype, prependnamespace, param1, param2) \
- inline returntype funcname(param1 p1, param2 p2) \
- { \
- return 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_wince_##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 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_wince_##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_wince_##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_wince_##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(_getpid, int)
-generate_inline_return_func1(time_tToFt, FILETIME, time_t)
-generate_inline_return_func1(ftToTime_t, time_t, FILETIME)
-generate_inline_return_func0(_getdrive, int)
-generate_inline_return_func2(_waccess, int, qt_wince_, const wchar_t *, int)
-generate_inline_return_func3(_wopen, int, const wchar_t *, int, int)
-generate_inline_return_func2(_fdopen, FILE *, qt_wince_, int, const char *)
-generate_inline_return_func2(fdopen, FILE *, qt_wince_, int, const char *)
-generate_inline_return_func1(rewind, void, FILE *)
-generate_inline_return_func0(tmpfile, FILE *)
-generate_inline_return_func2(_rename, int, qt_wince_, const char *, const char *)
-generate_inline_return_func1(_remove, int, const char *)
-generate_inline_return_func1(SetErrorMode, int, int)
-#if _WIN32_WCE < 0x800
-generate_inline_return_func2(_chmod, bool, qt_wince_, const char *, int)
-generate_inline_return_func2(_wchmod, bool, qt_wince_, const wchar_t *, int)
-#endif
-generate_inline_return_func7(CreateFileA, HANDLE, LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE)
-generate_inline_return_func4(SetWindowOrgEx, BOOL, qt_wince_, HDC, int, int, LPPOINT)
-generate_inline_return_func2(calloc, void *, qt_wince_, size_t, size_t)
-generate_inline_return_func0(GetThreadLocale, DWORD)
-generate_inline_return_func3(_beginthread, HANDLE, StartAdressFunc, unsigned, void *)
-generate_inline_return_func6(_beginthreadex, unsigned long, void *, unsigned, StartAdressExFunc, void *, unsigned, unsigned *)
-generate_inline_return_func1(_endthreadex, void, unsigned)
-generate_inline_return_func5(bsearch, void *, const void *, const void *, size_t, size_t, CompareFunc)
-
-#endif //__cplusplus
-
-#endif // Q_OS_WINCE
-#endif // QFUNCTIONS_WINCE_H
diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h
index c24fc3a0ce..773884047a 100644
--- a/src/corelib/kernel/qmath.h
+++ b/src/corelib/kernel/qmath.h
@@ -45,6 +45,7 @@
#endif
#include <QtCore/qglobal.h>
+#include <QtCore/qalgorithms.h>
#ifndef _USE_MATH_DEFINES
# define _USE_MATH_DEFINES
@@ -241,20 +242,12 @@ Q_DECL_CONSTEXPR inline double qRadiansToDegrees(double radians)
}
-#if defined(Q_CC_GNU)
-// clz instructions exist in at least MIPS, ARM, PowerPC and X86, so we can assume this builtin always maps to an efficient instruction.
+#if defined(QT_HAS_BUILTIN_CLZ)
inline quint32 qNextPowerOfTwo(quint32 v)
{
if (v == 0)
return 1;
- return 2U << (31 ^ __builtin_clz(v));
-}
-
-inline quint64 qNextPowerOfTwo(quint64 v)
-{
- if (v == 0)
- return 1;
- return Q_UINT64_C(2) << (63 ^ __builtin_clzll(v));
+ return 2U << (31 ^ QAlgorithmsPrivate::qt_builtin_clz(v));
}
#else
inline quint32 qNextPowerOfTwo(quint32 v)
@@ -267,7 +260,16 @@ inline quint32 qNextPowerOfTwo(quint32 v)
++v;
return v;
}
+#endif
+#if defined(QT_HAS_BUILTIN_CLZLL)
+inline quint64 qNextPowerOfTwo(quint64 v)
+{
+ if (v == 0)
+ return 1;
+ return Q_UINT64_C(2) << (63 ^ QAlgorithmsPrivate::qt_builtin_clzll(v));
+}
+#else
inline quint64 qNextPowerOfTwo(quint64 v)
{
v |= v >> 1;
diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h
index f7c60cc309..4d114a5616 100644
--- a/src/corelib/kernel/qmetaobject.h
+++ b/src/corelib/kernel/qmetaobject.h
@@ -168,19 +168,15 @@ public:
inline bool isValid() const { return mobj != Q_NULLPTR; }
-#ifdef Q_QDOC
- static QMetaMethod fromSignal(PointerToMemberFunction signal);
-#else
- template <typename Func>
- static inline QMetaMethod fromSignal(Func signal)
+ template <typename PointerToMemberFunction>
+ static inline QMetaMethod fromSignal(PointerToMemberFunction signal)
{
- typedef QtPrivate::FunctionPointer<Func> SignalType;
+ typedef QtPrivate::FunctionPointer<PointerToMemberFunction> SignalType;
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
"No Q_OBJECT in the class with the signal");
return fromSignalImpl(&SignalType::Object::staticMetaObject,
reinterpret_cast<void **>(&signal));
}
-#endif
private:
#if QT_DEPRECATED_SINCE(5,0)
diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h
index 0790af2bb5..9b67d63524 100644
--- a/src/corelib/kernel/qmetaobject_p.h
+++ b/src/corelib/kernel/qmetaobject_p.h
@@ -168,6 +168,7 @@ class QMutex;
struct QMetaObjectPrivate
{
+ // revision 7 is Qt 5.0 everything lower is not supported
enum { OutputRevision = 7 }; // Used by moc, qmetaobjectbuilder and qdbus
int revision;
@@ -176,12 +177,9 @@ struct QMetaObjectPrivate
int methodCount, methodData;
int propertyCount, propertyData;
int enumeratorCount, enumeratorData;
- int constructorCount, constructorData; //since revision 2
- int flags; //since revision 3
- int signalCount; //since revision 4
- // revision 5 introduces changes in normalized signatures, no new members
- // revision 6 added qt_static_metacall as a member of each Q_OBJECT and inside QMetaObject itself
- // revision 7 is Qt 5
+ int constructorCount, constructorData;
+ int flags;
+ int signalCount;
static inline const QMetaObjectPrivate *get(const QMetaObject *metaobject)
{ return reinterpret_cast<const QMetaObjectPrivate*>(metaobject->d.data); }
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 3ac1f28638..cf0e88c7cd 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -870,8 +870,7 @@ const char *QMetaType::typeName(int typeId)
return result;
}
-/*!
- \internal
+/*
Similar to QMetaType::type(), but only looks in the static set of types.
*/
static inline int qMetaTypeStaticType(const char *typeName, int length)
@@ -884,8 +883,7 @@ static inline int qMetaTypeStaticType(const char *typeName, int length)
return types[i].type;
}
-/*!
- \internal
+/*
Similar to QMetaType::type(), but only looks in the custom set of
types, and doesn't lock the mutex.
The extra \a firstInvalidIndex parameter is an easy way to avoid
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index b68dbacbd3..a36d247c3c 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -506,11 +506,8 @@ public:
static int registerTypedef(const char *typeName, int aliasId);
static int registerNormalizedTypedef(const QT_PREPEND_NAMESPACE(QByteArray) &normalizedTypeName, int aliasId);
static int type(const char *typeName);
-#ifndef Q_QDOC
+
static int type(const QT_PREPEND_NAMESPACE(QByteArray) &typeName);
-#else
- static int type(const QByteArray &typeName);
-#endif
static const char *typeName(int type);
static int sizeOf(int type);
static TypeFlags typeFlags(int type);
@@ -600,8 +597,11 @@ public:
}
#ifdef Q_QDOC
+ template<typename MemberFunction, int>
static bool registerConverter(MemberFunction function);
+ template<typename MemberFunctionOk, char>
static bool registerConverter(MemberFunctionOk function);
+ template<typename UnaryFunction>
static bool registerConverter(UnaryFunction function);
#else
// member function as in "QString QFont::toString() const"
@@ -1857,6 +1857,7 @@ inline int qRegisterMetaTypeStreamOperators()
} QT_END_NAMESPACE \
/**/
+#ifndef Q_MOC_RUN
#define Q_DECLARE_METATYPE(TYPE) Q_DECLARE_METATYPE_IMPL(TYPE)
#define Q_DECLARE_METATYPE_IMPL(TYPE) \
QT_BEGIN_NAMESPACE \
@@ -1876,7 +1877,7 @@ inline int qRegisterMetaTypeStreamOperators()
} \
}; \
QT_END_NAMESPACE
-
+#endif // Q_MOC_RUN
#define Q_DECLARE_BUILTIN_METATYPE(TYPE, METATYPEID, NAME) \
QT_BEGIN_NAMESPACE \
@@ -1899,7 +1900,9 @@ QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_FORWARD_DECLARE_STATIC_TYPES_ITER)
typedef QList<QVariant> QVariantList;
typedef QMap<QString, QVariant> QVariantMap;
typedef QHash<QString, QVariant> QVariantHash;
+#ifndef Q_QDOC
typedef QList<QByteArray> QByteArrayList;
+#endif
#define Q_DECLARE_METATYPE_TEMPLATE_1ARG(SINGLE_ARG_TEMPLATE) \
QT_BEGIN_NAMESPACE \
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index c06f702b30..3cec9802dc 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -210,8 +210,11 @@ public:
const char *member, Qt::ConnectionType type = Qt::AutoConnection) const;
#ifdef Q_QDOC
+ template<typename PointerToMemberFunction>
static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type = Qt::AutoConnection);
+ template<typename PointerToMemberFunction, typename Functor>
static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor);
+ template<typename PointerToMemberFunction, typename Functor>
static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type = Qt::AutoConnection);
#else
//Connect a signal to a pointer to qobject member function
@@ -337,6 +340,7 @@ public:
static bool disconnect(const QMetaObject::Connection &);
#ifdef Q_QDOC
+ template<typename PointerToMemberFunction>
static bool disconnect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method);
#else
template <typename Func1, typename Func2>
diff --git a/src/corelib/kernel/qobject_impl.h b/src/corelib/kernel/qobject_impl.h
index aa68c9c1ad..d7ae63a98c 100644
--- a/src/corelib/kernel/qobject_impl.h
+++ b/src/corelib/kernel/qobject_impl.h
@@ -97,7 +97,7 @@ namespace QtPrivate {
inline void destroyIfLastRef() Q_DECL_NOTHROW
{ if (!m_ref.deref()) m_impl(Destroy, this, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR); }
- inline bool compare(void **a) { bool ret; m_impl(Compare, this, Q_NULLPTR, a, &ret); return ret; }
+ inline bool compare(void **a) { bool ret = false; m_impl(Compare, this, Q_NULLPTR, a, &ret); return ret; }
inline void call(QObject *r, void **a) { m_impl(Call, this, r, a, Q_NULLPTR); }
protected:
~QSlotObjectBase() {}
@@ -143,10 +143,9 @@ namespace QtPrivate {
case Call:
FuncType::template call<Args, R>(static_cast<QStaticSlotObject*>(this_)->function, r, a);
break;
- case Compare:
- *ret = false; // not implemented
- break;
- case NumOperations: ;
+ case Compare: // not implemented
+ case NumOperations:
+ Q_UNUSED(ret);
}
}
public:
@@ -168,10 +167,9 @@ namespace QtPrivate {
case Call:
FuncType::template call<Args, R>(static_cast<QFunctorSlotObject*>(this_)->function, r, a);
break;
- case Compare:
- *ret = false; // not implemented
- break;
- case NumOperations: ;
+ case Compare: // not implemented
+ case NumOperations:
+ Q_UNUSED(ret);
}
}
public:
diff --git a/src/corelib/kernel/qppsobject.cpp b/src/corelib/kernel/qppsobject.cpp
index dbff997c88..f716c1a92e 100644
--- a/src/corelib/kernel/qppsobject.cpp
+++ b/src/corelib/kernel/qppsobject.cpp
@@ -397,12 +397,12 @@ QByteArray QPpsObjectPrivate::encode(const QVariantMap &ppsData, bool *ok)
void QPpsObjectPrivate::encodeData(pps_encoder_t *encoder, const char *name, const QVariant &data,
bool *ok)
{
- QString errorFunction;
+ const char *errorFunction;
pps_encoder_error_t error = PPS_ENCODER_OK;
switch (data.type()) {
case QVariant::Bool:
error = pps_encoder_add_bool(encoder, name, data.toBool());
- errorFunction = QStringLiteral("pps_encoder_add_bool");
+ errorFunction = "pps_encoder_add_bool";
break;
// We want to support encoding uint even though libpps doesn't support it directly.
// We can't encode uint as an int since that will lose precision (e.g. 2^31+1 can't be
@@ -411,41 +411,41 @@ void QPpsObjectPrivate::encodeData(pps_encoder_t *encoder, const char *name, con
case QVariant::UInt:
case QVariant::Double:
error = pps_encoder_add_double(encoder, name, data.toDouble());
- errorFunction = QStringLiteral("pps_encoder_add_double");
+ errorFunction = "pps_encoder_add_double";
break;
case QVariant::Int:
error = pps_encoder_add_int(encoder, name, data.toInt());
- errorFunction = QStringLiteral("pps_encoder_add_int");
+ errorFunction = "pps_encoder_add_int";
break;
case QVariant::LongLong:
error = pps_encoder_add_int64(encoder, name, data.toLongLong());
- errorFunction = QStringLiteral("pps_encoder_add_int64");
+ errorFunction = "pps_encoder_add_int64";
break;
case QVariant::String:
error = pps_encoder_add_string(encoder, name, data.toString().toUtf8().constData());
- errorFunction = QStringLiteral("pps_encoder_add_string");
+ errorFunction = "pps_encoder_add_string";
break;
case QVariant::List:
error = pps_encoder_start_array(encoder, name);
- errorFunction = QStringLiteral("pps_encoder_start_array");
+ errorFunction = "pps_encoder_start_array";
if (error == PPS_ENCODER_OK) {
encodeArray(encoder, data.toList(), ok);
error = pps_encoder_end_array(encoder);
- errorFunction = QStringLiteral("pps_encoder_end_array");
+ errorFunction = "pps_encoder_end_array";
}
break;
case QVariant::Map:
error = pps_encoder_start_object(encoder, name);
- errorFunction = QStringLiteral("pps_encoder_start_object");
+ errorFunction = "pps_encoder_start_object";
if (error == PPS_ENCODER_OK) {
encodeObject(encoder, data.toMap(), ok);
error = pps_encoder_end_object(encoder);
- errorFunction = QStringLiteral("pps_encoder_end_object");
+ errorFunction = "pps_encoder_end_object";
}
break;
case QVariant::Invalid:
error = pps_encoder_add_null(encoder, name);
- errorFunction = QStringLiteral("pps_encoder_add_null");
+ errorFunction = "pps_encoder_add_null";
break;
default:
qWarning("QPpsObjectPrivate::encodeData: the type of the parameter data is invalid");
@@ -454,7 +454,7 @@ void QPpsObjectPrivate::encodeData(pps_encoder_t *encoder, const char *name, con
}
if (error != PPS_ENCODER_OK) {
- qWarning() << "QPpsObjectPrivate::encodeData: " << errorFunction << " failed";
+ qWarning("QPpsObjectPrivate::encodeData: %s failed", errorFunction);
*ok = false;
} else {
*ok = true;
diff --git a/src/corelib/kernel/qsharedmemory_win.cpp b/src/corelib/kernel/qsharedmemory_win.cpp
index e998b938c7..07d4930332 100644
--- a/src/corelib/kernel/qsharedmemory_win.cpp
+++ b/src/corelib/kernel/qsharedmemory_win.cpp
@@ -64,8 +64,8 @@ void QSharedMemoryPrivate::setErrorString(QLatin1String function)
errorString = QSharedMemory::tr("%1: already exists").arg(function);
break;
case ERROR_FILE_NOT_FOUND:
-#if defined(Q_OS_WINCE) || (defined(Q_OS_WINRT) && _MSC_VER < 1900)
- // This happens on CE only if no file is present as CreateFileMappingW
+#if defined(Q_OS_WINRT) && _MSC_VER < 1900
+ // This happens on WinRT only if no file is present as CreateFileMappingW
// bails out with this error code
case ERROR_INVALID_PARAMETER:
#endif
@@ -112,10 +112,6 @@ HANDLE QSharedMemoryPrivate::handle()
#else
hand = CreateFileMappingFromApp(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, (PCWSTR)nativeKey.utf16());
#endif
-#elif defined(Q_OS_WINCE)
- // This works for opening a mapping too, but always opens it with read/write access in
- // attach as it seems.
- hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, 0, (wchar_t*)nativeKey.utf16());
#else
hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, (wchar_t*)nativeKey.utf16());
#endif
diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp
index 12fd5404da..f38daec4f8 100644
--- a/src/corelib/kernel/qsystemerror.cpp
+++ b/src/corelib/kernel/qsystemerror.cpp
@@ -39,15 +39,9 @@
#include <qglobal.h>
#include "qsystemerror_p.h"
-#if !defined(Q_OS_WINCE)
-# include <errno.h>
-# if defined(Q_CC_MSVC)
-# include <crtdbg.h>
-# endif
-#else
-# if (_WIN32_WCE >= 0x700)
-# include <errno.h>
-# endif
+#include <errno.h>
+#if defined(Q_CC_MSVC)
+# include <crtdbg.h>
#endif
#ifdef Q_OS_WIN
# include <qt_windows.h>
@@ -131,16 +125,12 @@ static QString standardLibraryErrorString(int errorCode)
s = QT_TRANSLATE_NOOP("QIODevice", "No space left on device");
break;
default: {
- #ifdef Q_OS_WINCE
- ret = windowsErrorString(errorCode);
- #else
- #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX)
+ #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX)
QByteArray buf(1024, '\0');
ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf);
- #else
+ #else
ret = QString::fromLocal8Bit(strerror(errorCode));
- #endif
- #endif
+ #endif
break; }
}
if (s) {
diff --git a/src/corelib/kernel/qsystemsemaphore_p.h b/src/corelib/kernel/qsystemsemaphore_p.h
index 26647db2e1..3b55d80276 100644
--- a/src/corelib/kernel/qsystemsemaphore_p.h
+++ b/src/corelib/kernel/qsystemsemaphore_p.h
@@ -56,9 +56,7 @@
#ifndef QT_NO_SYSTEMSEMAPHORE
#include "qsharedmemory_p.h"
-#ifndef Q_OS_WINCE
-# include <sys/types.h>
-#endif
+#include <sys/types.h>
#ifdef QT_POSIX_IPC
# include <semaphore.h>
#endif
diff --git a/src/corelib/kernel/qsystemsemaphore_posix.cpp b/src/corelib/kernel/qsystemsemaphore_posix.cpp
index 6137239467..9fbf5779b8 100644
--- a/src/corelib/kernel/qsystemsemaphore_posix.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_posix.cpp
@@ -147,7 +147,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
if (::sem_post(semaphore) == -1) {
setErrorString(QLatin1String("QSystemSemaphore::modifySemaphore (sem_post)"));
#if defined QSYSTEMSEMAPHORE_DEBUG
- qDebug() << QLatin1String("QSystemSemaphore::modify sem_post failed") << count << errno;
+ qDebug("QSystemSemaphore::modify sem_post failed %d %d", count, errno);
#endif
// rollback changes to preserve the SysV semaphore behavior
for ( ; cnt < count; ++cnt) {
@@ -169,7 +169,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
}
setErrorString(QLatin1String("QSystemSemaphore::modifySemaphore (sem_wait)"));
#if defined QSYSTEMSEMAPHORE_DEBUG
- qDebug() << QLatin1String("QSystemSemaphore::modify sem_wait failed") << count << errno;
+ qDebug("QSystemSemaphore::modify sem_wait failed %d %d", count, errno);
#endif
return false;
}
diff --git a/src/corelib/kernel/qsystemsemaphore_systemv.cpp b/src/corelib/kernel/qsystemsemaphore_systemv.cpp
index f4fdfa5f58..1967899a58 100644
--- a/src/corelib/kernel/qsystemsemaphore_systemv.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_systemv.cpp
@@ -187,7 +187,8 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
}
setErrorString(QLatin1String("QSystemSemaphore::modifySemaphore"));
#if defined QSYSTEMSEMAPHORE_DEBUG
- qDebug() << QLatin1String("QSystemSemaphore::modify failed") << count << semctl(semaphore, 0, GETVAL) << errno << EIDRM << EINVAL;
+ qDebug("QSystemSemaphore::modify failed %d %d %d %d %d",
+ count, int(semctl(semaphore, 0, GETVAL)), int(errno), int(EIDRM), int(EINVAL);
#endif
return false;
}
diff --git a/src/corelib/kernel/qsystemsemaphore_win.cpp b/src/corelib/kernel/qsystemsemaphore_win.cpp
index 236e346afe..3395f5641e 100644
--- a/src/corelib/kernel/qsystemsemaphore_win.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_win.cpp
@@ -121,11 +121,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
return false;
}
} else {
-#if !defined(Q_OS_WINCE)
if (WAIT_OBJECT_0 != WaitForSingleObjectEx(semaphore, INFINITE, FALSE)) {
-#else
- if (WAIT_OBJECT_0 != WaitForSingleObject(semaphore, INFINITE)) {
-#endif
setErrorString(QLatin1String("QSystemSemaphore::modifySemaphore"));
#if defined QSYSTEMSEMAPHORE_DEBUG
qDebug("QSystemSemaphore::modifySemaphore WaitForSingleObject failed");
diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h
index dd52d52a1c..d97fe933b9 100644
--- a/src/corelib/kernel/qtimer.h
+++ b/src/corelib/kernel/qtimer.h
@@ -80,11 +80,17 @@ public:
static void singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, const char *member);
#ifdef Q_QDOC
+ template<typename PointerToMemberFunction>
static void singleShot(int msec, const QObject *receiver, PointerToMemberFunction method);
+ template<typename PointerToMemberFunction>
static void singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, PointerToMemberFunction method);
+ template<typename Functor>
static void singleShot(int msec, Functor functor);
+ template<typename Functor>
static void singleShot(int msec, Qt::TimerType timerType, Functor functor);
+ template<typename Functor, int>
static void singleShot(int msec, const QObject *context, Functor functor);
+ template<typename Functor, int>
static void singleShot(int msec, Qt::TimerType timerType, const QObject *context, Functor functor);
#else
// singleShot to a QObject slot
diff --git a/src/corelib/plugin/plugin.pri b/src/corelib/plugin/plugin.pri
index 544dd41742..473480eb55 100644
--- a/src/corelib/plugin/plugin.pri
+++ b/src/corelib/plugin/plugin.pri
@@ -35,8 +35,4 @@ integrity {
SOURCES += plugin/qlibrary_unix.cpp
}
-darwin {
- OBJECTIVE_SOURCES += plugin/quuid_darwin.mm
-}
-
!no-libdl: LIBS_PRIVATE += $$QMAKE_LIBS_DYNLOAD
diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp
index 6cd02e3a3f..c09dc6c22b 100644
--- a/src/corelib/plugin/qfactoryloader.cpp
+++ b/src/corelib/plugin/qfactoryloader.cpp
@@ -108,7 +108,11 @@ void QFactoryLoader::update()
if (!QDir(path).exists(QLatin1String(".")))
continue;
- QStringList plugins = QDir(path).entryList(QDir::Files);
+ QStringList plugins = QDir(path).entryList(
+#ifdef Q_OS_WIN
+ QStringList(QStringLiteral("*.dll")),
+#endif
+ QDir::Files);
QLibraryPrivate *library = 0;
#ifdef Q_OS_MAC
@@ -187,10 +191,12 @@ void QFactoryLoader::update()
++keyUsageCount;
}
}
- if (keyUsageCount || keys.isEmpty())
+ if (keyUsageCount || keys.isEmpty()) {
+ library->setLoadHints(QLibrary::PreventUnloadHint); // once loaded, don't unload
d->libraryList += library;
- else
+ } else {
library->release();
+ }
}
}
#else
diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp
index f6a947b61a..9db0b7ff39 100644
--- a/src/corelib/plugin/qlibrary_unix.cpp
+++ b/src/corelib/plugin/qlibrary_unix.cpp
@@ -50,10 +50,6 @@
# include <private/qcore_mac_p.h>
#endif
-#if defined(QT_AOUT_UNDERSCORE)
-#include <string.h>
-#endif
-
#if (defined(Q_OS_VXWORKS) && !defined(VXWORKS_RTP)) || defined (Q_OS_NACL)
#define QT_NO_DYNAMIC_LIBRARY
#endif
@@ -171,9 +167,6 @@ bool QLibraryPrivate::load_sys()
}
#if !defined(Q_OS_CYGWIN)
else {
-#if defined(Q_OS_MAC)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4)
-#endif
dlFlags |= RTLD_LOCAL;
}
#endif
@@ -308,14 +301,7 @@ Q_CORE_EXPORT QFunctionPointer qt_mac_resolve_sys(void *handle, const char *symb
QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol)
{
-#if defined(QT_AOUT_UNDERSCORE)
- // older a.out systems add an underscore in front of symbols
- char* undrscr_symbol = new char[strlen(symbol)+2];
- undrscr_symbol[0] = '_';
- strcpy(undrscr_symbol+1, symbol);
- QFunctionPointer address = QFunctionPointer(dlsym(pHnd, undrscr_symbol));
- delete [] undrscr_symbol;
-#elif defined(QT_HPUX_LD)
+#if defined(QT_HPUX_LD)
QFunctionPointer address = 0;
if (shl_findsym((shl_t*)&pHnd, symbol, TYPE_UNDEFINED, &address) < 0)
address = 0;
diff --git a/src/corelib/plugin/qlibrary_win.cpp b/src/corelib/plugin/qlibrary_win.cpp
index 46fbba151c..48aa0cdbb6 100644
--- a/src/corelib/plugin/qlibrary_win.cpp
+++ b/src/corelib/plugin/qlibrary_win.cpp
@@ -71,15 +71,6 @@ bool QLibraryPrivate::load_sys()
#endif
// We make the following attempts at locating the library:
//
- // WinCE
- // if (absolute)
- // fileName
- // fileName + ".dll"
- // else
- // fileName + ".dll"
- // fileName
- // QFileInfo(fileName).absoluteFilePath()
- //
// Windows
// if (absolute)
// fileName
@@ -97,14 +88,10 @@ bool QLibraryPrivate::load_sys()
// If the fileName is an absolute path we try that first, otherwise we
// use the system-specific suffix first
QFileSystemEntry fsEntry(fileName);
- if (fsEntry.isAbsolute()) {
+ if (fsEntry.isAbsolute())
attempts.prepend(fileName);
- } else {
+ else
attempts.append(fileName);
-#if defined(Q_OS_WINCE)
- attempts.append(QFileInfo(fileName).absoluteFilePath());
-#endif
- }
#ifdef Q_OS_WINRT
if (fileName.startsWith(QLatin1Char('/')))
attempts.prepend(QDir::rootPath() + fileName);
@@ -176,11 +163,7 @@ bool QLibraryPrivate::unload_sys()
QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol)
{
-#ifdef Q_OS_WINCE
- FARPROC address = GetProcAddress(pHnd, (const wchar_t*)QString::fromLatin1(symbol).utf16());
-#else
FARPROC address = GetProcAddress(pHnd, symbol);
-#endif
if (!address) {
errorString = QLibrary::tr("Cannot resolve symbol \"%1\" in %2: %3").arg(
QString::fromLatin1(symbol)).arg(
diff --git a/src/corelib/plugin/qmachparser.cpp b/src/corelib/plugin/qmachparser.cpp
index c136ef3797..a599fbcb23 100644
--- a/src/corelib/plugin/qmachparser.cpp
+++ b/src/corelib/plugin/qmachparser.cpp
@@ -59,6 +59,9 @@ static const cpu_type_t my_cputype = CPU_TYPE_X86;
static const cpu_type_t my_cputype = CPU_TYPE_POWERPC64;
#elif defined(Q_PROCESSOR_POWER_32)
static const cpu_type_t my_cputype = CPU_TYPE_POWERPC;
+#elif defined(Q_PROCESSOR_ARM_64)
+# define MACHO64
+static const cpu_type_t my_cputype = CPU_TYPE_ARM64;
#elif defined(Q_PROCESSOR_ARM)
static const cpu_type_t my_cputype = CPU_TYPE_ARM;
#else
diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp
index 62067c7ef7..4752f69ff3 100644
--- a/src/corelib/plugin/qpluginloader.cpp
+++ b/src/corelib/plugin/qpluginloader.cpp
@@ -154,6 +154,7 @@ QPluginLoader::QPluginLoader(const QString &fileName, QObject *parent)
: QObject(parent), d(0), did_load(false)
{
setFileName(fileName);
+ setLoadHints(QLibrary::PreventUnloadHint);
}
/*!
@@ -348,7 +349,7 @@ static QString locatePlugin(const QString& fileName)
void QPluginLoader::setFileName(const QString &fileName)
{
#if defined(QT_SHARED)
- QLibrary::LoadHints lh;
+ QLibrary::LoadHints lh = QLibrary::PreventUnloadHint;
if (d) {
lh = d->loadHints();
d->release();
@@ -394,7 +395,7 @@ QString QPluginLoader::errorString() const
\brief Give the load() function some hints on how it should behave.
You can give hints on how the symbols in the plugin are
- resolved. By default, none of the hints are set.
+ resolved. By default since Qt 5.7, QLibrary::PreventUnloadHint is set.
See the documentation of QLibrary::loadHints for a complete
description of how this property works.
diff --git a/src/corelib/plugin/qsystemlibrary.cpp b/src/corelib/plugin/qsystemlibrary.cpp
index 178a33f987..7c80fbbd42 100644
--- a/src/corelib/plugin/qsystemlibrary.cpp
+++ b/src/corelib/plugin/qsystemlibrary.cpp
@@ -68,23 +68,11 @@
DLL Safe search mode is documented in the "Dynamic-Link Library Search
Order" document on MSDN.
-
- Since library loading code is sometimes shared between Windows and WinCE,
- this class can also be used on WinCE. However, its implementation just
- calls the LoadLibrary() function. This is ok since it is documented as not
- loading from the current directory on WinCE. This behaviour is documented
- in the documentation for LoadLibrary for Windows CE at MSDN.
- (http://msdn.microsoft.com/en-us/library/ms886736.aspx)
*/
QT_BEGIN_NAMESPACE
-#if defined(Q_OS_WINCE)
-HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirectory /* = true */)
-{
- return ::LoadLibrary(libraryName);
-}
-#elif defined(Q_OS_WINRT)
+#if defined(Q_OS_WINRT)
HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirectory /* = true */)
{
Q_UNUSED(onlySystemDirectory);
@@ -141,6 +129,6 @@ HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirect
}
-#endif //Q_OS_WINCE
+#endif // Q_OS_WINRT
QT_END_NAMESPACE
diff --git a/src/corelib/plugin/qsystemlibrary_p.h b/src/corelib/plugin/qsystemlibrary_p.h
index 469376d81b..7b6d180df9 100644
--- a/src/corelib/plugin/qsystemlibrary_p.h
+++ b/src/corelib/plugin/qsystemlibrary_p.h
@@ -93,11 +93,7 @@ public:
load();
if (!m_handle)
return 0;
-#ifdef Q_OS_WINCE
- return QFunctionPointer(GetProcAddress(m_handle, (const wchar_t*)QString::fromLatin1(symbol).utf16()));
-#else
return QFunctionPointer(GetProcAddress(m_handle, symbol));
-#endif
}
static QFunctionPointer resolve(const QString &libraryName, const char *symbol)
diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp
index 5876bb84c3..1780039928 100644
--- a/src/corelib/plugin/quuid.cpp
+++ b/src/corelib/plugin/quuid.cpp
@@ -809,39 +809,6 @@ QUuid::Version QUuid::version() const Q_DECL_NOTHROW
return ver;
}
-/*! \fn QUuid QUuid::fromCFUUID(CFUUIDRef uuid)
- \since 5.7
-
- Constructs a new QUuid containing a copy of the \a uuid CFUUID.
-
- \note this function is only available on Apple platforms.
-*/
-
-/*! \fn CFUUIDRef QUuid::toCFUUID() const
- \since 5.7
-
- Creates a CFUUID from a QUuid. The caller owns the CFUUID and is
- responsible for releasing it.
-
- \note this function is only available on Apple platforms.
-*/
-
-/*! \fn QUuid QUuid::fromNSUUID(const NSUUID *uuid)
- \since 5.7
-
- Constructs a new QUuid containing a copy of the \a uuid NSUUID.
-
- \note this function is only available on Apple platforms.
-*/
-
-/*! \fn NSUUID QUuid::toNSUUID() const
- \since 5.7
-
- Creates a NSUUID from a QUuid. The NSUUID is autoreleased.
-
- \note this function is only available on Apple platforms.
-*/
-
/*!
\fn bool QUuid::operator<(const QUuid &other) const
diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h
index a1d16b449e..264f572993 100644
--- a/src/corelib/plugin/quuid.h
+++ b/src/corelib/plugin/quuid.h
@@ -55,11 +55,9 @@ typedef struct _GUID
#endif
#endif
-#ifdef Q_OS_DARWIN
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_FORWARD_DECLARE_CF_TYPE(CFUUID);
-# ifdef __OBJC__
Q_FORWARD_DECLARE_OBJC_CLASS(NSUUID);
-# endif
#endif
QT_BEGIN_NAMESPACE
@@ -210,10 +208,8 @@ public:
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
static QUuid fromCFUUID(CFUUIDRef uuid);
CFUUIDRef toCFUUID() const Q_DECL_CF_RETURNS_RETAINED;
-# if defined(__OBJC__) || defined(Q_QDOC)
static QUuid fromNSUUID(const NSUUID *uuid);
NSUUID *toNSUUID() const Q_DECL_NS_RETURNS_AUTORELEASED;
-# endif
#endif
uint data1;
diff --git a/src/corelib/plugin/quuid_darwin.mm b/src/corelib/plugin/quuid_darwin.mm
deleted file mode 100644
index c2a7240f3b..0000000000
--- a/src/corelib/plugin/quuid_darwin.mm
+++ /dev/null
@@ -1,75 +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 "quuid.h"
-
-#import <Foundation/Foundation.h>
-
-QT_BEGIN_NAMESPACE
-
-QUuid QUuid::fromCFUUID(CFUUIDRef uuid)
-{
- if (!uuid)
- return QUuid();
- const CFUUIDBytes bytes = CFUUIDGetUUIDBytes(uuid);
- return QUuid::fromRfc4122(QByteArray::fromRawData(reinterpret_cast<const char *>(&bytes), sizeof(bytes)));
-}
-
-CFUUIDRef QUuid::toCFUUID() const
-{
- const QByteArray bytes = toRfc4122();
- return CFUUIDCreateFromUUIDBytes(0, *reinterpret_cast<const CFUUIDBytes *>(bytes.constData()));
-}
-
-QUuid QUuid::fromNSUUID(const NSUUID *uuid)
-{
- if (!uuid)
- return QUuid();
- uuid_t bytes;
- [uuid getUUIDBytes:bytes];
- return QUuid::fromRfc4122(QByteArray::fromRawData(reinterpret_cast<const char *>(bytes), sizeof(bytes)));
-}
-
-NSUUID *QUuid::toNSUUID() const
-{
- const QByteArray bytes = toRfc4122();
- return [[[NSUUID alloc] initWithUUIDBytes:*reinterpret_cast<const uuid_t *>(bytes.constData())] autorelease];
-}
-
-QT_END_NAMESPACE
diff --git a/src/corelib/statemachine/qsignaltransition.h b/src/corelib/statemachine/qsignaltransition.h
index e8d413cd8a..d7cf8584da 100644
--- a/src/corelib/statemachine/qsignaltransition.h
+++ b/src/corelib/statemachine/qsignaltransition.h
@@ -60,6 +60,7 @@ public:
QSignalTransition(const QObject *sender, const char *signal,
QState *sourceState = Q_NULLPTR);
#ifdef Q_QDOC
+ template<typename PointerToMemberFunction>
QSignalTransition(const QObject *object, PointerToMemberFunction signal,
QState *sourceState = Q_NULLPTR);
#elif defined(Q_COMPILER_DELEGATING_CONSTRUCTORS)
diff --git a/src/corelib/statemachine/qstate.h b/src/corelib/statemachine/qstate.h
index ee1ff3fea3..7a9dc9c132 100644
--- a/src/corelib/statemachine/qstate.h
+++ b/src/corelib/statemachine/qstate.h
@@ -82,6 +82,7 @@ public:
void addTransition(QAbstractTransition *transition);
QSignalTransition *addTransition(const QObject *sender, const char *signal, QAbstractState *target);
#ifdef Q_QDOC
+ template<typename PointerToMemberFunction>
QSignalTransition *addTransition(const QObject *sender, PointerToMemberFunction signal,
QAbstractState *target);
#else
diff --git a/src/corelib/thread/qmutex_win.cpp b/src/corelib/thread/qmutex_win.cpp
index acb0f9dc61..3c314a4c0c 100644
--- a/src/corelib/thread/qmutex_win.cpp
+++ b/src/corelib/thread/qmutex_win.cpp
@@ -61,11 +61,7 @@ QMutexPrivate::~QMutexPrivate()
bool QMutexPrivate::wait(int timeout)
{
-#ifndef Q_OS_WINCE
return (WaitForSingleObjectEx(event, timeout < 0 ? INFINITE : timeout, FALSE) == WAIT_OBJECT_0);
-#else
- return (WaitForSingleObject(event, timeout < 0 ? INFINITE : timeout) == WAIT_OBJECT_0);
-#endif
}
void QMutexPrivate::wakeUp() Q_DECL_NOTHROW
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index ef1799a021..a14c193bad 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -55,15 +55,10 @@
#include <qt_windows.h>
#ifndef Q_OS_WINRT
-#ifndef Q_OS_WINCE
-#ifndef _MT
-#define _MT
-#endif // _MT
-#include <process.h>
-#else // !Q_OS_WINCE
-#include "qfunctions_wince.h"
-#endif // Q_OS_WINCE
-#else // !Q_OS_WINRT
+# ifndef _MT
+# define _MT
+# endif // _MT
+# include <process.h>
#endif // Q_OS_WINRT
#ifndef QT_NO_THREAD
@@ -150,7 +145,6 @@ QThreadData *QThreadData::current(bool createIfNecessary)
// WinRT API?
} else {
HANDLE realHandle = INVALID_HANDLE_VALUE;
-#if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600))
DuplicateHandle(GetCurrentProcess(),
GetCurrentThread(),
GetCurrentProcess(),
@@ -158,9 +152,6 @@ QThreadData *QThreadData::current(bool createIfNecessary)
0,
FALSE,
DUPLICATE_SAME_ACCESS);
-#else
- realHandle = reinterpret_cast<HANDLE>(GetCurrentThreadId());
-#endif
qt_watch_adopted_thread(realHandle, threadData->thread);
}
}
@@ -190,9 +181,7 @@ void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread)
QMutexLocker lock(&qt_adopted_thread_watcher_mutex);
if (GetCurrentThreadId() == qt_adopted_thread_watcher_id) {
-#if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600))
CloseHandle(adoptedThreadHandle);
-#endif
return;
}
@@ -291,9 +280,7 @@ DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID)
data->deref();
QMutexLocker lock(&qt_adopted_thread_watcher_mutex);
-#if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600))
CloseHandle(qt_adopted_thread_handles.at(handleIndex));
-#endif
qt_adopted_thread_handles.remove(handleIndex);
qt_adopted_qthreads.remove(qthreadIndex);
}
@@ -306,7 +293,7 @@ DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID)
return 0;
}
-#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
#ifndef Q_OS_WIN64
# define ULONG_PTR DWORD
@@ -336,7 +323,7 @@ void qt_set_thread_name(HANDLE threadId, LPCSTR threadName)
{
}
}
-#endif // !QT_NO_DEBUG && Q_CC_MSVC && !Q_OS_WINCE && !Q_OS_WINRT
+#endif // !QT_NO_DEBUG && Q_CC_MSVC && !Q_OS_WINRT
/**************************************************************************
** QThreadPrivate
@@ -378,7 +365,7 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
else
createEventDispatcher(data);
-#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
// sets the name of the current thread.
QByteArray objectName = thr->objectName().toLocal8Bit();
qt_set_thread_name((HANDLE)-1,
@@ -453,7 +440,7 @@ int QThread::idealThreadCount() Q_DECL_NOTHROW
void QThread::yieldCurrentThread()
{
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
SwitchToThread();
#else
::Sleep(0);
@@ -495,7 +482,6 @@ void QThread::start(Priority priority)
d->returnCode = 0;
d->interruptionRequested = false;
-#ifndef Q_OS_WINRT
/*
NOTE: we create the thread in the suspended state, set the
priority and then resume the thread.
@@ -506,9 +492,21 @@ 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
+ // MSVC -MT or -MTd build
d->handle = (Qt::HANDLE) _beginthreadex(NULL, d->stackSize, QThreadPrivate::start,
this, CREATE_SUSPENDED, &(d->id));
-#else // !Q_OS_WINRT
+#else
+ // MSVC -MD or -MDd or MinGW build
d->handle = (Qt::HANDLE) CreateThread(NULL, d->stackSize, (LPTHREAD_START_ROUTINE)QThreadPrivate::start,
this, CREATE_SUSPENDED, reinterpret_cast<LPDWORD>(&d->id));
#endif // Q_OS_WINRT
diff --git a/src/corelib/thread/qwaitcondition_win.cpp b/src/corelib/thread/qwaitcondition_win.cpp
index a95ca0b8fd..e6610f18c8 100644
--- a/src/corelib/thread/qwaitcondition_win.cpp
+++ b/src/corelib/thread/qwaitcondition_win.cpp
@@ -115,12 +115,7 @@ bool QWaitConditionPrivate::wait(QWaitConditionEvent *wce, unsigned long time)
{
// wait for the event
bool ret = false;
-#ifndef Q_OS_WINCE
switch (WaitForSingleObjectEx(wce->event, time, FALSE)) {
-#else
- switch (WaitForSingleObject(wce->event, time)) {
-#endif
-
default: break;
case WAIT_OBJECT_0:
diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h
index 4f704d6764..6e68bc7eb1 100644
--- a/src/corelib/tools/qalgorithms.h
+++ b/src/corelib/tools/qalgorithms.h
@@ -142,15 +142,9 @@ QT_DEPRECATED_X("Use std::count") inline void qCount(const Container &container,
}
#ifdef Q_QDOC
-template <typename T>
-LessThan qLess()
-{
-}
-
-template <typename T>
-LessThan qGreater()
-{
-}
+typedef void* LessThan;
+template <typename T> LessThan qLess();
+template <typename T> LessThan qGreater();
#else
template <typename T>
class QT_DEPRECATED_X("Use std::less") qLess
@@ -522,20 +516,148 @@ QT_DEPRECATED_X("Use std::binary_search") Q_OUTOFLINE_TEMPLATE RandomAccessItera
#endif // QT_DEPRECATED_SINCE(5, 2)
-} //namespace QAlgorithmsPrivate
-
+// Clang had a bug where __builtin_ctz/clz/popcount were not marked as constexpr.
+#if !defined Q_CC_CLANG || (defined __apple_build_version__ && __clang_major__ >= 7) \
+ || (Q_CC_CLANG >= 307)
+# define QT_HAS_CONSTEXPR_BUILTINS
+#endif
-// Use __builtin_popcount on gcc. Clang claims to be gcc
-// but has a bug where __builtin_popcount is not marked as
-// constexpr.
-#if defined(Q_CC_GNU) && !defined(Q_CC_CLANG)
+#if defined QT_HAS_CONSTEXPR_BUILTINS
+#if defined(Q_CC_GNU)
+# define QT_HAS_BUILTIN_CTZS
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) Q_DECL_NOTHROW
+{
+# if QT_HAS_BUILTIN(__builtin_ctzs) || defined(__BMI__)
+ return __builtin_ctzs(v);
+# else
+ return __builtin_ctz(v);
+# endif
+}
+#define QT_HAS_BUILTIN_CLZS
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW
+{
+# if QT_HAS_BUILTIN(__builtin_clzs) || defined(__BMI__)
+ return __builtin_clzs(v);
+# else
+ return __builtin_clz(v) - 16U;
+# endif
+}
+#define QT_HAS_BUILTIN_CTZ
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctz(quint32 v) Q_DECL_NOTHROW
+{
+ return __builtin_ctz(v);
+}
+#define QT_HAS_BUILTIN_CLZ
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clz(quint32 v) Q_DECL_NOTHROW
+{
+ return __builtin_clz(v);
+}
+#define QT_HAS_BUILTIN_CTZLL
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzll(quint64 v) Q_DECL_NOTHROW
+{
+ return __builtin_ctzll(v);
+}
+#define QT_HAS_BUILTIN_CLZLL
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzll(quint64 v) Q_DECL_NOTHROW
+{
+ return __builtin_clzll(v);
+}
#define QALGORITHMS_USE_BUILTIN_POPCOUNT
-#endif
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) Q_DECL_NOTHROW
+{
+ return __builtin_popcount(v);
+}
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint8 v) Q_DECL_NOTHROW
+{
+ return __builtin_popcount(v);
+}
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) Q_DECL_NOTHROW
+{
+ return __builtin_popcount(v);
+}
+#define QALGORITHMS_USE_BUILTIN_POPCOUNTLL
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW
+{
+ return __builtin_popcountll(v);
+}
+#elif defined(Q_CC_MSVC) && !defined(Q_OS_WINCE) && !defined(Q_PROCESSOR_ARM)
+#define QT_HAS_BUILTIN_CTZ
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE unsigned long qt_builtin_ctz(quint32 val)
+{
+ unsigned long result;
+ _BitScanForward(&result, val);
+ return result;
+}
+#define QT_HAS_BUILTIN_CLZ
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE unsigned long qt_builtin_clz(quint32 val)
+{
+ unsigned long result;
+ _BitScanReverse(&result, val);
+ // Now Invert the result: clz will count *down* from the msb to the lsb, so the msb index is 31
+ // and the lsb index is 0. The result for the index when counting up: msb index is 0 (because it
+ // starts there), and the lsb index is 31.
+ result ^= sizeof(quint32) * 8 - 1;
+ return result;
+}
+#if Q_PROCESSOR_WORDSIZE == 8
+// These are only defined for 64bit builds.
+#define QT_HAS_BUILTIN_CTZLL
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE unsigned long qt_builtin_ctzll(quint64 val)
+{
+ unsigned long result;
+ _BitScanForward64(&result, val);
+ return result;
+}
+// MSVC calls it _BitScanReverse and returns the carry flag, which we don't need
+#define QT_HAS_BUILTIN_CLZLL
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE unsigned long qt_builtin_clzll(quint64 val)
+{
+ unsigned long result;
+ _BitScanReverse64(&result, val);
+ // see qt_builtin_clz
+ result ^= sizeof(quint64) * 8 - 1;
+ return result;
+}
+#endif // MSVC 64bit
+# define QT_HAS_BUILTIN_CTZS
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) Q_DECL_NOTHROW
+{
+ return qt_builtin_ctz(v);
+}
+#define QT_HAS_BUILTIN_CLZS
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW
+{
+ return qt_builtin_clz(v) - 16U;
+}
+#define QALGORITHMS_USE_BUILTIN_POPCOUNT
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) Q_DECL_NOTHROW
+{
+ return __popcnt(v);
+}
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint8 v) Q_DECL_NOTHROW
+{
+ return __popcnt16(v);
+}
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) Q_DECL_NOTHROW
+{
+ return __popcnt16(v);
+}
+#if Q_PROCESSOR_WORDSIZE == 8
+#define QALGORITHMS_USE_BUILTIN_POPCOUNTLL
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW
+{
+ return __popcnt64(v);
+}
+#endif // MSVC 64bit
+#endif // MSVC
+#endif // QT_HAS_CONSTEXPR_BUILTINS
+
+} //namespace QAlgorithmsPrivate
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint32 v) Q_DECL_NOTHROW
{
#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
- return __builtin_popcount(v);
+ return QAlgorithmsPrivate::qt_builtin_popcount(v);
#else
// See http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
return
@@ -548,7 +670,7 @@ Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint32 v) Q
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint8 v) Q_DECL_NOTHROW
{
#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
- return __builtin_popcount(v);
+ return QAlgorithmsPrivate::qt_builtin_popcount(v);
#else
return
(((v ) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
@@ -558,7 +680,7 @@ Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint8 v) Q_
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint16 v) Q_DECL_NOTHROW
{
#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
- return __builtin_popcount(v);
+ return QAlgorithmsPrivate::qt_builtin_popcount(v);
#else
return
(((v ) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
@@ -568,8 +690,8 @@ Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint16 v) Q
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint64 v) Q_DECL_NOTHROW
{
-#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
- return __builtin_popcountll(v);
+#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNTLL
+ return QAlgorithmsPrivate::qt_builtin_popcountll(v);
#else
return
(((v ) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
@@ -592,8 +714,8 @@ Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(long unsigne
Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint32 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
- return v ? __builtin_ctz(v) : 32U;
+#if defined(QT_HAS_BUILTIN_CTZ)
+ return v ? QAlgorithmsPrivate::qt_builtin_ctz(v) : 32U;
#else
// see http://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightParallel
unsigned int c = 32; // c will be the number of zero bits on the right
@@ -610,8 +732,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint32 v) Q_DECL_NO
Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint8 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
- return v ? __builtin_ctz(v) : 8U;
+#if defined(QT_HAS_BUILTIN_CTZ)
+ return v ? QAlgorithmsPrivate::qt_builtin_ctz(v) : 8U;
#else
unsigned int c = 8; // c will be the number of zero bits on the right
v &= -signed(v);
@@ -625,12 +747,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint8 v) Q_DECL_NOT
Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint16 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
-# if QT_HAS_BUILTIN(__builtin_ctzs) || (defined(__LZCNT__) && defined(__BMI__))
- return v ? __builtin_ctzs(v) : 16U;
-# else
- return v ? __builtin_ctz(v) : 16U;
-# endif
+#if defined(QT_HAS_BUILTIN_CTZS)
+ return v ? QAlgorithmsPrivate::qt_builtin_ctzs(v) : 16U;
#else
unsigned int c = 16; // c will be the number of zero bits on the right
v &= -signed(v);
@@ -645,8 +763,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint16 v) Q_DECL_NO
Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint64 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
- return v ? __builtin_ctzll(v) : 64;
+#if defined(QT_HAS_BUILTIN_CTZLL)
+ return v ? QAlgorithmsPrivate::qt_builtin_ctzll(v) : 64;
#else
quint32 x = static_cast<quint32>(v);
return x ? qCountTrailingZeroBits(x)
@@ -661,8 +779,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(unsigned long v) Q_D
Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint32 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
- return v ? __builtin_clz(v) : 32U;
+#if defined(QT_HAS_BUILTIN_CLZ)
+ return v ? QAlgorithmsPrivate::qt_builtin_clz(v) : 32U;
#else
// Hacker's Delight, 2nd ed. Fig 5-16, p. 102
v = v | (v >> 1);
@@ -676,8 +794,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint32 v) Q_DECL_NOT
Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint8 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
- return v ? __builtin_clz(v)-24U : 8U;
+#if defined(QT_HAS_BUILTIN_CLZ)
+ return v ? QAlgorithmsPrivate::qt_builtin_clz(v)-24U : 8U;
#else
v = v | (v >> 1);
v = v | (v >> 2);
@@ -688,12 +806,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint8 v) Q_DECL_NOTH
Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint16 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
-# if QT_HAS_BUILTIN(__builtin_clzs) || (defined(__LZCNT__) && defined(__BMI__))
- return v ? __builtin_clzs(v) : 16U;
-# else
- return v ? __builtin_clz(v)-16U : 16U;
-# endif
+#if defined(QT_HAS_BUILTIN_CLZS)
+ return v ? QAlgorithmsPrivate::qt_builtin_clzs(v) : 16U;
#else
v = v | (v >> 1);
v = v | (v >> 2);
@@ -705,8 +819,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint16 v) Q_DECL_NOT
Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint64 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
- return v ? __builtin_clzll(v) : 64U;
+#if defined(QT_HAS_BUILTIN_CLZLL)
+ return v ? QAlgorithmsPrivate::qt_builtin_clzll(v) : 64U;
#else
v = v | (v >> 1);
v = v | (v >> 2);
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index c9d6f4e411..266c2e9b57 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -4467,91 +4467,6 @@ QByteArray QByteArray::fromPercentEncoding(const QByteArray &input, char percent
\sa fromStdString(), QString::toStdString()
*/
-/*! \fn QByteArray QByteArray::fromCFData(CFDataRef data)
- \since 5.3
-
- Constructs a new QByteArray containing a copy of the CFData \a data.
-
- \sa fromRawCFData(), fromRawData(), toRawCFData(), toCFData()
-*/
-
-/*! \fn QByteArray QByteArray::fromRawCFData(CFDataRef data)
- \since 5.3
-
- Constructs a QByteArray that uses the bytes of the CFData \a data.
-
- The \a data's bytes are not copied.
-
- The caller guarantees that the CFData will not be deleted
- or modified as long as this QByteArray object exists.
-
- \sa fromCFData(), fromRawData(), toRawCFData(), toCFData()
-*/
-
-/*! \fn CFDataRef QByteArray::toCFData() const
- \since 5.3
-
- Creates a CFData from a QByteArray. The caller owns the CFData object
- and is responsible for releasing it.
-
- \sa toRawCFData(), fromCFData(), fromRawCFData(), fromRawData()
-*/
-
-/*! \fn CFDataRef QByteArray::toRawCFData() const
- \since 5.3
-
- Constructs a CFData that uses the bytes of the QByteArray.
-
- The QByteArray's bytes are not copied.
-
- The caller guarantees that the QByteArray will not be deleted
- or modified as long as this CFData object exists.
-
- \sa toCFData(), fromRawCFData(), fromCFData(), fromRawData()
-*/
-
-/*! \fn QByteArray QByteArray::fromNSData(const NSData *data)
- \since 5.3
-
- Constructs a new QByteArray containing a copy of the NSData \a data.
-
- \sa fromRawNSData(), fromRawData(), toNSData(), toRawNSData()
-*/
-
-/*! \fn QByteArray QByteArray::fromRawNSData(const NSData *data)
- \since 5.3
-
- Constructs a QByteArray that uses the bytes of the NSData \a data.
-
- The \a data's bytes are not copied.
-
- The caller guarantees that the NSData will not be deleted
- or modified as long as this QByteArray object exists.
-
- \sa fromNSData(), fromRawData(), toRawNSData(), toNSData()
-*/
-
-/*! \fn NSData QByteArray::toNSData() const
- \since 5.3
-
- Creates a NSData from a QByteArray. The NSData object is autoreleased.
-
- \sa fromNSData(), fromRawNSData(), fromRawData(), toRawNSData()
-*/
-
-/*! \fn NSData QByteArray::toRawNSData() const
- \since 5.3
-
- Constructs a NSData that uses the bytes of the QByteArray.
-
- The QByteArray's bytes are not copied.
-
- The caller guarantees that the QByteArray will not be deleted
- or modified as long as this NSData object exists.
-
- \sa fromRawNSData(), fromNSData(), fromRawData(), toNSData()
-*/
-
static inline bool q_strchr(const char str[], char chr)
{
if (!str) return false;
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index d334bb43c5..477402d6de 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -56,11 +56,9 @@
#error qbytearray.h must be included before any header file that defines truncate
#endif
-#ifdef Q_OS_MAC
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_FORWARD_DECLARE_CF_TYPE(CFData);
-# ifdef __OBJC__
Q_FORWARD_DECLARE_OBJC_CLASS(NSData);
-# endif
#endif
QT_BEGIN_NAMESPACE
@@ -384,17 +382,15 @@ public:
static QByteArray fromHex(const QByteArray &hexEncoded) Q_REQUIRED_RESULT;
static QByteArray fromPercentEncoding(const QByteArray &pctEncoded, char percent = '%') Q_REQUIRED_RESULT;
-#if defined(Q_OS_MAC) || defined(Q_QDOC)
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
static QByteArray fromCFData(CFDataRef data);
static QByteArray fromRawCFData(CFDataRef data);
CFDataRef toCFData() const Q_DECL_CF_RETURNS_RETAINED;
CFDataRef toRawCFData() const Q_DECL_CF_RETURNS_RETAINED;
-# if defined(__OBJC__) || defined(Q_QDOC)
static QByteArray fromNSData(const NSData *data);
static QByteArray fromRawNSData(const NSData *data);
NSData *toNSData() const Q_DECL_NS_RETURNS_AUTORELEASED;
NSData *toRawNSData() const Q_DECL_NS_RETURNS_AUTORELEASED;
-# endif
#endif
typedef char *iterator;
diff --git a/src/corelib/tools/qbytearray_mac.mm b/src/corelib/tools/qbytearray_mac.mm
deleted file mode 100644
index 9386a966f0..0000000000
--- a/src/corelib/tools/qbytearray_mac.mm
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Samuel Gaist <samuel.gaist@edeltech.ch>
-** 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 "qbytearray.h"
-
-#import <Foundation/Foundation.h>
-
-QT_BEGIN_NAMESPACE
-
-QByteArray QByteArray::fromCFData(CFDataRef data)
-{
- if (!data)
- return QByteArray();
-
- return QByteArray(reinterpret_cast<const char *>(CFDataGetBytePtr(data)), CFDataGetLength(data));
-}
-
-QByteArray QByteArray::fromRawCFData(CFDataRef data)
-{
- if (!data)
- return QByteArray();
-
- return QByteArray::fromRawData(reinterpret_cast<const char *>(CFDataGetBytePtr(data)), CFDataGetLength(data));
-}
-
-CFDataRef QByteArray::toCFData() const
-{
- return CFDataCreate(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(data()), length());
-}
-
-CFDataRef QByteArray::toRawCFData() const
-{
- return CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(data()),
- length(), kCFAllocatorNull);
-}
-
-QByteArray QByteArray::fromNSData(const NSData *data)
-{
- if (!data)
- return QByteArray();
- return QByteArray(reinterpret_cast<const char *>([data bytes]), [data length]);
-}
-
-QByteArray QByteArray::fromRawNSData(const NSData *data)
-{
- if (!data)
- return QByteArray();
- return QByteArray::fromRawData(reinterpret_cast<const char *>([data bytes]), [data length]);
-}
-
-NSData *QByteArray::toNSData() const
-{
- return [NSData dataWithBytes:constData() length:size()];
-}
-
-NSData *QByteArray::toRawNSData() const
-{
- // const_cast is fine here because NSData is immutable thus will never modify bytes we're giving it
- return [NSData dataWithBytesNoCopy:const_cast<char *>(constData()) length:size() freeWhenDone:NO];
-}
-
-QT_END_NAMESPACE
diff --git a/src/corelib/tools/qbytearraylist.h b/src/corelib/tools/qbytearraylist.h
index bc8b08b380..501bb2e0d5 100644
--- a/src/corelib/tools/qbytearraylist.h
+++ b/src/corelib/tools/qbytearraylist.h
@@ -50,11 +50,13 @@ QT_BEGIN_NAMESPACE
typedef QListIterator<QByteArray> QByteArrayListIterator;
typedef QMutableListIterator<QByteArray> QMutableByteArrayListIterator;
+#ifndef Q_QDOC
typedef QList<QByteArray> QByteArrayList;
namespace QtPrivate {
QByteArray Q_CORE_EXPORT QByteArrayList_join(const QByteArrayList *that, const char *separator, int separatorLength);
}
+#endif
#ifdef Q_QDOC
class QByteArrayList : public QList<QByteArray>
diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h
index f01fbc109c..a83e5e6f98 100644
--- a/src/corelib/tools/qchar.h
+++ b/src/corelib/tools/qchar.h
@@ -578,6 +578,18 @@ Q_DECL_CONSTEXPR inline bool operator>=(QChar c1, QChar c2) Q_DECL_NOTHROW { ret
Q_DECL_CONSTEXPR inline bool operator> (QChar c1, QChar c2) Q_DECL_NOTHROW { return operator< (c2, c1); }
Q_DECL_CONSTEXPR inline bool operator<=(QChar c1, QChar c2) Q_DECL_NOTHROW { return !operator< (c2, c1); }
+// disambiguate QChar == int (but only that, so constrain template to exactly 'int'):
+template <typename T>
+Q_DECL_DEPRECATED_X("don't compare ints to QChars, compare them to QChar::unicode() instead")
+Q_DECL_CONSTEXPR inline
+typename std::enable_if<std::is_same<typename std::remove_cv<T>::type, int>::value, bool>::type
+operator==(QChar lhs, T rhs) Q_DECL_NOEXCEPT { return lhs == QChar(rhs); }
+template <typename T>
+Q_DECL_DEPRECATED_X("don't compare ints to QChars, compare them to QChar::unicode() instead")
+Q_DECL_CONSTEXPR inline
+typename std::enable_if<std::is_same<typename std::remove_cv<T>::type, int>::value, bool>::type
+operator!=(QChar lhs, T rhs) Q_DECL_NOEXCEPT { return lhs != QChar(rhs); }
+
#ifndef QT_NO_DATASTREAM
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, QChar);
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QChar &);
diff --git a/src/corelib/tools/qcommandlineoption.cpp b/src/corelib/tools/qcommandlineoption.cpp
index 64cabcc304..1f7f9cc33b 100644
--- a/src/corelib/tools/qcommandlineoption.cpp
+++ b/src/corelib/tools/qcommandlineoption.cpp
@@ -49,14 +49,12 @@ class QCommandLineOptionPrivate : public QSharedData
public:
Q_NEVER_INLINE
explicit QCommandLineOptionPrivate(const QString &name)
- : names(removeInvalidNames(QStringList(name))),
- hidden(false)
+ : names(removeInvalidNames(QStringList(name)))
{ }
Q_NEVER_INLINE
explicit QCommandLineOptionPrivate(const QStringList &names)
- : names(removeInvalidNames(names)),
- hidden(false)
+ : names(removeInvalidNames(names))
{ }
static QStringList removeInvalidNames(QStringList nameList);
@@ -74,8 +72,7 @@ public:
//! The list of default values used for this option.
QStringList defaultValues;
- //! Show or hide in --help
- bool hidden;
+ QCommandLineOption::Flags flags;
};
/*!
@@ -394,6 +391,7 @@ QStringList QCommandLineOption::defaultValues() const
return d->defaultValues;
}
+#if QT_DEPRECATED_SINCE(5, 8)
/*!
Sets whether to hide this option in the user-visible help output.
@@ -401,11 +399,12 @@ QStringList QCommandLineOption::defaultValues() const
a particular option makes it internal, i.e. not listed in the help output.
\since 5.6
+ \obsolete Use setFlags(QCommandLineOption::HiddenFromHelp), QCommandLineOption::HiddenFromHelp
\sa isHidden
*/
void QCommandLineOption::setHidden(bool hide)
{
- d->hidden = hide;
+ d->flags.setFlag(HiddenFromHelp, hide);
}
/*!
@@ -413,11 +412,52 @@ void QCommandLineOption::setHidden(bool hide)
false if the option is listed.
\since 5.6
- \sa setHidden()
+ \obsolete Use flags() & QCommandLineOption::HiddenFromHelp
+ \sa setHidden(), QCommandLineOption::HiddenFromHelp
*/
bool QCommandLineOption::isHidden() const
{
- return d->hidden;
+ return d->flags & HiddenFromHelp;
}
+#endif
+
+/*!
+ Returns a set of flags that affect this command-line option.
+
+ \since 5.8
+ \sa setFlags(), QCommandLineOption::Flags
+ */
+QCommandLineOption::Flags QCommandLineOption::flags() const
+{
+ return d->flags;
+}
+
+/*!
+ Set the set of flags that affect this command-line option.
+
+ \since 5.8
+ \sa flags(), QCommandLineOption::Flags
+ */
+void QCommandLineOption::setFlags(Flags flags)
+{
+ d->flags = flags;
+}
+
+/*!
+ \enum QCommandLineOption::Flag
+
+ \value HiddenFromHelp Hide this option in the user-visible help output. All
+ options are visible by default. Setting this flag for a particular
+ option makes it internal, i.e. not listed in the help output.
+
+ \value ShortOptionStyle The option will always be understood as a short
+ option, regardless of what was set by
+ QCommandLineParser::setSingleDashWordOptionMode.
+ This allows flags such as \c{-DDEFINE=VALUE} or \c{-I/include/path} to be
+ interpreted as short flags even when the parser is in
+ QCommandLineParser::ParseAsLongOptions mode.
+
+ \sa QCommandLineOption::setFlags(), QCommandLineOption::flags()
+*/
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qcommandlineoption.h b/src/corelib/tools/qcommandlineoption.h
index a7747f9fb2..6ebaab3d48 100644
--- a/src/corelib/tools/qcommandlineoption.h
+++ b/src/corelib/tools/qcommandlineoption.h
@@ -50,6 +50,12 @@ class QCommandLineOptionPrivate;
class Q_CORE_EXPORT QCommandLineOption
{
public:
+ enum Flag {
+ HiddenFromHelp = 0x1,
+ ShortOptionStyle = 0x2
+ };
+ Q_DECLARE_FLAGS(Flags, Flag)
+
explicit QCommandLineOption(const QString &name);
explicit QCommandLineOption(const QStringList &names);
/*implicit*/ QCommandLineOption(const QString &name, const QString &description,
@@ -82,14 +88,24 @@ public:
void setDefaultValues(const QStringList &defaultValues);
QStringList defaultValues() const;
+ Flags flags() const;
+ void setFlags(Flags aflags);
+
+#if QT_DEPRECATED_SINCE(5, 8)
+ QT_DEPRECATED_X("Use setFlags() with HiddenFromHelp)")
void setHidden(bool hidden);
+ QT_DEPRECATED_X("Use flags() and HiddenFromHelp")
bool isHidden() const;
+#endif
+
private:
QSharedDataPointer<QCommandLineOptionPrivate> d;
};
Q_DECLARE_SHARED(QCommandLineOption)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QCommandLineOption::Flags)
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp
index a7ab8b9e70..2450484ce9 100644
--- a/src/corelib/tools/qcommandlineparser.cpp
+++ b/src/corelib/tools/qcommandlineparser.cpp
@@ -44,7 +44,7 @@
#include <qhash.h>
#include <qvector.h>
#include <qdebug.h>
-#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WINRT)
# include <qt_windows.h>
#endif
#include <stdio.h>
@@ -295,7 +295,9 @@ QCommandLineParser::~QCommandLineParser()
i.e. as the long option named \c{abc}. This is how Qt's own tools
(uic, rcc...) have always been parsing arguments. This mode should be
used for preserving compatibility in applications that were parsing
- arguments in such a way.
+ arguments in such a way. There is an exception if the \c{a} option has the
+ QCommandLineOption::ShortOptionStyle flag set, in which case it is still
+ interpreted as \c{-a bc}.
\sa setSingleDashWordOptionMode()
*/
@@ -530,7 +532,7 @@ QString QCommandLineParser::errorText() const
enum MessageType { UsageMessage, ErrorMessage };
-#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WINRT)
// 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()
@@ -552,7 +554,7 @@ static void showParserMessage(const QString &message, MessageType type)
else
qCritical(qPrintable(message));
return;
-#elif defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WINCE)
+#elif defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED)
if (displayMessageBox()) {
const UINT flags = MB_OK | MB_TOPMOST | MB_SETFOREGROUND
| (type == UsageMessage ? MB_ICONINFORMATION : MB_ICONERROR);
@@ -565,7 +567,7 @@ static void showParserMessage(const QString &message, MessageType type)
reinterpret_cast<const wchar_t *>(title.utf16()), flags);
return;
}
-#endif // Q_OS_WIN && !QT_BOOTSTRAPPED && !Q_OS_WINCE
+#endif // Q_OS_WIN && !QT_BOOTSTRAPPED
fputs(qPrintable(message), type == UsageMessage ? stdout : stderr);
}
@@ -762,6 +764,18 @@ bool QCommandLineParserPrivate::parse(const QStringList &args)
}
case QCommandLineParser::ParseAsLongOptions:
{
+ if (argument.size() > 2) {
+ const QString possibleShortOptionStyleName = argument.mid(1, 1);
+ const auto shortOptionIt = nameHash.constFind(possibleShortOptionStyleName);
+ if (shortOptionIt != nameHash.constEnd()) {
+ const auto &arg = commandLineOptionList.at(*shortOptionIt);
+ if (arg.flags() & QCommandLineOption::ShortOptionStyle) {
+ registerFoundOption(possibleShortOptionStyleName);
+ optionValuesHash[*shortOptionIt].append(argument.mid(2));
+ break;
+ }
+ }
+ }
const QString optionName = argument.mid(1).section(assignChar, 0, 0);
if (registerFoundOption(optionName)) {
if (!parseOptionValue(optionName, argument, &argumentIterator, args.end()))
@@ -1098,7 +1112,7 @@ QString QCommandLineParserPrivate::helpText() const
optionNameList.reserve(commandLineOptionList.size());
int longestOptionNameString = 0;
for (const QCommandLineOption &option : commandLineOptionList) {
- if (option.isHidden())
+ if (option.flags() & QCommandLineOption::HiddenFromHelp)
continue;
const QStringList optionNames = option.names();
QString optionNamesString;
@@ -1117,7 +1131,7 @@ QString QCommandLineParserPrivate::helpText() const
++longestOptionNameString;
auto optionNameIterator = optionNameList.cbegin();
for (const QCommandLineOption &option : commandLineOptionList) {
- if (option.isHidden())
+ if (option.flags() & QCommandLineOption::HiddenFromHelp)
continue;
text += wrapText(*optionNameIterator, longestOptionNameString, option.description());
++optionNameIterator;
diff --git a/src/corelib/tools/qcryptographichash.h b/src/corelib/tools/qcryptographichash.h
index a19c734768..0f17baa036 100644
--- a/src/corelib/tools/qcryptographichash.h
+++ b/src/corelib/tools/qcryptographichash.h
@@ -42,6 +42,7 @@
#define QCRYPTOGRAPHICHASH_H
#include <QtCore/qbytearray.h>
+#include <QtCore/qobjectdefs.h>
QT_BEGIN_NAMESPACE
@@ -51,6 +52,7 @@ class QIODevice;
class Q_CORE_EXPORT QCryptographicHash
{
+ Q_GADGET
public:
enum Algorithm {
#ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1
@@ -69,6 +71,7 @@ public:
Sha3_512
#endif
};
+ Q_ENUM(Algorithm)
explicit QCryptographicHash(Algorithm method);
~QCryptographicHash();
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 6750925853..2ebf7c7977 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -57,9 +57,6 @@
#include <time.h>
#ifdef Q_OS_WIN
# include <qt_windows.h>
-# ifdef Q_OS_WINCE
-# include "qfunctions_wince.h"
-# endif
# ifdef Q_OS_WINRT
# include "qfunctions_winrt.h"
# endif
@@ -71,8 +68,6 @@
QT_BEGIN_NAMESPACE
-Q_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer<QDateTimePrivate>, defaultDateTimePrivate, (new QDateTimePrivate()))
-
/*****************************************************************************
Date/Time Constants
*****************************************************************************/
@@ -1685,9 +1680,6 @@ QString QTime::toString(const QString& format) const
bool QTime::setHMS(int h, int m, int s, int ms)
{
-#if defined(Q_OS_WINCE)
- startTick = NullTime;
-#endif
if (!isValid(h,m,s,ms)) {
mds = NullTime; // make this invalid
return false;
@@ -1767,10 +1759,6 @@ QTime QTime::addMSecs(int ms) const
t.mds = (ds() + ms) % MSECS_PER_DAY;
}
}
-#if defined(Q_OS_WINCE)
- if (startTick > NullTime)
- t.startTick = (startTick + ms) % MSECS_PER_DAY;
-#endif
return t;
}
@@ -1792,13 +1780,7 @@ int QTime::msecsTo(const QTime &t) const
{
if (!isValid() || !t.isValid())
return 0;
-#if defined(Q_OS_WINCE)
- // GetLocalTime() for Windows CE has no milliseconds resolution
- if (t.startTick > NullTime && startTick > NullTime)
- return t.startTick - startTick;
- else
-#endif
- return t.ds() - ds();
+ return t.ds() - ds();
}
@@ -2137,13 +2119,14 @@ int QTime::elapsed() const
QDateTime static helper functions
*****************************************************************************/
+// get the types from QDateTime (through QDateTimePrivate)
+typedef QDateTimePrivate::QDateTimeShortData ShortData;
+typedef QDateTimePrivate::QDateTimeData QDateTimeData;
+
// Calls the platform variant of tzset
static void qt_tzset()
{
-#if defined(Q_OS_WINCE)
- // WinCE doesn't use tzset
- return;
-#elif defined(Q_OS_WIN)
+#if defined(Q_OS_WIN)
_tzset();
#else
tzset();
@@ -2157,12 +2140,7 @@ static void qt_tzset()
// Relies on tzset, mktime, or localtime having been called to populate timezone
static int qt_timezone()
{
-#if defined(Q_OS_WINCE)
- TIME_ZONE_INFORMATION tzi;
- GetTimeZoneInformation(&tzi);
- // Expressed in minutes, convert to seconds
- return (tzi.Bias + tzi.StandardBias) * 60;
-#elif defined(_MSC_VER) && _MSC_VER >= 1400
+#if defined(_MSC_VER)
long offset;
_get_timezone(&offset);
return offset;
@@ -2191,16 +2169,6 @@ static int qt_timezone()
// Returns the tzname, assume tzset has been called already
static QString qt_tzname(QDateTimePrivate::DaylightStatus daylightStatus)
{
-#if defined(Q_OS_WINCE)
- TIME_ZONE_INFORMATION tzi;
- DWORD res = GetTimeZoneInformation(&tzi);
- if (res == TIME_ZONE_ID_UNKNOWN)
- return QString();
- else if (daylightStatus == QDateTimePrivate::DaylightTime)
- return QString::fromWCharArray(tzi.DaylightName);
- else
- return QString::fromWCharArray(tzi.StandardName);
-#else
int isDst = (daylightStatus == QDateTimePrivate::DaylightTime) ? 1 : 0;
#if defined(_MSC_VER) && _MSC_VER >= 1400
size_t s = 0;
@@ -2211,7 +2179,6 @@ static QString qt_tzname(QDateTimePrivate::DaylightStatus daylightStatus)
#else
return QString::fromLocal8Bit(tzname[isDst]);
#endif // Q_OS_WIN
-#endif // Q_OS_WINCE
}
// Calls the platform variant of mktime for the given date, time and daylightStatus,
@@ -2226,48 +2193,6 @@ static qint64 qt_mktime(QDate *date, QTime *time, QDateTimePrivate::DaylightStat
int yy, mm, dd;
date->getDate(&yy, &mm, &dd);
-#if defined(Q_OS_WINCE)
- // WinCE doesn't provide standard C library time functions
- SYSTEMTIME st;
- memset(&st, 0, sizeof(SYSTEMTIME));
- st.wSecond = time->second();
- st.wMinute = time->minute();
- st.wHour = time->hour();
- st.wDay = dd;
- st.wMonth = mm;
- st.wYear = yy;
- FILETIME lft;
- bool valid = SystemTimeToFileTime(&st, &lft);
- FILETIME ft;
- if (valid)
- valid = LocalFileTimeToFileTime(&lft, &ft);
- const time_t secsSinceEpoch = ftToTime_t(ft);
- const time_t localSecs = ftToTime_t(lft);
- TIME_ZONE_INFORMATION tzi;
- GetTimeZoneInformation(&tzi);
- bool isDaylight = false;
- // Check for overflow
- qint64 localDiff = qAbs(localSecs - secsSinceEpoch);
- int daylightOffset = qAbs(tzi.Bias + tzi.DaylightBias) * 60;
- if (localDiff > daylightOffset)
- valid = false;
- else
- isDaylight = (localDiff == daylightOffset);
- if (daylightStatus) {
- if (isDaylight)
- *daylightStatus = QDateTimePrivate::DaylightTime;
- else
- *daylightStatus = QDateTimePrivate::StandardTime;
- }
- if (abbreviation) {
- if (isDaylight)
- *abbreviation = QString::fromWCharArray(tzi.DaylightName);
- else
- *abbreviation = QString::fromWCharArray(tzi.StandardName);
- }
- if (ok)
- *ok = valid;
-#else
// All other platforms provide standard C library time functions
tm local;
memset(&local, 0, sizeof(local)); // tm_[wy]day plus any non-standard fields
@@ -2329,7 +2254,6 @@ static qint64 qt_mktime(QDate *date, QTime *time, QDateTimePrivate::DaylightStat
if (ok)
*ok = false;
}
-#endif // Q_OS_WINCE
return ((qint64)secsSinceEpoch * 1000) + msec;
}
@@ -2345,23 +2269,7 @@ static bool qt_localtime(qint64 msecsSinceEpoch, QDate *localDate, QTime *localT
tm local;
bool valid = false;
-#if defined(Q_OS_WINCE)
- FILETIME utcTime = time_tToFt(secsSinceEpoch);
- FILETIME resultTime;
- valid = FileTimeToLocalFileTime(&utcTime , &resultTime);
- SYSTEMTIME sysTime;
- if (valid)
- valid = FileTimeToSystemTime(&resultTime , &sysTime);
-
- if (valid) {
- local.tm_sec = sysTime.wSecond;
- local.tm_min = sysTime.wMinute;
- local.tm_hour = sysTime.wHour;
- local.tm_mday = sysTime.wDay;
- local.tm_mon = sysTime.wMonth - 1;
- local.tm_year = sysTime.wYear - 1900;
- }
-#elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
+#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
// localtime() is required to work as if tzset() was called before it.
// localtime_r() does not have this requirement, so make an explicit call.
qt_tzset();
@@ -2574,240 +2482,403 @@ static qint64 localMSecsToEpochMSecs(qint64 localMsecs,
}
}
-/*****************************************************************************
- QDateTimePrivate member functions
- *****************************************************************************/
+static inline bool specCanBeSmall(Qt::TimeSpec spec)
+{
+ return spec == Qt::LocalTime || spec == Qt::UTC;
+}
-QDateTimePrivate::QDateTimePrivate(const QDate &toDate, const QTime &toTime, Qt::TimeSpec toSpec,
- int offsetSeconds)
- : m_msecs(0),
- m_spec(Qt::LocalTime),
- m_offsetFromUtc(0),
- m_status(0)
+static Q_DECL_CONSTEXPR inline
+QDateTimePrivate::StatusFlags mergeSpec(QDateTimePrivate::StatusFlags status, Qt::TimeSpec spec)
{
- setTimeSpec(toSpec, offsetSeconds);
- setDateTime(toDate, toTime);
+ return QDateTimePrivate::StatusFlags((status & ~QDateTimePrivate::TimeSpecMask) |
+ (int(spec) << QDateTimePrivate::TimeSpecShift));
}
-#ifndef QT_BOOTSTRAPPED
-QDateTimePrivate::QDateTimePrivate(const QDate &toDate, const QTime &toTime,
- const QTimeZone &toTimeZone)
- : m_spec(Qt::TimeZone),
- m_offsetFromUtc(0),
- m_timeZone(toTimeZone),
- m_status(0)
+static Q_DECL_CONSTEXPR inline Qt::TimeSpec extractSpec(QDateTimePrivate::StatusFlags status)
{
- setDateTime(toDate, toTime);
+ return Qt::TimeSpec((status & QDateTimePrivate::TimeSpecMask) >> QDateTimePrivate::TimeSpecShift);
}
-#endif // QT_BOOTSTRAPPED
-void QDateTimePrivate::setTimeSpec(Qt::TimeSpec spec, int offsetSeconds)
+// Set the Daylight Status if LocalTime set via msecs
+static Q_DECL_RELAXED_CONSTEXPR inline QDateTimePrivate::StatusFlags
+mergeDaylightStatus(QDateTimePrivate::StatusFlags sf, QDateTimePrivate::DaylightStatus status)
+{
+ sf &= ~QDateTimePrivate::DaylightMask;
+ if (status == QDateTimePrivate::DaylightTime) {
+ sf |= QDateTimePrivate::SetToDaylightTime;
+ } else if (status == QDateTimePrivate::StandardTime) {
+ sf |= QDateTimePrivate::SetToStandardTime;
+ }
+ return sf;
+}
+
+// Get the DST Status if LocalTime set via msecs
+static Q_DECL_RELAXED_CONSTEXPR inline
+QDateTimePrivate::DaylightStatus extractDaylightStatus(QDateTimePrivate::StatusFlags status)
{
- clearValidDateTime();
- clearSetToDaylightStatus();
+ if (status & QDateTimePrivate::SetToDaylightTime)
+ return QDateTimePrivate::DaylightTime;
+ if (status & QDateTimePrivate::SetToStandardTime)
+ return QDateTimePrivate::StandardTime;
+ return QDateTimePrivate::UnknownDaylightTime;
+}
+
+static inline qint64 getMSecs(const QDateTimeData &d)
+{
+ if (d.isShort()) {
+ // same as, but producing better code
+ //return d.data.msecs;
+ return qintptr(d.d) >> 8;
+ }
+ return d->m_msecs;
+}
+
+static inline QDateTimePrivate::StatusFlags getStatus(const QDateTimeData &d)
+{
+ if (d.isShort()) {
+ // same as, but producing better code
+ //return StatusFlag(d.data.status);
+ return QDateTimePrivate::StatusFlag(qintptr(d.d) & 0xFF);
+ }
+ return d->m_status;
+}
+
+static inline Qt::TimeSpec getSpec(const QDateTimeData &d)
+{
+ return extractSpec(getStatus(d));
+}
+
+// Refresh the LocalTime validity and offset
+static void refreshDateTime(QDateTimeData &d)
+{
+ auto status = getStatus(d);
+ const auto spec = extractSpec(status);
+ const qint64 msecs = getMSecs(d);
+ qint64 epochMSecs = 0;
+ int offsetFromUtc = 0;
+ QDate testDate;
+ QTime testTime;
+ Q_ASSERT(spec == Qt::TimeZone || spec == Qt::LocalTime);
#ifndef QT_BOOTSTRAPPED
- m_timeZone = QTimeZone();
+ // If not valid time zone then is invalid
+ if (spec == Qt::TimeZone) {
+ if (!d->m_timeZone.isValid())
+ status &= ~QDateTimePrivate::ValidDateTime;
+ else
+ epochMSecs = QDateTimePrivate::zoneMSecsToEpochMSecs(msecs, d->m_timeZone, &testDate, &testTime);
+ }
#endif // QT_BOOTSTRAPPED
- switch (spec) {
- case Qt::OffsetFromUTC:
- if (offsetSeconds == 0) {
- m_spec = Qt::UTC;
- m_offsetFromUtc = 0;
+ // If not valid date and time then is invalid
+ if (!(status & QDateTimePrivate::ValidDate) || !(status & QDateTimePrivate::ValidTime)) {
+ status &= ~QDateTimePrivate::ValidDateTime;
+ if (status & QDateTimePrivate::ShortData) {
+ d.data.status = status;
} else {
- m_spec = Qt::OffsetFromUTC;
- m_offsetFromUtc = offsetSeconds;
+ d->m_status = status;
+ d->m_offsetFromUtc = 0;
}
+ return;
+ }
+
+ // We have a valid date and time and a Qt::LocalTime or Qt::TimeZone that needs calculating
+ // LocalTime and TimeZone might fall into a "missing" DST transition hour
+ // Calling toEpochMSecs will adjust the returned date/time if it does
+ if (spec == Qt::LocalTime) {
+ auto dstStatus = extractDaylightStatus(status);
+ epochMSecs = localMSecsToEpochMSecs(msecs, &dstStatus, &testDate, &testTime);
+ }
+ if (timeToMSecs(testDate, testTime) == msecs) {
+ status |= QDateTimePrivate::ValidDateTime;
+ // Cache the offset to use in offsetFromUtc()
+ offsetFromUtc = (msecs - epochMSecs) / 1000;
+ } else {
+ status &= ~QDateTimePrivate::ValidDateTime;
+ }
+
+ if (status & QDateTimePrivate::ShortData) {
+ d.data.status = status;
+ } else {
+ d->m_status = status;
+ d->m_offsetFromUtc = offsetFromUtc;
+ }
+}
+
+// Check the UTC / offsetFromUTC validity
+static void checkValidDateTime(QDateTimeData &d)
+{
+ auto status = getStatus(d);
+ auto spec = extractSpec(status);
+ switch (spec) {
+ case Qt::OffsetFromUTC:
+ case Qt::UTC:
+ // for these, a valid date and a valid time imply a valid QDateTime
+ if ((status & QDateTimePrivate::ValidDate) && (status & QDateTimePrivate::ValidTime))
+ status |= QDateTimePrivate::ValidDateTime;
+ else
+ status &= ~QDateTimePrivate::ValidDateTime;
+ if (status & QDateTimePrivate::ShortData)
+ d.data.status = status;
+ else
+ d->m_status = status;
break;
case Qt::TimeZone:
- // Use system time zone instead
- m_spec = Qt::LocalTime;
- m_offsetFromUtc = 0;
+ case Qt::LocalTime:
+ // for these, we need to check whether the timezone is valid and whether
+ // the time is valid in that timezone. Expensive, but no other option.
+ refreshDateTime(d);
break;
+ }
+}
+
+static void setTimeSpec(QDateTimeData &d, Qt::TimeSpec spec, int offsetSeconds)
+{
+ auto status = getStatus(d);
+ status &= ~(QDateTimePrivate::ValidDateTime | QDateTimePrivate::DaylightMask |
+ QDateTimePrivate::TimeSpecMask);
+
+ switch (spec) {
+ case Qt::OffsetFromUTC:
+ if (offsetSeconds == 0)
+ spec = Qt::UTC;
+ break;
+ case Qt::TimeZone:
+ // Use system time zone instead
+ spec = Qt::LocalTime;
+ // fallthrough
case Qt::UTC:
case Qt::LocalTime:
- m_spec = spec;
- m_offsetFromUtc = 0;
+ offsetSeconds = 0;
break;
}
+
+ status = mergeSpec(status, spec);
+ if (d.isShort() && offsetSeconds == 0) {
+ d.data.status = status;
+ } else {
+ d.detach();
+ d->m_status = status & ~QDateTimePrivate::ShortData;
+ d->m_offsetFromUtc = offsetSeconds;
+#ifndef QT_BOOTSTRAPPED
+ d->m_timeZone = QTimeZone();
+#endif // QT_BOOTSTRAPPED
+ }
}
-void QDateTimePrivate::setDateTime(const QDate &date, const QTime &time)
+static void setDateTime(QDateTimeData &d, const QDate &date, const QTime &time)
{
// If the date is valid and the time is not we set time to 00:00:00
QTime useTime = time;
if (!useTime.isValid() && date.isValid())
useTime = QTime::fromMSecsSinceStartOfDay(0);
- StatusFlags newStatus;
+ QDateTimePrivate::StatusFlags newStatus = 0;
// Set date value and status
qint64 days = 0;
if (date.isValid()) {
days = date.toJulianDay() - JULIAN_DAY_FOR_EPOCH;
- newStatus = ValidDate;
- } else if (date.isNull()) {
- newStatus = NullDate;
+ newStatus = QDateTimePrivate::ValidDate;
}
// Set time value and status
int ds = 0;
if (useTime.isValid()) {
ds = useTime.msecsSinceStartOfDay();
- newStatus |= ValidTime;
- } else if (time.isNull()) {
- newStatus |= NullTime;
+ newStatus |= QDateTimePrivate::ValidTime;
}
// Set msecs serial value
- m_msecs = (days * MSECS_PER_DAY) + ds;
- m_status = newStatus;
+ qint64 msecs = (days * MSECS_PER_DAY) + ds;
+ if (d.isShort()) {
+ // let's see if we can keep this short
+ d.data.msecs = qintptr(msecs);
+ if (d.data.msecs == msecs) {
+ // yes, we can
+ d.data.status &= ~(QDateTimePrivate::ValidityMask | QDateTimePrivate::DaylightMask);
+ d.data.status |= newStatus;
+ } else {
+ // nope...
+ d.detach();
+ }
+ }
+ if (!d.isShort()) {
+ d.detach();
+ d->m_msecs = msecs;
+ d->m_status &= ~(QDateTimePrivate::ValidityMask | QDateTimePrivate::DaylightMask);
+ d->m_status |= newStatus;
+ }
// Set if date and time are valid
- checkValidDateTime();
+ checkValidDateTime(d);
}
-QPair<QDate, QTime> QDateTimePrivate::getDateTime() const
+static QPair<QDate, QTime> getDateTime(const QDateTimeData &d)
{
QPair<QDate, QTime> result;
- msecsToTime(m_msecs, &result.first, &result.second);
+ qint64 msecs = getMSecs(d);
+ auto status = getStatus(d);
+ msecsToTime(msecs, &result.first, &result.second);
- if (isNullDate())
+ if (!status.testFlag(QDateTimePrivate::ValidDate))
result.first = QDate();
- if (isNullTime())
+ if (!status.testFlag(QDateTimePrivate::ValidTime))
result.second = QTime();
return result;
}
-// Set the Daylight Status if LocalTime set via msecs
-void QDateTimePrivate::setDaylightStatus(QDateTimePrivate::DaylightStatus status)
-{
- if (status == DaylightTime) {
- m_status = m_status & ~SetToStandardTime;
- m_status = m_status | SetToDaylightTime;
- } else if (status == StandardTime) {
- m_status = m_status & ~SetToDaylightTime;
- m_status = m_status | SetToStandardTime;
+/*****************************************************************************
+ QDateTime::Data member functions
+ *****************************************************************************/
+
+inline QDateTime::Data::Data(Qt::TimeSpec spec)
+{
+ if (CanBeSmall && Q_LIKELY(specCanBeSmall(spec))) {
+ d = reinterpret_cast<QDateTimePrivate *>(int(mergeSpec(QDateTimePrivate::ShortData, spec)));
} else {
- clearSetToDaylightStatus();
+ // the structure is too small, we need to detach
+ d = new QDateTimePrivate;
+ d->ref.ref();
+ d->m_status = mergeSpec(0, spec);
}
}
-// Get the DST Status if LocalTime set via msecs
-QDateTimePrivate::DaylightStatus QDateTimePrivate::daylightStatus() const
+inline QDateTime::Data::Data(const Data &other)
+ : d(other.d)
{
- if ((m_status & SetToDaylightTime) == SetToDaylightTime)
- return DaylightTime;
- if ((m_status & SetToStandardTime) == SetToStandardTime)
- return StandardTime;
- return UnknownDaylightTime;
+ if (!isShort()) {
+ // check if we could shrink
+ ShortData sd;
+ sd.msecs = qintptr(d->m_msecs);
+ if (CanBeSmall && specCanBeSmall(extractSpec(d->m_status)) && sd.msecs == d->m_msecs) {
+ sd.status = d->m_status | QDateTimePrivate::ShortData;
+ data = sd;
+ } else {
+ // no, have to keep it big
+ d->ref.ref();
+ }
+ }
}
-qint64 QDateTimePrivate::toMSecsSinceEpoch() const
+inline QDateTime::Data::Data(Data &&other)
+ : d(other.d)
{
- switch (m_spec) {
- case Qt::OffsetFromUTC:
- case Qt::UTC:
- return (m_msecs - (m_offsetFromUtc * 1000));
-
- case Qt::LocalTime: {
- // recalculate the local timezone
- DaylightStatus status = daylightStatus();
- return localMSecsToEpochMSecs(m_msecs, &status);
+ // reset the other to a short state, if we can
+ if (CanBeSmall) {
+ Data dummy(Qt::LocalTime);
+ Q_ASSERT(dummy.isShort());
+ other.d = dummy.d;
+ } else if (!isShort()) {
+ // can't be small, so do implicit sharing
+ d->ref.ref();
}
+}
- case Qt::TimeZone:
-#ifdef QT_BOOTSTRAPPED
- break;
-#else
- return zoneMSecsToEpochMSecs(m_msecs, m_timeZone);
-#endif
+inline QDateTime::Data &QDateTime::Data::operator=(const Data &other)
+{
+ if (d == other.d)
+ return *this;
+
+ auto x = d;
+ d = other.d;
+ if (!other.isShort()) {
+ // check if we could shrink
+ ShortData sd;
+ sd.msecs = qintptr(other.d->m_msecs);
+ if (CanBeSmall && specCanBeSmall(extractSpec(other.d->m_status)) && sd.msecs == other.d->m_msecs) {
+ sd.status = other.d->m_status | QDateTimePrivate::ShortData;
+ data = sd;
+ } else {
+ // no, have to keep it big
+ other.d->ref.ref();
+ }
}
- Q_UNREACHABLE();
- return 0;
+
+ if (!(CanBeSmall && quintptr(x) & QDateTimePrivate::ShortData) && !x->ref.deref())
+ delete x;
+ return *this;
}
-// Check the UTC / offsetFromUTC validity
-void QDateTimePrivate::checkValidDateTime()
+inline QDateTime::Data::~Data()
{
- switch (m_spec) {
- case Qt::OffsetFromUTC:
- case Qt::UTC:
- // for these, a valid date and a valid time imply a valid QDateTime
- if (isValidDate() && isValidTime())
- setValidDateTime();
- else
- clearValidDateTime();
- break;
- case Qt::TimeZone:
- case Qt::LocalTime:
- // for these, we need to check whether the timezone is valid and whether
- // the time is valid in that timezone. Expensive, but no other option.
- refreshDateTime();
- break;
- }
+ if (!isShort() && !d->ref.deref())
+ delete d;
}
-// Refresh the LocalTime validity and offset
-void QDateTimePrivate::refreshDateTime()
+inline bool QDateTime::Data::isShort() const
{
- switch (m_spec) {
- case Qt::OffsetFromUTC:
- case Qt::UTC:
- // Always set by setDateTime so just return
- return;
- case Qt::TimeZone:
- case Qt::LocalTime:
- break;
- }
+ return CanBeSmall && quintptr(d) & QDateTimePrivate::ShortData;
+}
- // If not valid date and time then is invalid
- if (!isValidDate() || !isValidTime()) {
- clearValidDateTime();
- m_offsetFromUtc = 0;
- return;
- }
+inline void QDateTime::Data::detach()
+{
+ QDateTimePrivate *x;
+ bool wasShort = isShort();
+ if (wasShort) {
+ // force enlarging
+ x = new QDateTimePrivate;
+ x->m_status = QDateTimePrivate::StatusFlag(data.status & ~QDateTimePrivate::ShortData);
+ x->m_msecs = data.msecs;
+ } else {
+ if (d->ref.load() == 1)
+ return;
-#ifndef QT_BOOTSTRAPPED
- // If not valid time zone then is invalid
- if (m_spec == Qt::TimeZone && !m_timeZone.isValid()) {
- clearValidDateTime();
- m_offsetFromUtc = 0;
- return;
+ x = new QDateTimePrivate(*d);
}
-#endif // QT_BOOTSTRAPPED
- // We have a valid date and time and a Qt::LocalTime or Qt::TimeZone that needs calculating
- // LocalTime and TimeZone might fall into a "missing" DST transition hour
- // Calling toEpochMSecs will adjust the returned date/time if it does
- QDate testDate;
- QTime testTime;
- qint64 epochMSecs = 0;
- if (m_spec == Qt::LocalTime) {
- DaylightStatus status = daylightStatus();
- epochMSecs = localMSecsToEpochMSecs(m_msecs, &status, &testDate, &testTime);
-#ifndef QT_BOOTSTRAPPED
- } else {
- epochMSecs = zoneMSecsToEpochMSecs(m_msecs, m_timeZone, &testDate, &testTime);
-#endif // QT_BOOTSTRAPPED
- }
- if (timeToMSecs(testDate, testTime) == m_msecs) {
- setValidDateTime();
- // Cache the offset to use in toMSecsSinceEpoch()
- m_offsetFromUtc = (m_msecs - epochMSecs) / 1000;
- } else {
- clearValidDateTime();
- m_offsetFromUtc = 0;
- }
+ x->ref.store(1);
+ if (!wasShort && !d->ref.deref())
+ delete d;
+ d = x;
+}
+
+inline const QDateTimePrivate *QDateTime::Data::operator->() const
+{
+ Q_ASSERT(!isShort());
+ return d;
+}
+
+inline QDateTimePrivate *QDateTime::Data::operator->()
+{
+ // should we attempt to detach here?
+ Q_ASSERT(!isShort());
+ Q_ASSERT(d->ref.load() == 1);
+ return d;
+}
+
+/*****************************************************************************
+ QDateTimePrivate member functions
+ *****************************************************************************/
+
+Q_NEVER_INLINE
+QDateTime::Data QDateTimePrivate::create(const QDate &toDate, const QTime &toTime, Qt::TimeSpec toSpec,
+ int offsetSeconds)
+{
+ QDateTime::Data result(toSpec);
+ setTimeSpec(result, toSpec, offsetSeconds);
+ setDateTime(result, toDate, toTime);
+ return result;
}
#ifndef QT_BOOTSTRAPPED
+inline QDateTime::Data QDateTimePrivate::create(const QDate &toDate, const QTime &toTime,
+ const QTimeZone &toTimeZone)
+{
+ QDateTime::Data result(Qt::TimeZone);
+ Q_ASSERT(!result.isShort());
+
+ result.d->m_status = mergeSpec(result.d->m_status, Qt::TimeZone);
+ result.d->m_timeZone = toTimeZone;
+ setDateTime(result, toDate, toTime);
+ return result;
+}
+
// Convert a TimeZone time expressed in zone msecs encoding into a UTC epoch msecs
-qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QTimeZone &zone,
- QDate *localDate, QTime *localTime)
+inline qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QTimeZone &zone,
+ QDate *localDate, QTime *localTime)
{
// Get the effective data from QTimeZone
QTimeZonePrivate::Data data = zone.d->dataForLocalTime(zoneMSecs);
@@ -2958,8 +3029,8 @@ qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QTimeZone
\sa isValid()
*/
-QDateTime::QDateTime()
- : d(*defaultDateTimePrivate())
+QDateTime::QDateTime() Q_DECL_NOEXCEPT_EXPR(Data::CanBeSmall)
+ : d(Qt::LocalTime)
{
}
@@ -2970,7 +3041,7 @@ QDateTime::QDateTime()
*/
QDateTime::QDateTime(const QDate &date)
- : d(new QDateTimePrivate(date, QTime(0, 0, 0), Qt::LocalTime, 0))
+ : d(QDateTimePrivate::create(date, QTime(0, 0, 0), Qt::LocalTime, 0))
{
}
@@ -2990,7 +3061,7 @@ QDateTime::QDateTime(const QDate &date)
*/
QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec)
- : d(new QDateTimePrivate(date, time, spec, 0))
+ : d(QDateTimePrivate::create(date, time, spec, 0))
{
}
@@ -3013,7 +3084,7 @@ QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec)
*/
QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec, int offsetSeconds)
- : d(new QDateTimePrivate(date, time, spec, offsetSeconds))
+ : d(QDateTimePrivate::create(date, time, spec, offsetSeconds))
{
}
@@ -3030,7 +3101,7 @@ QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec, in
*/
QDateTime::QDateTime(const QDate &date, const QTime &time, const QTimeZone &timeZone)
- : d(new QDateTimePrivate(date, time, timeZone))
+ : d(QDateTimePrivate::create(date, time, timeZone))
{
}
#endif // QT_BOOTSTRAPPED
@@ -3038,13 +3109,22 @@ QDateTime::QDateTime(const QDate &date, const QTime &time, const QTimeZone &time
/*!
Constructs a copy of the \a other datetime.
*/
-
-QDateTime::QDateTime(const QDateTime &other)
+QDateTime::QDateTime(const QDateTime &other) Q_DECL_NOTHROW
: d(other.d)
{
}
/*!
+ \since 5.8
+ Moves the content of the temporary \a other datetime to this object and
+ leaves \a other in an unspecified (but proper) state.
+*/
+QDateTime::QDateTime(QDateTime &&other) Q_DECL_NOTHROW
+ : d(std::move(other.d))
+{
+}
+
+/*!
Destroys the datetime.
*/
QDateTime::~QDateTime()
@@ -3056,7 +3136,7 @@ QDateTime::~QDateTime()
copy.
*/
-QDateTime &QDateTime::operator=(const QDateTime &other)
+QDateTime &QDateTime::operator=(const QDateTime &other) Q_DECL_NOTHROW
{
d = other.d;
return *this;
@@ -3078,7 +3158,9 @@ QDateTime &QDateTime::operator=(const QDateTime &other)
bool QDateTime::isNull() const
{
- return d->isNullDate() && d->isNullTime();
+ auto status = getStatus(d);
+ return !status.testFlag(QDateTimePrivate::ValidDate) &&
+ !status.testFlag(QDateTimePrivate::ValidTime);
}
/*!
@@ -3095,7 +3177,8 @@ bool QDateTime::isNull() const
bool QDateTime::isValid() const
{
- return (d->isValidDateTime());
+ auto status = getStatus(d);
+ return status & QDateTimePrivate::ValidDateTime;
}
/*!
@@ -3106,10 +3189,11 @@ bool QDateTime::isValid() const
QDate QDateTime::date() const
{
- if (d->isNullDate())
+ auto status = getStatus(d);
+ if (!status.testFlag(QDateTimePrivate::ValidDate))
return QDate();
QDate dt;
- msecsToTime(d->m_msecs, &dt, 0);
+ msecsToTime(getMSecs(d), &dt, 0);
return dt;
}
@@ -3121,10 +3205,11 @@ QDate QDateTime::date() const
QTime QDateTime::time() const
{
- if (d->isNullTime())
+ auto status = getStatus(d);
+ if (!status.testFlag(QDateTimePrivate::ValidTime))
return QTime();
QTime tm;
- msecsToTime(d->m_msecs, 0, &tm);
+ msecsToTime(getMSecs(d), 0, &tm);
return tm;
}
@@ -3136,7 +3221,7 @@ QTime QDateTime::time() const
Qt::TimeSpec QDateTime::timeSpec() const
{
- return d->m_spec;
+ return getSpec(d);
}
#ifndef QT_BOOTSTRAPPED
@@ -3154,7 +3239,7 @@ Qt::TimeSpec QDateTime::timeSpec() const
QTimeZone QDateTime::timeZone() const
{
- switch (d->m_spec) {
+ switch (getSpec(d)) {
case Qt::UTC:
return QTimeZone::utc();
case Qt::OffsetFromUTC:
@@ -3189,7 +3274,20 @@ QTimeZone QDateTime::timeZone() const
int QDateTime::offsetFromUtc() const
{
- return d->m_offsetFromUtc;
+ if (!d.isShort())
+ return d->m_offsetFromUtc;
+ if (!isValid())
+ return 0;
+
+ auto spec = getSpec(d);
+ if (spec == Qt::LocalTime) {
+ // we didn't cache the value, so we need to calculate it now...
+ qint64 msecs = getMSecs(d);
+ return (msecs - toMSecsSinceEpoch()) / 1000;
+ }
+
+ Q_ASSERT(spec == Qt::UTC);
+ return 0;
}
/*!
@@ -3215,7 +3313,7 @@ int QDateTime::offsetFromUtc() const
QString QDateTime::timeZoneAbbreviation() const
{
- switch (d->m_spec) {
+ switch (getSpec(d)) {
case Qt::UTC:
return QTimeZonePrivate::utcQString();
case Qt::OffsetFromUTC:
@@ -3224,12 +3322,12 @@ QString QDateTime::timeZoneAbbreviation() const
#ifdef QT_BOOTSTRAPPED
break;
#else
- return d->m_timeZone.d->abbreviation(d->toMSecsSinceEpoch());
+ return d->m_timeZone.d->abbreviation(toMSecsSinceEpoch());
#endif // QT_BOOTSTRAPPED
case Qt::LocalTime: {
QString abbrev;
- QDateTimePrivate::DaylightStatus status = d->daylightStatus();
- localMSecsToEpochMSecs(d->m_msecs, &status, 0, 0, &abbrev);
+ auto status = extractDaylightStatus(getStatus(d));
+ localMSecsToEpochMSecs(getMSecs(d), &status, 0, 0, &abbrev);
return abbrev;
}
}
@@ -3249,7 +3347,7 @@ QString QDateTime::timeZoneAbbreviation() const
bool QDateTime::isDaylightTime() const
{
- switch (d->m_spec) {
+ switch (getSpec(d)) {
case Qt::UTC:
case Qt::OffsetFromUTC:
return false;
@@ -3260,9 +3358,9 @@ bool QDateTime::isDaylightTime() const
return d->m_timeZone.d->isDaylightTime(toMSecsSinceEpoch());
#endif // QT_BOOTSTRAPPED
case Qt::LocalTime: {
- QDateTimePrivate::DaylightStatus status = d->daylightStatus();
+ auto status = extractDaylightStatus(getStatus(d));
if (status == QDateTimePrivate::UnknownDaylightTime)
- localMSecsToEpochMSecs(d->m_msecs, &status);
+ localMSecsToEpochMSecs(getMSecs(d), &status);
return (status == QDateTimePrivate::DaylightTime);
}
}
@@ -3278,7 +3376,7 @@ bool QDateTime::isDaylightTime() const
void QDateTime::setDate(const QDate &date)
{
- d->setDateTime(date, time());
+ setDateTime(d, date, time());
}
/*!
@@ -3296,7 +3394,7 @@ void QDateTime::setDate(const QDate &date)
void QDateTime::setTime(const QTime &time)
{
- d->setDateTime(date(), time);
+ setDateTime(d, date(), time);
}
/*!
@@ -3317,9 +3415,8 @@ void QDateTime::setTime(const QTime &time)
void QDateTime::setTimeSpec(Qt::TimeSpec spec)
{
- QDateTimePrivate *d = this->d.data(); // detaches (and shadows d)
- d->setTimeSpec(spec, 0);
- d->checkValidDateTime();
+ QT_PREPEND_NAMESPACE(setTimeSpec(d, spec, 0));
+ checkValidDateTime(d);
}
/*!
@@ -3339,9 +3436,8 @@ void QDateTime::setTimeSpec(Qt::TimeSpec spec)
void QDateTime::setOffsetFromUtc(int offsetSeconds)
{
- QDateTimePrivate *d = this->d.data(); // detaches (and shadows d)
- d->setTimeSpec(Qt::OffsetFromUTC, offsetSeconds);
- d->checkValidDateTime();
+ QT_PREPEND_NAMESPACE(setTimeSpec(d, Qt::OffsetFromUTC, offsetSeconds));
+ checkValidDateTime(d);
}
#ifndef QT_BOOTSTRAPPED
@@ -3358,11 +3454,11 @@ void QDateTime::setOffsetFromUtc(int offsetSeconds)
void QDateTime::setTimeZone(const QTimeZone &toZone)
{
- QDateTimePrivate *d = this->d.data(); // detaches (and shadows d)
- d->m_spec = Qt::TimeZone;
+ d.detach(); // always detach
+ d->m_status = mergeSpec(d->m_status, Qt::TimeZone);
d->m_offsetFromUtc = 0;
d->m_timeZone = toZone;
- d->refreshDateTime();
+ refreshDateTime(d);
}
#endif // QT_BOOTSTRAPPED
@@ -3383,7 +3479,28 @@ void QDateTime::setTimeZone(const QTimeZone &toZone)
*/
qint64 QDateTime::toMSecsSinceEpoch() const
{
- return d->toMSecsSinceEpoch();
+ switch (getSpec(d)) {
+ case Qt::UTC:
+ return getMSecs(d);
+
+ case Qt::OffsetFromUTC:
+ return d->m_msecs - (d->m_offsetFromUtc * 1000);
+
+ case Qt::LocalTime: {
+ // recalculate the local timezone
+ auto status = extractDaylightStatus(getStatus(d));
+ return localMSecsToEpochMSecs(getMSecs(d), &status);
+ }
+
+ case Qt::TimeZone:
+#ifdef QT_BOOTSTRAPPED
+ break;
+#else
+ return QDateTimePrivate::zoneMSecsToEpochMSecs(d->m_msecs, d->m_timeZone);
+#endif
+ }
+ Q_UNREACHABLE();
+ return 0;
}
/*!
@@ -3412,7 +3529,7 @@ uint QDateTime::toTime_t() const
{
if (!isValid())
return uint(-1);
- qint64 retval = d->toMSecsSinceEpoch() / 1000;
+ qint64 retval = toMSecsSinceEpoch() / 1000;
if (quint64(retval) >= Q_UINT64_C(0xFFFFFFFF))
return uint(-1);
return uint(retval);
@@ -3434,51 +3551,67 @@ uint QDateTime::toTime_t() const
*/
void QDateTime::setMSecsSinceEpoch(qint64 msecs)
{
- QDateTimePrivate *d = this->d.data(); // detaches (and shadows d)
+ const auto spec = getSpec(d);
+ auto status = getStatus(d);
- d->m_status = 0;
- switch (d->m_spec) {
+ status &= ~QDateTimePrivate::ValidityMask;
+ switch (spec) {
case Qt::UTC:
- d->m_msecs = msecs;
- d->m_status = d->m_status
+ status = status
| QDateTimePrivate::ValidDate
| QDateTimePrivate::ValidTime
| QDateTimePrivate::ValidDateTime;
break;
case Qt::OffsetFromUTC:
- d->m_msecs = msecs + (d->m_offsetFromUtc * 1000);
- d->m_status = d->m_status
+ msecs = msecs + (d->m_offsetFromUtc * 1000);
+ status = status
| QDateTimePrivate::ValidDate
| QDateTimePrivate::ValidTime
| QDateTimePrivate::ValidDateTime;
break;
case Qt::TimeZone:
+ Q_ASSERT(!d.isShort());
#ifndef QT_BOOTSTRAPPED
// Docs state any LocalTime before 1970-01-01 will *not* have any DST applied
// but all affected times afterwards will have DST applied.
+ d.detach();
if (msecs >= 0)
d->m_offsetFromUtc = d->m_timeZone.d->offsetFromUtc(msecs);
else
d->m_offsetFromUtc = d->m_timeZone.d->standardTimeOffset(msecs);
- d->m_msecs = msecs + (d->m_offsetFromUtc * 1000);
- d->m_status = d->m_status
+ msecs = msecs + (d->m_offsetFromUtc * 1000);
+ status = status
| QDateTimePrivate::ValidDate
| QDateTimePrivate::ValidTime
| QDateTimePrivate::ValidDateTime;
- d->refreshDateTime();
#endif // QT_BOOTSTRAPPED
break;
case Qt::LocalTime: {
QDate dt;
QTime tm;
- QDateTimePrivate::DaylightStatus status;
- epochMSecsToLocalTime(msecs, &dt, &tm, &status);
- d->setDateTime(dt, tm);
- d->setDaylightStatus(status);
- d->refreshDateTime();
+ QDateTimePrivate::DaylightStatus dstStatus;
+ epochMSecsToLocalTime(msecs, &dt, &tm, &dstStatus);
+ setDateTime(d, dt, tm);
+ msecs = getMSecs(d);
+ status = mergeDaylightStatus(getStatus(d), dstStatus);
break;
}
}
+
+ ShortData sd;
+ sd.msecs = msecs;
+ if (d.isShort() && sd.msecs == msecs) {
+ // we can keep short
+ sd.status = status;
+ d.data = sd;
+ } else {
+ d.detach();
+ d->m_status = status;
+ d->m_msecs = msecs;
+ }
+
+ if (spec == Qt::LocalTime || spec == Qt::TimeZone)
+ refreshDateTime(d);
}
/*!
@@ -3565,13 +3698,13 @@ QString QDateTime::toString(Qt::DateFormat format) const
return QLocale().toString(*this, QLocale::LongFormat);
case Qt::RFC2822Date: {
buf = QLocale::c().toString(*this, QStringLiteral("dd MMM yyyy hh:mm:ss "));
- buf += toOffsetString(Qt::TextDate, d->m_offsetFromUtc);
+ buf += toOffsetString(Qt::TextDate, offsetFromUtc());
return buf;
}
default:
#ifndef QT_NO_TEXTDATE
case Qt::TextDate: {
- const QPair<QDate, QTime> p = d->getDateTime();
+ const QPair<QDate, QTime> p = getDateTime(d);
const QDate &dt = p.first;
const QTime &tm = p.second;
//We cant use date.toString(Qt::TextDate) as we need to insert the time before the year
@@ -3582,14 +3715,14 @@ QString QDateTime::toString(Qt::DateFormat format) const
.arg(dt.year());
if (timeSpec() != Qt::LocalTime) {
buf += QStringLiteral(" GMT");
- if (d->m_spec == Qt::OffsetFromUTC)
- buf += toOffsetString(Qt::TextDate, d->m_offsetFromUtc);
+ if (getSpec(d) == Qt::OffsetFromUTC)
+ buf += toOffsetString(Qt::TextDate, offsetFromUtc());
}
return buf;
}
#endif
case Qt::ISODate: {
- const QPair<QDate, QTime> p = d->getDateTime();
+ const QPair<QDate, QTime> p = getDateTime(d);
const QDate &dt = p.first;
const QTime &tm = p.second;
buf = dt.toString(Qt::ISODate);
@@ -3597,12 +3730,12 @@ QString QDateTime::toString(Qt::DateFormat format) const
return QString(); // failed to convert
buf += QLatin1Char('T');
buf += tm.toString(Qt::ISODate);
- switch (d->m_spec) {
+ switch (getSpec(d)) {
case Qt::UTC:
buf += QLatin1Char('Z');
break;
case Qt::OffsetFromUTC:
- buf += toOffsetString(Qt::ISODate, d->m_offsetFromUtc);
+ buf += toOffsetString(Qt::ISODate, offsetFromUtc());
break;
default:
break;
@@ -3691,12 +3824,7 @@ QString QDateTime::toString(const QString& format) const
}
#endif //QT_NO_DATESTRING
-static void massageAdjustedDateTime(Qt::TimeSpec spec,
-#ifndef QT_BOOTSTRAPPED
- const QTimeZone &zone,
-#endif // QT_BOOTSTRAPPED
- QDate *date,
- QTime *time)
+static inline void massageAdjustedDateTime(const QDateTimeData &d, QDate *date, QTime *time)
{
/*
If we have just adjusted to a day with a DST transition, our given time
@@ -3706,24 +3834,20 @@ static void massageAdjustedDateTime(Qt::TimeSpec spec,
to its DST-ness); but for a time in spring's missing hour it'll adjust the
time while picking a DST-ness. (Handling of autumn is trickier, as either
DST-ness is valid, without adjusting the time. We might want to propagate
- d->daylightStatus() in that case, but it's hard to do so without breaking
+ the daylight status in that case, but it's hard to do so without breaking
(far more common) other cases; and it makes little difference, as the two
answers do then differ only in DST-ness.)
*/
+ auto spec = getSpec(d);
if (spec == Qt::LocalTime) {
QDateTimePrivate::DaylightStatus status = QDateTimePrivate::UnknownDaylightTime;
localMSecsToEpochMSecs(timeToMSecs(*date, *time), &status, date, time);
#ifndef QT_BOOTSTRAPPED
} else if (spec == Qt::TimeZone) {
- QDateTimePrivate::zoneMSecsToEpochMSecs(timeToMSecs(*date, *time), zone, date, time);
+ QDateTimePrivate::zoneMSecsToEpochMSecs(timeToMSecs(*date, *time), d->m_timeZone, date, time);
#endif // QT_BOOTSTRAPPED
}
}
-#ifdef QT_BOOTSTRAPPED // Avoid duplicate #if-ery in uses.
-#define MASSAGEADJUSTEDDATETIME(s, z, d, t) massageAdjustedDateTime(s, d, t)
-#else
-#define MASSAGEADJUSTEDDATETIME(s, z, d, t) massageAdjustedDateTime(s, z, d, t)
-#endif // QT_BOOTSTRAPPED
/*!
Returns a QDateTime object containing a datetime \a ndays days
@@ -3742,12 +3866,12 @@ static void massageAdjustedDateTime(Qt::TimeSpec spec,
QDateTime QDateTime::addDays(qint64 ndays) const
{
QDateTime dt(*this);
- QPair<QDate, QTime> p = d->getDateTime();
+ QPair<QDate, QTime> p = getDateTime(d);
QDate &date = p.first;
QTime &time = p.second;
date = date.addDays(ndays);
- MASSAGEADJUSTEDDATETIME(d->m_spec, d->m_timeZone, &date, &time);
- dt.d->setDateTime(date, time);
+ massageAdjustedDateTime(dt.d, &date, &time);
+ setDateTime(dt.d, date, time);
return dt;
}
@@ -3768,12 +3892,12 @@ QDateTime QDateTime::addDays(qint64 ndays) const
QDateTime QDateTime::addMonths(int nmonths) const
{
QDateTime dt(*this);
- QPair<QDate, QTime> p = d->getDateTime();
+ QPair<QDate, QTime> p = getDateTime(d);
QDate &date = p.first;
QTime &time = p.second;
date = date.addMonths(nmonths);
- MASSAGEADJUSTEDDATETIME(d->m_spec, d->m_timeZone, &date, &time);
- dt.d->setDateTime(date, time);
+ massageAdjustedDateTime(dt.d, &date, &time);
+ setDateTime(dt.d, date, time);
return dt;
}
@@ -3794,15 +3918,14 @@ QDateTime QDateTime::addMonths(int nmonths) const
QDateTime QDateTime::addYears(int nyears) const
{
QDateTime dt(*this);
- QPair<QDate, QTime> p = d->getDateTime();
+ QPair<QDate, QTime> p = getDateTime(d);
QDate &date = p.first;
QTime &time = p.second;
date = date.addYears(nyears);
- MASSAGEADJUSTEDDATETIME(d->m_spec, d->m_timeZone, &date, &time);
- dt.d->setDateTime(date, time);
+ massageAdjustedDateTime(dt.d, &date, &time);
+ setDateTime(dt.d, date, time);
return dt;
}
-#undef MASSAGEADJUSTEDDATETIME
/*!
Returns a QDateTime object containing a datetime \a s seconds
@@ -3834,12 +3957,25 @@ QDateTime QDateTime::addMSecs(qint64 msecs) const
return QDateTime();
QDateTime dt(*this);
- if (d->m_spec == Qt::LocalTime || d->m_spec == Qt::TimeZone)
+ auto spec = getSpec(d);
+ if (spec == Qt::LocalTime || spec == Qt::TimeZone) {
// Convert to real UTC first in case crosses DST transition
- dt.setMSecsSinceEpoch(d->toMSecsSinceEpoch() + msecs);
- else
+ dt.setMSecsSinceEpoch(toMSecsSinceEpoch() + msecs);
+ } else {
// No need to convert, just add on
- dt.d->m_msecs = dt.d->m_msecs + msecs;
+ if (d.isShort()) {
+ // need to check if we need to enlarge first
+ msecs += dt.d.data.msecs;
+ dt.d.data.msecs = qintptr(msecs);
+ if (dt.d.data.msecs != msecs) {
+ dt.d.detach();
+ dt.d->m_msecs = msecs;
+ }
+ } else {
+ dt.d.detach();
+ dt.d->m_msecs += msecs;
+ }
+ }
return dt;
}
@@ -3905,7 +4041,7 @@ qint64 QDateTime::msecsTo(const QDateTime &other) const
if (!isValid() || !other.isValid())
return 0;
- return other.d->toMSecsSinceEpoch() - d->toMSecsSinceEpoch();
+ return other.toMSecsSinceEpoch() - toMSecsSinceEpoch();
}
/*!
@@ -3928,7 +4064,7 @@ qint64 QDateTime::msecsTo(const QDateTime &other) const
QDateTime QDateTime::toTimeSpec(Qt::TimeSpec spec) const
{
- if (d->m_spec == spec && (spec == Qt::UTC || spec == Qt::LocalTime))
+ if (getSpec(d) == spec && (spec == Qt::UTC || spec == Qt::LocalTime))
return *this;
if (!isValid()) {
@@ -3937,7 +4073,7 @@ QDateTime QDateTime::toTimeSpec(Qt::TimeSpec spec) const
return ret;
}
- return fromMSecsSinceEpoch(d->toMSecsSinceEpoch(), spec, 0);
+ return fromMSecsSinceEpoch(toMSecsSinceEpoch(), spec, 0);
}
/*!
@@ -3955,7 +4091,8 @@ QDateTime QDateTime::toTimeSpec(Qt::TimeSpec spec) const
QDateTime QDateTime::toOffsetFromUtc(int offsetSeconds) const
{
- if (d->m_spec == Qt::OffsetFromUTC && d->m_offsetFromUtc == offsetSeconds)
+ if (getSpec(d) == Qt::OffsetFromUTC
+ && d->m_offsetFromUtc == offsetSeconds)
return *this;
if (!isValid()) {
@@ -3964,7 +4101,7 @@ QDateTime QDateTime::toOffsetFromUtc(int offsetSeconds) const
return ret;
}
- return fromMSecsSinceEpoch(d->toMSecsSinceEpoch(), Qt::OffsetFromUTC, offsetSeconds);
+ return fromMSecsSinceEpoch(toMSecsSinceEpoch(), Qt::OffsetFromUTC, offsetSeconds);
}
#ifndef QT_BOOTSTRAPPED
@@ -3978,7 +4115,7 @@ QDateTime QDateTime::toOffsetFromUtc(int offsetSeconds) const
QDateTime QDateTime::toTimeZone(const QTimeZone &timeZone) const
{
- if (d->m_spec == Qt::TimeZone && d->m_timeZone == timeZone)
+ if (getSpec(d) == Qt::TimeZone && d->m_timeZone == timeZone)
return *this;
if (!isValid()) {
@@ -3987,7 +4124,7 @@ QDateTime QDateTime::toTimeZone(const QTimeZone &timeZone) const
return ret;
}
- return fromMSecsSinceEpoch(d->toMSecsSinceEpoch(), timeZone);
+ return fromMSecsSinceEpoch(toMSecsSinceEpoch(), timeZone);
}
#endif // QT_BOOTSTRAPPED
@@ -4000,10 +4137,9 @@ QDateTime QDateTime::toTimeZone(const QTimeZone &timeZone) const
bool QDateTime::operator==(const QDateTime &other) const
{
- if (d->m_spec == Qt::LocalTime
- && other.d->m_spec == Qt::LocalTime
- && d->m_status == other.d->m_status) {
- return (d->m_msecs == other.d->m_msecs);
+ if (getSpec(d) == Qt::LocalTime
+ && getStatus(d) == getStatus(other.d)) {
+ return getMSecs(d) == getMSecs(other.d);
}
// Convert to UTC and compare
return (toMSecsSinceEpoch() == other.toMSecsSinceEpoch());
@@ -4028,10 +4164,9 @@ bool QDateTime::operator==(const QDateTime &other) const
bool QDateTime::operator<(const QDateTime &other) const
{
- if (d->m_spec == Qt::LocalTime
- && other.d->m_spec == Qt::LocalTime
- && d->m_status == other.d->m_status) {
- return (d->m_msecs < other.d->m_msecs);
+ if (getSpec(d) == Qt::LocalTime
+ && getStatus(d) == getStatus(other.d)) {
+ return getMSecs(d) < getMSecs(other.d);
}
// Convert to UTC and compare
return (toMSecsSinceEpoch() < other.toMSecsSinceEpoch());
@@ -4109,9 +4244,6 @@ QTime QTime::currentTime()
memset(&st, 0, sizeof(SYSTEMTIME));
GetLocalTime(&st);
ct.setHMS(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
-#if defined(Q_OS_WINCE)
- ct.startTick = GetTickCount() % MSECS_PER_DAY;
-#endif
return ct;
}
@@ -4186,39 +4318,6 @@ qint64 QDateTime::currentMSecsSinceEpoch() Q_DECL_NOTHROW
#error "What system is this?"
#endif
-/*! \fn QDateTime QDateTime::fromCFDate(CFDateRef date)
- \since 5.5
-
- Constructs a new QDateTime containing a copy of the CFDate \a date.
-
- \sa toCFDate()
-*/
-
-/*! \fn CFDateRef QDateTime::toCFDate() const
- \since 5.5
-
- Creates a CFDate from a QDateTime. The caller owns the CFDate object
- and is responsible for releasing it.
-
- \sa fromCFDate()
-*/
-
-/*! \fn QDateTime QDateTime::fromNSDate(const NSDate *date)
- \since 5.5
-
- Constructs a new QDateTime containing a copy of the NSDate \a date.
-
- \sa toNSDate()
-*/
-
-/*! \fn NSDate QDateTime::toNSDate() const
- \since 5.5
-
- Creates an NSDate from a QDateTime. The NSDate object is autoreleased.
-
- \sa fromNSDate()
-*/
-
/*!
\since 4.2
@@ -4310,7 +4409,7 @@ QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs)
QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs, Qt::TimeSpec spec, int offsetSeconds)
{
QDateTime dt;
- dt.d->setTimeSpec(spec, offsetSeconds);
+ QT_PREPEND_NAMESPACE(setTimeSpec(dt.d, spec, offsetSeconds));
dt.setMSecsSinceEpoch(msecs);
return dt;
}
@@ -4817,7 +4916,7 @@ QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime)
if (out.version() >= QDataStream::Qt_5_2) {
// In 5.2 we switched to using Qt::TimeSpec and added offset support
- dateAndTime = dateTime.d->getDateTime();
+ dateAndTime = getDateTime(dateTime.d);
out << dateAndTime << qint8(dateTime.timeSpec());
if (dateTime.timeSpec() == Qt::OffsetFromUTC)
out << qint32(dateTime.offsetFromUtc());
@@ -4832,13 +4931,13 @@ QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime)
// This approach is wrong and should not be used again; it breaks
// the guarantee that a deserialised local datetime is the same time
// of day, regardless of which timezone it was serialised in.
- dateAndTime = (dateTime.isValid() ? dateTime.toUTC() : dateTime).d->getDateTime();
+ dateAndTime = getDateTime((dateTime.isValid() ? dateTime.toUTC() : dateTime).d);
out << dateAndTime << qint8(dateTime.timeSpec());
} else if (out.version() >= QDataStream::Qt_4_0) {
// From 4.0 to 5.1 (except 5.0) we used QDateTimePrivate::Spec
- dateAndTime = dateTime.d->getDateTime();
+ dateAndTime = getDateTime(dateTime.d);
out << dateAndTime;
switch (dateTime.timeSpec()) {
case Qt::UTC:
@@ -4858,7 +4957,7 @@ QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime)
} else { // version < QDataStream::Qt_4_0
// Before 4.0 there was no TimeSpec, only Qt::LocalTime was supported
- dateAndTime = dateTime.d->getDateTime();
+ dateAndTime = getDateTime(dateTime.d);
out << dateAndTime;
}
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index ee3be5553b..0af13dd45f 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -46,11 +47,9 @@
#include <limits>
-#ifdef Q_OS_MAC
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_FORWARD_DECLARE_CF_TYPE(CFDate);
-# ifdef __OBJC__
Q_FORWARD_DECLARE_OBJC_CLASS(NSDate);
-# endif
#endif
QT_BEGIN_NAMESPACE
@@ -148,15 +147,9 @@ Q_DECLARE_TYPEINFO(QDate, Q_MOVABLE_TYPE);
class Q_CORE_EXPORT QTime
{
explicit Q_DECL_CONSTEXPR QTime(int ms) : mds(ms)
-#if defined(Q_OS_WINCE)
- , startTick(NullTime)
-#endif
{}
public:
Q_DECL_CONSTEXPR QTime(): mds(NullTime)
-#if defined(Q_OS_WINCE)
- , startTick(NullTime)
-#endif
{}
QTime(int h, int m, int s = 0, int ms = 0);
@@ -202,9 +195,6 @@ private:
enum TimeFlag { NullTime = -1 };
Q_DECL_CONSTEXPR inline int ds() const { return mds == -1 ? 0 : mds; }
int mds;
-#if defined(Q_OS_WINCE)
- int startTick;
-#endif
friend class QDateTime;
friend class QDateTimePrivate;
@@ -219,8 +209,45 @@ class QDateTimePrivate;
class Q_CORE_EXPORT QDateTime
{
+ // ### Qt 6: revisit the optimization
+ struct ShortData {
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ quintptr status : 8;
+#endif
+ // note: this is only 24 bits on 32-bit systems...
+ qintptr msecs : sizeof(void *) * 8 - 8;
+
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ quintptr status : 8;
+#endif
+ };
+
+ union Data {
+ enum {
+ // To be of any use, we need at least 60 years around 1970, which
+ // is 1,893,456,000,000 ms. That requires 41 bits to store, plus
+ // the sign bit. With the status byte, the minimum size is 50 bits.
+ CanBeSmall = sizeof(ShortData) * 8 > 50
+ };
+
+ Data(Qt::TimeSpec);
+ Data(const Data &other);
+ Data(Data &&other);
+ Data &operator=(const Data &other);
+ ~Data();
+
+ bool isShort() const;
+ void detach();
+
+ const QDateTimePrivate *operator->() const;
+ QDateTimePrivate *operator->();
+
+ QDateTimePrivate *d;
+ ShortData data;
+ };
+
public:
- QDateTime();
+ QDateTime() Q_DECL_NOEXCEPT_EXPR(Data::CanBeSmall);
explicit QDateTime(const QDate &);
QDateTime(const QDate &, const QTime &, Qt::TimeSpec spec = Qt::LocalTime);
// ### Qt 6: Merge with above with default offsetSeconds = 0
@@ -228,15 +255,16 @@ public:
#ifndef QT_BOOTSTRAPPED
QDateTime(const QDate &date, const QTime &time, const QTimeZone &timeZone);
#endif // QT_BOOTSTRAPPED
- QDateTime(const QDateTime &other);
+ QDateTime(const QDateTime &other) Q_DECL_NOTHROW;
+ QDateTime(QDateTime &&other) Q_DECL_NOTHROW;
~QDateTime();
#ifdef Q_COMPILER_RVALUE_REFS
QDateTime &operator=(QDateTime &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
- QDateTime &operator=(const QDateTime &other);
+ QDateTime &operator=(const QDateTime &other) Q_DECL_NOTHROW;
- void swap(QDateTime &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
+ void swap(QDateTime &other) Q_DECL_NOTHROW { qSwap(d.d, other.d.d); }
bool isNull() const;
bool isValid() const;
@@ -322,22 +350,17 @@ public:
#endif
static qint64 currentMSecsSinceEpoch() Q_DECL_NOTHROW;
-#if defined(Q_OS_MAC) || defined(Q_QDOC)
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
static QDateTime fromCFDate(CFDateRef date);
CFDateRef toCFDate() const Q_DECL_CF_RETURNS_RETAINED;
-# if defined(__OBJC__) || defined(Q_QDOC)
static QDateTime fromNSDate(const NSDate *date);
NSDate *toNSDate() const Q_DECL_NS_RETURNS_AUTORELEASED;
-# endif
#endif
private:
friend class QDateTimePrivate;
- // ### Qt6: Using a private here has high impact on runtime
- // on users such as QFileInfo. In Qt 6, the data members
- // should be inlined.
- QSharedDataPointer<QDateTimePrivate> d;
+ Data d;
#ifndef QT_NO_DATASTREAM
friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QDateTime &);
diff --git a/src/corelib/tools/qdatetime_mac.mm b/src/corelib/tools/qdatetime_mac.mm
deleted file mode 100644
index d61ea28636..0000000000
--- a/src/corelib/tools/qdatetime_mac.mm
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2014 Petroules Corporation.
-** 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 "qdatetime.h"
-
-#import <Foundation/Foundation.h>
-
-QT_BEGIN_NAMESPACE
-
-QDateTime QDateTime::fromCFDate(CFDateRef date)
-{
- if (!date)
- return QDateTime();
- return QDateTime::fromMSecsSinceEpoch(static_cast<qint64>((CFDateGetAbsoluteTime(date)
- + kCFAbsoluteTimeIntervalSince1970) * 1000));
-}
-
-CFDateRef QDateTime::toCFDate() const
-{
- return CFDateCreate(kCFAllocatorDefault, (static_cast<CFAbsoluteTime>(toMSecsSinceEpoch())
- / 1000) - kCFAbsoluteTimeIntervalSince1970);
-}
-
-QDateTime QDateTime::fromNSDate(const NSDate *date)
-{
- if (!date)
- return QDateTime();
- return QDateTime::fromMSecsSinceEpoch(static_cast<qint64>([date timeIntervalSince1970] * 1000));
-}
-
-NSDate *QDateTime::toNSDate() const
-{
- return [NSDate
- dateWithTimeIntervalSince1970:static_cast<NSTimeInterval>(toMSecsSinceEpoch()) / 1000];
-}
-
-QT_END_NAMESPACE
diff --git a/src/corelib/tools/qdatetime_p.h b/src/corelib/tools/qdatetime_p.h
index 104cbccbd4..c4d00c99f9 100644
--- a/src/corelib/tools/qdatetime_p.h
+++ b/src/corelib/tools/qdatetime_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -60,9 +61,13 @@
QT_BEGIN_NAMESPACE
-class QDateTimePrivate : public QSharedData
+class QDateTimePrivate
{
public:
+ // forward the declarations from QDateTime (this makes them public)
+ typedef QDateTime::ShortData QDateTimeShortData;
+ typedef QDateTime::Data QDateTimeData;
+
// Never change or delete this enum, it is required for backwards compatible
// serialization of QDateTime before 5.2, so is essentially public API
enum Spec {
@@ -76,7 +81,6 @@ public:
// Daylight Time Status
enum DaylightStatus {
- NoDaylightTime = -2,
UnknownDaylightTime = -1,
StandardTime = 0,
DaylightTime = 1
@@ -84,62 +88,46 @@ public:
// Status of date/time
enum StatusFlag {
- NullDate = 0x01,
- NullTime = 0x02,
- ValidDate = 0x04, // just the date field
- ValidTime = 0x08, // just the time field
- ValidDateTime = 0x10, // the whole object (including timezone)
+ ShortData = 0x01,
+
+ ValidDate = 0x02,
+ ValidTime = 0x04,
+ ValidDateTime = 0x08,
+
+ TimeSpecMask = 0x30,
+
SetToStandardTime = 0x40,
SetToDaylightTime = 0x80
};
Q_DECLARE_FLAGS(StatusFlags, StatusFlag)
+ enum {
+ TimeSpecShift = 4,
+ ValidityMask = ValidDate | ValidTime | ValidDateTime,
+ DaylightMask = SetToStandardTime | SetToDaylightTime
+ };
+
QDateTimePrivate() : m_msecs(0),
- m_spec(Qt::LocalTime),
+ m_status(StatusFlag(Qt::LocalTime << TimeSpecShift)),
m_offsetFromUtc(0),
- m_status(NullDate | NullTime)
- {}
+ ref(0)
+ {
+ }
- QDateTimePrivate(const QDate &toDate, const QTime &toTime, Qt::TimeSpec toSpec,
- int offsetSeconds);
+ static QDateTime::Data create(const QDate &toDate, const QTime &toTime, Qt::TimeSpec toSpec,
+ int offsetSeconds);
#ifndef QT_BOOTSTRAPPED
- QDateTimePrivate(const QDate &toDate, const QTime &toTime, const QTimeZone & timeZone);
+ static QDateTime::Data create(const QDate &toDate, const QTime &toTime, const QTimeZone & timeZone);
#endif // QT_BOOTSTRAPPED
- // ### XXX: when the tooling situation improves, look at fixing the padding.
- // 4 bytes padding
-
qint64 m_msecs;
- Qt::TimeSpec m_spec;
+ StatusFlags m_status;
int m_offsetFromUtc;
+ mutable QAtomicInt ref;
#ifndef QT_BOOTSTRAPPED
QTimeZone m_timeZone;
#endif // QT_BOOTSTRAPPED
- StatusFlags m_status;
-
- void setTimeSpec(Qt::TimeSpec spec, int offsetSeconds);
- void setDateTime(const QDate &date, const QTime &time);
- QPair<QDate, QTime> getDateTime() const;
-
- void setDaylightStatus(DaylightStatus status);
- DaylightStatus daylightStatus() const;
-
- // Returns msecs since epoch, assumes offset value is current
- inline qint64 toMSecsSinceEpoch() const;
-
- void checkValidDateTime();
- void refreshDateTime();
-
- // Get/set date and time status
- inline bool isNullDate() const { return m_status & NullDate; }
- inline bool isNullTime() const { return m_status & NullTime; }
- inline bool isValidDate() const { return m_status & ValidDate; }
- inline bool isValidTime() const { return m_status & ValidTime; }
- inline bool isValidDateTime() const { return m_status & ValidDateTime; }
- inline void setValidDateTime() { m_status |= ValidDateTime; }
- inline void clearValidDateTime() { m_status &= ~ValidDateTime; }
- inline void clearSetToDaylightStatus() { m_status &= ~(SetToStandardTime | SetToDaylightTime); }
#ifndef QT_BOOTSTRAPPED
static qint64 zoneMSecsToEpochMSecs(qint64 msecs, const QTimeZone &zone,
diff --git a/src/corelib/tools/qelapsedtimer_win.cpp b/src/corelib/tools/qelapsedtimer_win.cpp
index 734aaf80f2..520126d262 100644
--- a/src/corelib/tools/qelapsedtimer_win.cpp
+++ b/src/corelib/tools/qelapsedtimer_win.cpp
@@ -40,35 +40,21 @@
#include "qelapsedtimer.h"
#include <qt_windows.h>
-typedef ULONGLONG (WINAPI *PtrGetTickCount64)(void);
-#if defined(Q_OS_WINRT)
- static const PtrGetTickCount64 ptrGetTickCount64 = &GetTickCount64;
-#else
- static PtrGetTickCount64 ptrGetTickCount64 = 0;
-#endif
-
QT_BEGIN_NAMESPACE
// Result of QueryPerformanceFrequency, 0 indicates that the high resolution timer is unavailable
static quint64 counterFrequency = 0;
-static void resolveLibs()
+static void resolveCounterFrequency()
{
static bool done = false;
if (done)
return;
-#if !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE)
- // try to get GetTickCount64 from the system
- HMODULE kernel32 = GetModuleHandleW(L"kernel32");
- if (!kernel32)
- return;
- ptrGetTickCount64 = (PtrGetTickCount64)GetProcAddress(kernel32, "GetTickCount64");
-#endif // !Q_OS_WINRT && !Q_OS_WINCE
-
// Retrieve the number of high-resolution performance counter ticks per second
LARGE_INTEGER frequency;
if (!QueryPerformanceFrequency(&frequency)) {
+ qFatal("QueryPerformanceFrequency failed, even though Microsoft documentation promises it wouldn't.");
counterFrequency = 0;
} else {
counterFrequency = frequency.QuadPart;
@@ -92,35 +78,20 @@ static inline qint64 ticksToNanoseconds(qint64 ticks)
static quint64 getTickCount()
{
- resolveLibs();
+ resolveCounterFrequency();
// This avoids a division by zero and disables the high performance counter if it's not available
if (counterFrequency > 0) {
LARGE_INTEGER counter;
- if (QueryPerformanceCounter(&counter)) {
- return counter.QuadPart;
- } else {
- qWarning("QueryPerformanceCounter failed, although QueryPerformanceFrequency succeeded.");
- return 0;
- }
+ bool ok = QueryPerformanceCounter(&counter);
+ Q_ASSERT_X(ok, "QElapsedTimer::start()",
+ "QueryPerformanceCounter failed, although QueryPerformanceFrequency succeeded.");
+ Q_UNUSED(ok);
+ return counter.QuadPart;
}
-#ifndef Q_OS_WINRT
- if (ptrGetTickCount64)
- return ptrGetTickCount64();
-
- static quint32 highdword = 0;
- static quint32 lastval = 0;
- quint32 val = GetTickCount();
- if (val < lastval)
- ++highdword;
- lastval = val;
- return val | (quint64(highdword) << 32);
-#else // !Q_OS_WINRT
- // ptrGetTickCount64 is always set on WinRT but GetTickCount is not available
- return ptrGetTickCount64();
-#endif // Q_OS_WINRT
+ return GetTickCount64();
}
quint64 qt_msectime()
@@ -130,7 +101,7 @@ quint64 qt_msectime()
QElapsedTimer::ClockType QElapsedTimer::clockType() Q_DECL_NOTHROW
{
- resolveLibs();
+ resolveCounterFrequency();
if (counterFrequency > 0)
return PerformanceCounter;
diff --git a/src/corelib/tools/qline.cpp b/src/corelib/tools/qline.cpp
index b004f74be9..8942292a3d 100644
--- a/src/corelib/tools/qline.cpp
+++ b/src/corelib/tools/qline.cpp
@@ -214,6 +214,14 @@ QT_BEGIN_NAMESPACE
Returns this line translated the distance specified by \a dx and \a dy.
*/
+/*!
+ \fn QPoint QLine::center() const
+
+ \since 5.8
+
+ Returns the center point of this line. This is equivalent to
+ (p1() + p2()) / 2, except it will never overflow.
+*/
/*!
\fn void QLine::setP1(const QPoint &p1)
@@ -351,6 +359,12 @@ QDataStream &operator>>(QDataStream &stream, QLine &line)
translate() function, and can be traversed using the pointAt()
function.
+ \section1 Constraints
+
+ QLine is limited to the minimum and maximum values for the
+ \c int type. Operations on a QLine that could potentially result
+ in values outside this range will result in undefined behavior.
+
\sa QLine, QPolygonF, QRectF
*/
@@ -711,6 +725,15 @@ QLineF::IntersectType QLineF::intersect(const QLineF &l, QPointF *intersectionPo
*/
/*!
+ \fn QPointF QLineF::center() const
+
+ \since 5.8
+
+ Returns the center point of this line. This is equivalent to
+ 0.5 * p1() + 0.5 * p2().
+*/
+
+/*!
\fn void QLineF::setP1(const QPointF &p1)
\since 4.4
diff --git a/src/corelib/tools/qline.h b/src/corelib/tools/qline.h
index 819dd3fd3b..5b5ca3b4c8 100644
--- a/src/corelib/tools/qline.h
+++ b/src/corelib/tools/qline.h
@@ -76,6 +76,8 @@ public:
Q_DECL_CONSTEXPR inline QLine translated(const QPoint &p) const Q_REQUIRED_RESULT;
Q_DECL_CONSTEXPR inline QLine translated(int dx, int dy) const Q_REQUIRED_RESULT;
+ Q_DECL_CONSTEXPR inline QPoint center() const Q_REQUIRED_RESULT;
+
inline void setP1(const QPoint &p1);
inline void setP2(const QPoint &p2);
inline void setPoints(const QPoint &p1, const QPoint &p2);
@@ -165,6 +167,11 @@ Q_DECL_CONSTEXPR inline QLine QLine::translated(int adx, int ady) const
return translated(QPoint(adx, ady));
}
+Q_DECL_CONSTEXPR inline QPoint QLine::center() const
+{
+ return QPoint(int((qint64(pt1.x()) + pt2.x()) / 2), int((qint64(pt1.y()) + pt2.y()) / 2));
+}
+
inline void QLine::setP1(const QPoint &aP1)
{
pt1 = aP1;
@@ -253,6 +260,8 @@ public:
Q_DECL_CONSTEXPR inline QLineF translated(const QPointF &p) const Q_REQUIRED_RESULT;
Q_DECL_CONSTEXPR inline QLineF translated(qreal dx, qreal dy) const Q_REQUIRED_RESULT;
+ Q_DECL_CONSTEXPR inline QPointF center() const Q_REQUIRED_RESULT;
+
inline void setP1(const QPointF &p1);
inline void setP2(const QPointF &p2);
inline void setPoints(const QPointF &p1, const QPointF &p2);
@@ -357,6 +366,11 @@ Q_DECL_CONSTEXPR inline QLineF QLineF::translated(qreal adx, qreal ady) const
return translated(QPointF(adx, ady));
}
+Q_DECL_CONSTEXPR inline QPointF QLineF::center() const
+{
+ return QPointF(0.5 * pt1.x() + 0.5 * pt2.x(), 0.5 * pt1.y() + 0.5 * pt2.y());
+}
+
inline void QLineF::setLength(qreal len)
{
if (isNull())
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 90ed5072e7..c7f27abdd6 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -118,7 +118,10 @@ struct Q_CORE_EXPORT QListData {
};
template <typename T>
-class QList : public QListSpecialMethods<T>
+class QList
+#ifndef Q_QDOC
+ : public QListSpecialMethods<T>
+#endif
{
public:
struct MemoryLayout
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index ea5d74d9bb..7809c513d6 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -61,7 +61,6 @@
#include "qvariant.h"
#include "qstringbuilder.h"
#include "private/qnumeric_p.h"
-#include "private/qsystemlibrary_p.h"
#ifdef Q_OS_WIN
# include <qt_windows.h>
# include <time.h>
diff --git a/src/corelib/tools/qlocale_mac.mm b/src/corelib/tools/qlocale_mac.mm
index 4b1d190705..4f6efc8832 100644
--- a/src/corelib/tools/qlocale_mac.mm
+++ b/src/corelib/tools/qlocale_mac.mm
@@ -390,9 +390,6 @@ static QString macFormatCurrency(const QSystemLocale::CurrencyToStringArgument &
static QVariant macQuoteString(QSystemLocale::QueryType type, const QStringRef &str)
{
- if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_6)
- return QVariant();
-
QString begin, end;
QCFType<CFLocaleRef> locale = CFLocaleCopyCurrent();
switch (type) {
diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp
index 88bfada515..f8b9f86ac6 100644
--- a/src/corelib/tools/qlocale_win.cpp
+++ b/src/corelib/tools/qlocale_win.cpp
@@ -44,9 +44,6 @@
#include "qstringlist.h"
#include "qvariant.h"
#include "qdatetime.h"
-
-#include "private/qsystemlibrary_p.h"
-
#include "qdebug.h"
#ifdef Q_OS_WIN
@@ -67,7 +64,6 @@ QT_BEGIN_NAMESPACE
#ifndef Q_OS_WINRT
static QByteArray getWinLocaleName(LCID id = LOCALE_USER_DEFAULT);
-static const char *winLangCodeToIsoName(int code);
static QString winIso639LangName(LCID id = LOCALE_USER_DEFAULT);
static QString winIso3116CtryName(LCID id = LOCALE_USER_DEFAULT);
#else // !Q_OS_WINRT
@@ -600,50 +596,32 @@ QVariant QSystemLocalePrivate::toCurrencyString(const QSystemLocale::CurrencyToS
QVariant QSystemLocalePrivate::uiLanguages()
{
- if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) {
- typedef BOOL (WINAPI *GetUserPreferredUILanguagesFunc) (
- DWORD dwFlags,
- PULONG pulNumLanguages,
- PWSTR pwszLanguagesBuffer,
- PULONG pcchLanguagesBuffer);
- static GetUserPreferredUILanguagesFunc GetUserPreferredUILanguages_ptr = 0;
#ifndef Q_OS_WINRT
- if (!GetUserPreferredUILanguages_ptr) {
- QSystemLibrary lib(QLatin1String("kernel32"));
- if (lib.load())
- GetUserPreferredUILanguages_ptr = (GetUserPreferredUILanguagesFunc)lib.resolve("GetUserPreferredUILanguages");
- }
-#endif // !Q_OS_WINRT
- if (GetUserPreferredUILanguages_ptr) {
- unsigned long cnt = 0;
- QVarLengthArray<wchar_t, 64> buf(64);
- unsigned long size = buf.size();
- if (!GetUserPreferredUILanguages_ptr(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size)) {
- size = 0;
- if (GetLastError() == ERROR_INSUFFICIENT_BUFFER &&
- GetUserPreferredUILanguages_ptr(MUI_LANGUAGE_NAME, &cnt, NULL, &size)) {
- buf.resize(size);
- if (!GetUserPreferredUILanguages_ptr(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size))
- return QStringList();
- }
- }
- QStringList result;
- result.reserve(cnt);
- const wchar_t *str = buf.constData();
- for (; cnt > 0; --cnt) {
- QString s = QString::fromWCharArray(str);
- if (s.isEmpty())
- break; // something is wrong
- result.append(s);
- str += s.size()+1;
- }
- return result;
+ unsigned long cnt = 0;
+ QVarLengthArray<wchar_t, 64> buf(64);
+# if !defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE) // Not present in MinGW 4.9/bootstrap builds.
+ unsigned long size = buf.size();
+ if (!GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size)) {
+ size = 0;
+ if (GetLastError() == ERROR_INSUFFICIENT_BUFFER &&
+ GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &cnt, NULL, &size)) {
+ buf.resize(size);
+ if (!GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size))
+ return QStringList();
}
}
-
-#ifndef Q_OS_WINRT
- // old Windows before Vista
- return QStringList(QString::fromLatin1(winLangCodeToIsoName(GetUserDefaultUILanguage())));
+# endif // !QT_BOOTSTRAPPED && !QT_BUILD_QMAKE
+ QStringList result;
+ result.reserve(cnt);
+ const wchar_t *str = buf.constData();
+ for (; cnt > 0; --cnt) {
+ QString s = QString::fromWCharArray(str);
+ if (s.isEmpty())
+ break; // something is wrong
+ result.append(s);
+ str += s.size() + 1;
+ }
+ return result;
#else // !Q_OS_WINRT
QStringList result;
ComPtr<ABI::Windows::Globalization::IApplicationLanguagesStatics> appLanguagesStatics;
@@ -1161,19 +1139,16 @@ static QByteArray getWinLocaleName(LPWSTR id)
}
}
-#if defined(Q_OS_WINCE)
- result = winLangCodeToIsoName(id != LOCALE_USER_DEFAULT ? id : GetUserDefaultLCID());
-#else // !Q_OS_WINCE
-# ifndef Q_OS_WINRT
+#ifndef Q_OS_WINRT
if (id == LOCALE_USER_DEFAULT)
id = GetUserDefaultLCID();
-# else // !Q_OS_WINRT
+#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
+#endif // Q_OS_WINRT
QString resultuage = winIso639LangName(id);
QString country = winIso3116CtryName(id);
result = resultuage.toLatin1();
@@ -1181,7 +1156,6 @@ static QByteArray getWinLocaleName(LPWSTR id)
result += '_';
result += country.toLatin1();
}
-#endif // !Q_OS_WINCE
return result;
}
diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h
index b376b6b999..8ce668f8ec 100644
--- a/src/corelib/tools/qrect.h
+++ b/src/corelib/tools/qrect.h
@@ -48,6 +48,10 @@
#error qrect.h must be included before any header file that defines topLeft
#endif
+#if defined(Q_OS_DARWIN)
+struct CGRect;
+#endif
+
QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT QRect
@@ -149,6 +153,10 @@ public:
friend Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &) Q_DECL_NOTHROW;
friend Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &) Q_DECL_NOTHROW;
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+ CGRect toCGRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+#endif
+
private:
int x1;
int y1;
@@ -604,6 +612,11 @@ public:
Q_DECL_CONSTEXPR inline QRect toRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
QRect toAlignedRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+ static QRectF fromCGRect(CGRect rect) Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ CGRect toCGRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+#endif
+
private:
qreal xp;
qreal yp;
diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp
index 1a37e0bc9c..67d11660e1 100644
--- a/src/corelib/tools/qscopedpointer.cpp
+++ b/src/corelib/tools/qscopedpointer.cpp
@@ -193,6 +193,48 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \fn bool operator==(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t)
+ \relates QScopedPointer
+ \since 5.8
+
+ Returns \c true if the scoped pointer \a lhs is a null pointer.
+
+ \sa QScopedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator==(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs)
+ \relates QScopedPointer
+ \since 5.8
+
+ Returns \c true if the scoped pointer \a rhs is a null pointer.
+
+ \sa QScopedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t)
+ \relates QScopedPointer
+ \since 5.8
+
+ Returns \c true if the scoped pointer \a lhs is a valid (i.e. a non-null)
+ pointer.
+
+ \sa QScopedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs)
+ \relates QScopedPointer
+ \since 5.8
+
+ Returns \c true if the scoped pointer \a rhs is a valid (i.e. a non-null)
+ pointer.
+
+ \sa QScopedPointer::isNull()
+*/
+
+/*!
\fn bool QScopedPointer::isNull() const
Returns \c true if this object is holding a pointer that is \c null.
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h
index 3e6af97a33..92d7df6e5d 100644
--- a/src/corelib/tools/qscopedpointer.h
+++ b/src/corelib/tools/qscopedpointer.h
@@ -97,7 +97,7 @@ class QScopedPointer
{
typedef T *QScopedPointer:: *RestrictedBool;
public:
- explicit inline QScopedPointer(T *p = Q_NULLPTR) : d(p)
+ explicit QScopedPointer(T *p = Q_NULLPTR) Q_DECL_NOTHROW : d(p)
{
}
@@ -113,13 +113,12 @@ public:
return *d;
}
- inline T *operator->() const
+ T *operator->() const Q_DECL_NOTHROW
{
- Q_ASSERT(d);
return d;
}
- inline bool operator!() const
+ bool operator!() const Q_DECL_NOTHROW
{
return !d;
}
@@ -130,23 +129,23 @@ public:
return isNull() ? Q_NULLPTR : &QScopedPointer::d;
}
#else
- inline operator RestrictedBool() const
+ operator RestrictedBool() const Q_DECL_NOTHROW
{
return isNull() ? Q_NULLPTR : &QScopedPointer::d;
}
#endif
- inline T *data() const
+ T *data() const Q_DECL_NOTHROW
{
return d;
}
- inline bool isNull() const
+ bool isNull() const Q_DECL_NOTHROW
{
return !d;
}
- inline void reset(T *other = Q_NULLPTR)
+ void reset(T *other = Q_NULLPTR) Q_DECL_NOEXCEPT_EXPR(noexcept(Cleanup::cleanup(std::declval<T *>())))
{
if (d == other)
return;
@@ -155,7 +154,7 @@ public:
Cleanup::cleanup(oldD);
}
- inline T *take()
+ T *take() Q_DECL_NOTHROW
{
T *oldD = d;
d = Q_NULLPTR;
@@ -177,18 +176,42 @@ private:
};
template <class T, class Cleanup>
-inline bool operator==(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
+inline bool operator==(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs) Q_DECL_NOTHROW
{
return lhs.data() == rhs.data();
}
template <class T, class Cleanup>
-inline bool operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
+inline bool operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs) Q_DECL_NOTHROW
{
return lhs.data() != rhs.data();
}
template <class T, class Cleanup>
+inline bool operator==(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return lhs.isNull();
+}
+
+template <class T, class Cleanup>
+inline bool operator==(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs) Q_DECL_NOTHROW
+{
+ return rhs.isNull();
+}
+
+template <class T, class Cleanup>
+inline bool operator!=(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return !lhs.isNull();
+}
+
+template <class T, class Cleanup>
+inline bool operator!=(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs) Q_DECL_NOTHROW
+{
+ return !rhs.isNull();
+}
+
+template <class T, class Cleanup>
inline void swap(QScopedPointer<T, Cleanup> &p1, QScopedPointer<T, Cleanup> &p2) Q_DECL_NOTHROW
{ p1.swap(p2); }
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index 84afb0c5db..af09ef6f40 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -442,15 +442,20 @@
*/
/*!
- \fn QSharedPointer::QSharedPointer(T *ptr)
+ \fn QSharedPointer::QSharedPointer(X *ptr)
Creates a QSharedPointer that points to \a ptr. The pointer \a ptr
becomes managed by this QSharedPointer and must not be passed to
another QSharedPointer object or deleted outside this object.
+
+ Since Qt 5.8, when the last reference to this QSharedPointer gets
+ destroyed, \a ptr will be deleted by calling \c X's destructor (even if \c
+ X is not the same as QSharedPointer's template parameter \c T). Previously,
+ the destructor for \c T was called.
*/
/*!
- \fn QSharedPointer::QSharedPointer(T *ptr, Deleter deleter)
+ \fn QSharedPointer::QSharedPointer(X *ptr, Deleter deleter)
Creates a QSharedPointer that points to \a ptr. The pointer \a ptr
becomes managed by this QSharedPointer and must not be passed to
@@ -477,6 +482,9 @@
}
\endcode
+ Note that the custom deleter function will be called with a pointer to type
+ \c X, even if the QSharedPointer template parameter \c T is not the same.
+
It is also possible to specify a member function directly, as in:
\code
QSharedPointer<MyObject> obj =
@@ -487,6 +495,22 @@
*/
/*!
+ \fn QSharedPointer::QSharedPointer(std::nullptr_t)
+ \since 5.8
+
+ Creates a QSharedPointer that is null. This is equivalent to the
+ QSharedPointer default constructor.
+*/
+
+/*!
+ \fn QSharedPointer::QSharedPointer(std::nullptr_t, Deleter)
+ \since 5.8
+
+ Creates a QSharedPointer that is null. This is equivalent to the
+ QSharedPointer default constructor.
+*/
+
+/*!
\fn QSharedPointer::QSharedPointer(const QSharedPointer<T> &other)
Creates a QSharedPointer object that shares \a other's pointer.
@@ -1124,6 +1148,90 @@
*/
/*!
+ \fn bool operator==(const QSharedPointer<T> &lhs, std::nullptr_t)
+ \relates QSharedPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a lhs is a null pointer.
+
+ \sa QSharedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator==(std::nullptr_t, const QSharedPointer<T> &rhs)
+ \relates QSharedPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a rhs is a null pointer.
+
+ \sa QSharedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(const QSharedPointer<T> &lhs, std::nullptr_t)
+ \relates QSharedPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a lhs is a valid (i.e.
+ non-null) pointer.
+
+ \sa QSharedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(std::nullptr_t, const QSharedPointer<T> &rhs)
+ \relates QSharedPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a rhs is a valid (i.e.
+ non-null) pointer.
+
+ \sa QSharedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator==(const QWeakPointer<T> &lhs, std::nullptr_t)
+ \relates QWeakPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a lhs is a null pointer.
+
+ \sa QWeakPointer::isNull()
+*/
+
+/*!
+ \fn bool operator==(std::nullptr_t, const QWeakPointer<T> &rhs)
+ \relates QWeakPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a rhs is a null pointer.
+
+ \sa QWeakPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(const QWeakPointer<T> &lhs, std::nullptr_t)
+ \relates QWeakPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a lhs is a valid (i.e.
+ non-null) pointer.
+
+ \sa QWeakPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(std::nullptr_t, const QWeakPointer<T> &rhs)
+ \relates QWeakPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a rhs is a valid (i.e.
+ non-null) pointer.
+
+ \sa QWeakPointer::isNull()
+*/
+
+/*!
\fn bool operator!=(const QWeakPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
\relates QWeakPointer
diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h
index 72976637d5..3b86eb238b 100644
--- a/src/corelib/tools/qsharedpointer.h
+++ b/src/corelib/tools/qsharedpointer.h
@@ -67,8 +67,10 @@ public:
// constructors
QSharedPointer();
- explicit QSharedPointer(T *ptr);
- QSharedPointer(T *ptr, Deleter d);
+ template <typename X> explicit QSharedPointer(X *ptr);
+ template <typename X, typename Deleter> QSharedPointer(X *ptr, Deleter d);
+ QSharedPointer(std::nullptr_t);
+ template <typename Deleter> QSharedPointer(std::nullptr_t, Deleter d);
QSharedPointer(const QSharedPointer<T> &other);
QSharedPointer(const QWeakPointer<T> &other);
@@ -147,6 +149,14 @@ template<class T, class X> bool operator==(const QWeakPointer<T> &ptr1, const QS
template<class T, class X> bool operator!=(const QWeakPointer<T> &ptr1, const QSharedPointer<X> &ptr2);
template<class T, class X> bool operator==(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2);
template<class T, class X> bool operator!=(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2);
+template<class T> bool operator==(const QSharedPointer<T> &lhs, std::nullptr_t);
+template<class T> bool operator!=(const QSharedPointer<T> &lhs, std::nullptr_t);
+template<class T> bool operator==(std::nullptr_t, const QSharedPointer<T> &rhs);
+template<class T> bool operator!=(std::nullptr_t, const QSharedPointer<T> &rhs);
+template<class T> bool operator==(const QWeakPointer<T> &lhs, std::nullptr_t);
+template<class T> bool operator!=(const QWeakPointer<T> &lhs, std::nullptr_t);
+template<class T> bool operator==(std::nullptr_t, const QWeakPointer<T> &rhs);
+template<class T> bool operator!=(std::nullptr_t, const QWeakPointer<T> &rhs);
template <class X, class T> QSharedPointer<X> qSharedPointerCast(const QSharedPointer<T> &other);
template <class X, class T> QSharedPointer<X> qSharedPointerCast(const QWeakPointer<T> &other);
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index e9a5443121..0f769ffa86 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -305,23 +305,29 @@ public:
typedef const value_type &const_reference;
typedef qptrdiff difference_type;
- inline T *data() const { return value; }
- inline bool isNull() const { return !data(); }
- inline operator RestrictedBool() const { return isNull() ? Q_NULLPTR : &QSharedPointer::value; }
- inline bool operator !() const { return isNull(); }
- inline T &operator*() const { return *data(); }
- inline T *operator->() const { return data(); }
-
- QSharedPointer() Q_DECL_NOTHROW : value(Q_NULLPTR), d(Q_NULLPTR) {}
+ T *data() const Q_DECL_NOTHROW { return value; }
+ bool isNull() const Q_DECL_NOTHROW { return !data(); }
+ operator RestrictedBool() const Q_DECL_NOTHROW { return isNull() ? Q_NULLPTR : &QSharedPointer::value; }
+ bool operator !() const Q_DECL_NOTHROW { return isNull(); }
+ T &operator*() const { return *data(); }
+ T *operator->() const Q_DECL_NOTHROW { return data(); }
+
+ Q_DECL_CONSTEXPR QSharedPointer() Q_DECL_NOTHROW : value(nullptr), d(nullptr) { }
~QSharedPointer() { deref(); }
- inline explicit QSharedPointer(T *ptr) : value(ptr) // noexcept
+ Q_DECL_CONSTEXPR QSharedPointer(std::nullptr_t) Q_DECL_NOTHROW : value(nullptr), d(nullptr) { }
+
+ template <class X>
+ inline explicit QSharedPointer(X *ptr) : value(ptr) // noexcept
{ internalConstruct(ptr, QtSharedPointer::NormalDeleter()); }
- template <typename Deleter>
- inline QSharedPointer(T *ptr, Deleter deleter) : value(ptr) // throws
+ template <class X, typename Deleter>
+ inline QSharedPointer(X *ptr, Deleter deleter) : value(ptr) // throws
{ internalConstruct(ptr, deleter); }
+ template <typename Deleter>
+ QSharedPointer(std::nullptr_t, Deleter) : value(nullptr), d(nullptr) { }
+
QSharedPointer(const QSharedPointer &other) Q_DECL_NOTHROW : value(other.value), d(other.d)
{ if (d) ref(); }
QSharedPointer &operator=(const QSharedPointer &other) Q_DECL_NOTHROW
@@ -363,7 +369,7 @@ public:
#endif
template <class X>
- inline QSharedPointer(const QSharedPointer<X> &other) : value(other.value), d(other.d)
+ QSharedPointer(const QSharedPointer<X> &other) Q_DECL_NOTHROW : value(other.value), d(other.d)
{ if (d) ref(); }
template <class X>
@@ -511,15 +517,15 @@ private:
inline void enableSharedFromThis(...) {}
- template <typename Deleter>
- inline void internalConstruct(T *ptr, Deleter deleter)
+ template <typename X, typename Deleter>
+ inline void internalConstruct(X *ptr, Deleter deleter)
{
if (!ptr) {
d = Q_NULLPTR;
return;
}
- typedef QtSharedPointer::ExternalRefCountWithCustomDeleter<T, Deleter> Private;
+ typedef QtSharedPointer::ExternalRefCountWithCustomDeleter<X, Deleter> Private;
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
typename Private::DestroyerFn actualDeleter = &Private::safetyCheckDeleter;
# else
@@ -598,10 +604,10 @@ public:
typedef const value_type &const_reference;
typedef qptrdiff difference_type;
- inline bool isNull() const { return d == Q_NULLPTR || d->strongref.load() == 0 || value == Q_NULLPTR; }
- inline operator RestrictedBool() const { return isNull() ? Q_NULLPTR : &QWeakPointer::value; }
- inline bool operator !() const { return isNull(); }
- inline T *data() const { return d == Q_NULLPTR || d->strongref.load() == 0 ? Q_NULLPTR : value; }
+ bool isNull() const Q_DECL_NOTHROW { return d == Q_NULLPTR || d->strongref.load() == 0 || value == Q_NULLPTR; }
+ operator RestrictedBool() const Q_DECL_NOTHROW { return isNull() ? Q_NULLPTR : &QWeakPointer::value; }
+ bool operator !() const Q_DECL_NOTHROW { return isNull(); }
+ T *data() const Q_DECL_NOTHROW { return d == Q_NULLPTR || d->strongref.load() == 0 ? Q_NULLPTR : value; }
inline QWeakPointer() Q_DECL_NOTHROW : d(Q_NULLPTR), value(Q_NULLPTR) { }
inline ~QWeakPointer() { if (d && !d->weakref.deref()) delete d; }
@@ -668,11 +674,11 @@ public:
}
template <class X>
- inline bool operator==(const QWeakPointer<X> &o) const
+ bool operator==(const QWeakPointer<X> &o) const Q_DECL_NOTHROW
{ return d == o.d && value == static_cast<const T *>(o.value); }
template <class X>
- inline bool operator!=(const QWeakPointer<X> &o) const
+ bool operator!=(const QWeakPointer<X> &o) const Q_DECL_NOTHROW
{ return !(*this == o); }
template <class X>
@@ -688,11 +694,11 @@ public:
}
template <class X>
- inline bool operator==(const QSharedPointer<X> &o) const
+ bool operator==(const QSharedPointer<X> &o) const Q_DECL_NOTHROW
{ return d == o.d; }
template <class X>
- inline bool operator!=(const QSharedPointer<X> &o) const
+ bool operator!=(const QSharedPointer<X> &o) const Q_DECL_NOTHROW
{ return !(*this == o); }
inline void clear() { *this = QWeakPointer(); }
@@ -774,48 +780,96 @@ public:
// operator== and operator!=
//
template <class T, class X>
-bool operator==(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
+bool operator==(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2) Q_DECL_NOTHROW
{
return ptr1.data() == ptr2.data();
}
template <class T, class X>
-bool operator!=(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
+bool operator!=(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2) Q_DECL_NOTHROW
{
return ptr1.data() != ptr2.data();
}
template <class T, class X>
-bool operator==(const QSharedPointer<T> &ptr1, const X *ptr2)
+bool operator==(const QSharedPointer<T> &ptr1, const X *ptr2) Q_DECL_NOTHROW
{
return ptr1.data() == ptr2;
}
template <class T, class X>
-bool operator==(const T *ptr1, const QSharedPointer<X> &ptr2)
+bool operator==(const T *ptr1, const QSharedPointer<X> &ptr2) Q_DECL_NOTHROW
{
return ptr1 == ptr2.data();
}
template <class T, class X>
-bool operator!=(const QSharedPointer<T> &ptr1, const X *ptr2)
+bool operator!=(const QSharedPointer<T> &ptr1, const X *ptr2) Q_DECL_NOTHROW
{
return !(ptr1 == ptr2);
}
template <class T, class X>
-bool operator!=(const T *ptr1, const QSharedPointer<X> &ptr2)
+bool operator!=(const T *ptr1, const QSharedPointer<X> &ptr2) Q_DECL_NOTHROW
{
return !(ptr2 == ptr1);
}
template <class T, class X>
-bool operator==(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2)
+bool operator==(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2) Q_DECL_NOTHROW
{
return ptr2 == ptr1;
}
template <class T, class X>
-bool operator!=(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2)
+bool operator!=(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2) Q_DECL_NOTHROW
{
return ptr2 != ptr1;
}
+template<class T>
+inline bool operator==(const QSharedPointer<T> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return lhs.isNull();
+}
+
+template<class T>
+inline bool operator!=(const QSharedPointer<T> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return !lhs.isNull();
+}
+
+template<class T>
+inline bool operator==(std::nullptr_t, const QSharedPointer<T> &rhs) Q_DECL_NOTHROW
+{
+ return rhs.isNull();
+}
+
+template<class T>
+inline bool operator!=(std::nullptr_t, const QSharedPointer<T> &rhs) Q_DECL_NOTHROW
+{
+ return !rhs.isNull();
+}
+
+template<class T>
+inline bool operator==(const QWeakPointer<T> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return lhs.isNull();
+}
+
+template<class T>
+inline bool operator!=(const QWeakPointer<T> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return !lhs.isNull();
+}
+
+template<class T>
+inline bool operator==(std::nullptr_t, const QWeakPointer<T> &rhs) Q_DECL_NOTHROW
+{
+ return rhs.isNull();
+}
+
+template<class T>
+inline bool operator!=(std::nullptr_t, const QWeakPointer<T> &rhs) Q_DECL_NOTHROW
+{
+ return !rhs.isNull();
+}
+
//
// operator-
//
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
index c869c4e089..d4edf459de 100644
--- a/src/corelib/tools/qsimd.cpp
+++ b/src/corelib/tools/qsimd.cpp
@@ -48,16 +48,8 @@
#endif
#if defined(Q_OS_WIN)
-# if defined(Q_OS_WINCE)
-# include <qt_windows.h>
-# if _WIN32_WCE < 0x800
-# include <cmnintrin.h>
-# endif
-# endif
# if !defined(Q_CC_GNU)
-# ifndef Q_OS_WINCE
-# include <intrin.h>
-# endif
+# include <intrin.h>
# endif
#elif defined(Q_OS_LINUX) && (defined(Q_PROCESSOR_ARM) || defined(Q_PROCESSOR_MIPS_32))
#include "private/qcore_unix_p.h"
@@ -93,25 +85,6 @@ static inline uint detectProcessorFeatures()
{
return 0;
}
-#elif defined (Q_OS_WINCE)
-static inline quint64 detectProcessorFeatures()
-{
- quint64 features = 0;
-
-#if defined (ARM)
-# ifdef PF_ARM_NEON
- if (IsProcessorFeaturePresent(PF_ARM_NEON))
- features |= Q_UINT64_C(1) << CpuFeatureNEON;
-# endif
-#elif defined(_X86_)
- if (IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE))
- features |= Q_UINT64_C(1) << CpuFeatureSSE2;
- if (IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE))
- features |= Q_UINT64_C(1) << CpuFeatureSSE3;
-#endif
- return features;
-}
-
#elif defined(Q_PROCESSOR_ARM)
static inline quint64 detectProcessorFeatures()
{
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index 8ddaed8032..8cf0c5a4d2 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -139,7 +139,7 @@
* }
*/
-#if defined(__MINGW64_VERSION_MAJOR) || (defined(Q_CC_MSVC) && !defined(Q_OS_WINCE))
+#if defined(__MINGW64_VERSION_MAJOR) || defined(Q_CC_MSVC)
#include <intrin.h>
#endif
@@ -465,65 +465,6 @@ static inline quint64 qCpuFeatures()
#define qCpuHasFeature(feature) ((qCompilerCpuFeatures & (Q_UINT64_C(1) << CpuFeature ## feature)) \
|| (qCpuFeatures() & (Q_UINT64_C(1) << CpuFeature ## feature)))
-#if QT_HAS_BUILTIN(__builtin_clz) && QT_HAS_BUILTIN(__builtin_ctz) && defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
-static Q_ALWAYS_INLINE unsigned _bit_scan_reverse(unsigned val)
-{
- Q_ASSERT(val != 0); // if val==0, the result is undefined.
- unsigned result = static_cast<unsigned>(__builtin_clz(val)); // Count Leading Zeros
- // Now Invert the result: clz will count *down* from the msb to the lsb, so the msb index is 31
- // and the lsb inde is 0. The result for _bit_scan_reverse is expected to be the index when
- // counting up: msb index is 0 (because it starts there), and the lsb index is 31.
- result ^= sizeof(unsigned) * 8 - 1;
- return result;
-}
-static Q_ALWAYS_INLINE unsigned _bit_scan_forward(unsigned val)
-{
- Q_ASSERT(val != 0); // if val==0, the result is undefined.
- return static_cast<unsigned>(__builtin_ctz(val)); // Count Trailing Zeros
-}
-#elif defined(Q_PROCESSOR_X86)
-// Bit scan functions for x86
-# if defined(Q_CC_MSVC)
-# if defined _WIN32_WCE && _WIN32_WCE < 0x800
-extern "C" unsigned char _BitScanForward(unsigned long* Index, unsigned long Mask);
-extern "C" unsigned char _BitScanReverse(unsigned long* Index, unsigned long Mask);
-# pragma intrinsic(_BitScanForward)
-# pragma intrinsic(_BitScanReverse)
-# endif
-// MSVC calls it _BitScanReverse and returns the carry flag, which we don't need
-static __forceinline unsigned long _bit_scan_reverse(uint val)
-{
- unsigned long result;
- _BitScanReverse(&result, val);
- return result;
-}
-static __forceinline unsigned long _bit_scan_forward(uint val)
-{
- unsigned long result;
- _BitScanForward(&result, val);
- return result;
-}
-# elif (defined(Q_CC_CLANG) || (defined(Q_CC_GNU) && Q_CC_GNU < 405)) \
- && !defined(Q_CC_INTEL)
-// Clang is missing the intrinsic for _bit_scan_reverse
-// GCC only added it in version 4.5
-static inline __attribute__((always_inline))
-unsigned _bit_scan_reverse(unsigned val)
-{
- unsigned result;
- asm("bsr %1, %0" : "=r" (result) : "r" (val));
- return result;
-}
-static inline __attribute__((always_inline))
-unsigned _bit_scan_forward(unsigned val)
-{
- unsigned result;
- asm("bsf %1, %0" : "=r" (result) : "r" (val));
- return result;
-}
-# endif
-#endif // Q_PROCESSOR_X86
-
#define ALIGNMENT_PROLOGUE_16BYTES(ptr, i, length) \
for (; i < static_cast<int>(qMin(static_cast<quintptr>(length), ((4 - ((reinterpret_cast<quintptr>(ptr) >> 2) & 0x3)) & 0x3))); ++i)
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 85da174366..c79bced52e 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -81,9 +81,6 @@
#ifdef Q_OS_WIN
# include <qt_windows.h>
-# ifdef Q_OS_WINCE
-# include <winnls.h>
-# endif
#endif
#ifdef truncate
@@ -471,7 +468,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, int l)
uint mask = ~_mm_movemask_epi8(result);
if (ushort(mask)) {
// found a different byte
- uint idx = uint(_bit_scan_forward(mask));
+ uint idx = qCountTrailingZeroBits(mask);
return reinterpret_cast<const QChar *>(ptr + idx)->unicode()
- reinterpret_cast<const QChar *>(ptr + distance + idx)->unicode();
}
@@ -574,7 +571,7 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
# endif
if (mask) {
// found a different character
- uint idx = uint(_bit_scan_forward(mask));
+ uint idx = qCountTrailingZeroBits(mask);
return uc[offset + idx / 2] - c[offset + idx / 2];
}
}
@@ -592,7 +589,7 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
uint mask = ~_mm_movemask_epi8(result);
if (ushort(mask)) {
// found a different character
- uint idx = uint(_bit_scan_forward(mask));
+ uint idx = qCountTrailingZeroBits(mask);
return uc[offset + idx / 2] - c[offset + idx / 2];
}
@@ -686,7 +683,7 @@ static int findChar(const QChar *str, int len, QChar ch, int from,
// found a match
// same as: return n - s + _bit_scan_forward(mask) / 2
return (reinterpret_cast<const char *>(n) - reinterpret_cast<const char *>(s)
- + _bit_scan_forward(mask)) >> 1;
+ + qCountTrailingZeroBits(mask)) >> 1;
}
}
@@ -1151,7 +1148,7 @@ const QString::Null QString::null = { };
has a ref count of 1, whereas QString::append() needs an extra
test).
- There are three ways you can access this improved method of string
+ There are two ways you can access this improved method of string
construction. The straightforward way is to include
\c{QStringBuilder} wherever you want to use it, and use the
\c{'%'} operator instead of \c{'+'} when concatenating strings:
@@ -3273,7 +3270,7 @@ int QString::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) co
{
const int sl = str.size();
if (sl == 1)
- return lastIndexOf(QLatin1Char(str.latin1()[0]), from, cs);
+ return lastIndexOf(str.at(0), from, cs);
const int l = d->size;
if (from < 0)
@@ -5522,7 +5519,7 @@ int QString::localeAwareCompare(const QString &other) const
return localeAwareCompare_helper(constData(), length(), other.constData(), other.length());
}
-#if defined(QT_USE_ICU) && !defined(Q_OS_WIN32) && !defined(Q_OS_WINCE) && !defined (Q_OS_MAC)
+#if defined(QT_USE_ICU) && !defined(Q_OS_WIN32) && !defined(Q_OS_DARWIN)
Q_GLOBAL_STATIC(QThreadStorage<QCollator>, defaultCollator)
#endif
@@ -5537,12 +5534,12 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1,
if (length1 == 0 || length2 == 0)
return ucstrcmp(data1, length1, data2, length2);
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
-#ifndef Q_OS_WINRT
+#if defined(Q_OS_WIN)
+# ifndef Q_OS_WINRT
int res = CompareString(GetUserDefaultLCID(), 0, (wchar_t*)data1, length1, (wchar_t*)data2, length2);
-#else
+# else
int res = CompareStringEx(LOCALE_NAME_USER_DEFAULT, 0, (LPCWSTR)data1, length1, (LPCWSTR)data2, length2, NULL, NULL, 0);
-#endif
+# endif
switch (res) {
case CSTR_LESS_THAN:
@@ -7949,40 +7946,6 @@ QString QString::multiArg(int numArgs, const QString **args) const
return result;
}
-
-/*! \fn QString QString::fromCFString(CFStringRef string)
- \since 5.2
-
- Constructs a new QString containing a copy of the \a string CFString.
-
- \note this function is only available on OS X and iOS.
-*/
-
-/*! \fn CFStringRef QString::toCFString() const
- \since 5.2
-
- Creates a CFString from a QString. The caller owns the CFString and is
- responsible for releasing it.
-
- \note this function is only available on OS X and iOS.
-*/
-
-/*! \fn QString QString::fromNSString(const NSString *string)
- \since 5.2
-
- Constructs a new QString containing a copy of the \a string NSString.
-
- \note this function is only available on OS X and iOS.
-*/
-
-/*! \fn NSString QString::toNSString() const
- \since 5.2
-
- Creates a NSString from a QString. The NSString is autoreleased.
-
- \note this function is only available on OS X and iOS.
-*/
-
/*! \fn bool QString::isSimpleText() const
\internal
@@ -8332,6 +8295,78 @@ QString &QString::setRawData(const QChar *unicode, int size)
Returns the size of the Latin-1 string stored in this object.
*/
+/*! \fn QLatin1Char QLatin1String::at(int pos) const
+ \since 5.8
+
+ Returns the character at position \a pos in this object.
+
+ \note This function performs no error checking.
+ The behavior is undefined when \a pos < 0 or \a pos ≥ size().
+
+ \sa operator[]()
+*/
+
+/*! \fn QLatin1Char QLatin1String::operator[](int pos) const
+ \since 5.8
+
+ Returns the character at position \a pos in this object.
+
+ \note This function performs no error checking.
+ The behavior is undefined when \a pos < 0 or \a pos ≥ size().
+
+ \sa at()
+*/
+
+/*! \fn QLatin1String QLatin1String::mid(int start) const
+ \since 5.8
+
+ Returns the substring starting at position \a start in this object,
+ and extending to the end of the string.
+
+ \note This function performs no error checking.
+ The behavior is undefined when \a start < 0 or \a start > size().
+
+ \sa left(), right()
+*/
+
+/*! \fn QLatin1String QLatin1String::mid(int start, int length) const
+ \since 5.8
+ \overload
+
+ Returns the substring of length \a length starting at position
+ \a start in this object.
+
+ \note This function performs no error checking.
+ The behavior is undefined when \a start < 0, \length < 0,
+ or \a start + \a length > size().
+
+ \sa left(), right()
+*/
+
+/*! \fn QLatin1String QLatin1String::left(int length) const
+ \since 5.8
+
+ Returns the substring of length \a length starting at position
+ 0 in this object.
+
+ \note This function performs no error checking.
+ The behavior is undefined when \length < 0 or \a length > size().
+
+ \sa mid(), right()
+*/
+
+/*! \fn QLatin1String QLatin1String::right(int length) const
+ \since 5.8
+
+ Returns the substring of length \a length starting at position
+ size() - \a length in this object.
+
+ \note This function performs no error checking.
+ The behavior is undefined when \length < 0 or \a length > size().
+
+ \sa mid(), left()
+*/
+
/*! \fn bool QLatin1String::operator==(const QString &other) const
Returns \c true if this string is equal to string \a other;
@@ -9364,6 +9399,24 @@ QStringRef QStringRef::appendTo(QString *string) const
*/
/*!
+ \overload
+ \fn int QStringRef::compare(const QByteArray &other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ \since 5.8
+
+ Compares this string with \a other and returns an
+ integer less than, equal to, or greater than zero if this string
+ is less than, equal to, or greater than the \a other byte array,
+ interpreted as a UTF-8 sequence.
+
+ If \a cs is Qt::CaseSensitive, the comparison is case sensitive;
+ otherwise the comparison is case insensitive.
+
+ Equivalent to \c {compare(*this, other, cs)}.
+
+ \sa QString::compare()
+*/
+
+/*!
\fn int QStringRef::localeAwareCompare(const QStringRef &s1, const QString & s2)
\since 4.5
@@ -9747,7 +9800,7 @@ int QStringRef::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs)
{
const int sl = str.size();
if (sl == 1)
- return lastIndexOf(QLatin1Char(str.latin1()[0]), from, cs);
+ return lastIndexOf(str.at(0), from, cs);
const int l = size();
if (from < 0)
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 793a859228..16a48515e8 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -68,11 +68,9 @@ namespace std
#error qstring.h must be included before any header file that defines truncate
#endif
-#ifdef Q_OS_MAC
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_FORWARD_DECLARE_CF_TYPE(CFString);
-# ifdef __OBJC__
Q_FORWARD_DECLARE_OBJC_CLASS(NSString);
-# endif
#endif
QT_BEGIN_NAMESPACE
@@ -99,6 +97,18 @@ public:
Q_DECL_CONSTEXPR int size() const Q_DECL_NOTHROW { return m_size; }
Q_DECL_CONSTEXPR const char *data() const Q_DECL_NOTHROW { return m_data; }
+ Q_DECL_CONSTEXPR QLatin1Char at(int i) const { return QLatin1Char(m_data[i]); }
+ Q_DECL_CONSTEXPR QLatin1Char operator[](int i) const { return at(i); }
+
+ Q_DECL_CONSTEXPR QLatin1String mid(int pos) const
+ { return QLatin1String(m_data + pos, m_size - pos); }
+ Q_DECL_CONSTEXPR QLatin1String mid(int pos, int n) const
+ { return QLatin1String(m_data + pos, n); }
+ Q_DECL_CONSTEXPR QLatin1String left(int n) const
+ { return QLatin1String(m_data, n); }
+ Q_DECL_CONSTEXPR QLatin1String right(int n) const
+ { return QLatin1String(m_data + m_size - n, n); }
+
inline bool operator==(const QString &s) const Q_DECL_NOTHROW;
inline bool operator!=(const QString &s) const Q_DECL_NOTHROW;
inline bool operator>(const QString &s) const Q_DECL_NOTHROW;
@@ -593,7 +603,7 @@ public:
Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW
{ return -s2.compare(s1, cs); }
- int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW;
+ inline int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW;
static int compare(const QString &s1, const QStringRef &s2,
Qt::CaseSensitivity = Qt::CaseSensitive) Q_DECL_NOTHROW;
@@ -768,13 +778,11 @@ public:
inline std::u32string toStdU32String() const;
#endif
-#if defined(Q_OS_MAC) || defined(Q_QDOC)
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
static QString fromCFString(CFStringRef string);
CFStringRef toCFString() const Q_DECL_CF_RETURNS_RETAINED;
-# if defined(__OBJC__) || defined(Q_QDOC)
static QString fromNSString(const NSString *string);
NSString *toNSString() const Q_DECL_NS_RETURNS_AUTORELEASED;
-# endif
#endif
// compatibility
struct Null { };
@@ -802,6 +810,16 @@ private:
Data *d;
+ friend inline bool operator==(QChar, const QString &) Q_DECL_NOTHROW;
+ friend inline bool operator< (QChar, const QString &) Q_DECL_NOTHROW;
+ friend inline bool operator> (QChar, const QString &) Q_DECL_NOTHROW;
+ friend inline bool operator==(QChar, const QStringRef &) Q_DECL_NOTHROW;
+ friend inline bool operator< (QChar, const QStringRef &) Q_DECL_NOTHROW;
+ friend inline bool operator> (QChar, const QStringRef &) Q_DECL_NOTHROW;
+ friend inline bool operator==(QChar, QLatin1String) Q_DECL_NOTHROW;
+ friend inline bool operator< (QChar, QLatin1String) Q_DECL_NOTHROW;
+ friend inline bool operator> (QChar, QLatin1String) Q_DECL_NOTHROW;
+
void reallocData(uint alloc, bool grow = false);
void expand(int i);
QString multiArg(int numArgs, const QString **args) const;
@@ -1483,6 +1501,10 @@ public:
int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW;
int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW;
int compare(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW;
+#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
+ int compare(const QByteArray &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ { return QString::compare_helper(unicode(), size(), s.data(), qstrnlen(s.data(), s.size()), cs); }
+#endif
static int compare(const QStringRef &s1, const QString &s2,
Qt::CaseSensitivity = Qt::CaseSensitive) Q_DECL_NOTHROW;
static int compare(const QStringRef &s1, const QStringRef &s2,
@@ -1518,24 +1540,10 @@ inline QStringRef::QStringRef(const QString *aString, int aPosition, int aSize)
inline QStringRef::QStringRef(const QString *aString)
:m_string(aString), m_position(0), m_size(aString?aString->size() : 0){}
+// QStringRef <> QStringRef
Q_CORE_EXPORT bool operator==(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW;
inline bool operator!=(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW
{ return !(s1 == s2); }
-Q_CORE_EXPORT bool operator==(const QString &s1, const QStringRef &s2) Q_DECL_NOTHROW;
-inline bool operator!=(const QString &s1, const QStringRef &s2) Q_DECL_NOTHROW
-{ return !(s1 == s2); }
-inline bool operator==(const QStringRef &s1, const QString &s2) Q_DECL_NOTHROW
-{ return s2 == s1; }
-inline bool operator!=(const QStringRef &s1, const QString &s2) Q_DECL_NOTHROW
-{ return s2 != s1; }
-Q_CORE_EXPORT bool operator==(QLatin1String s1, const QStringRef &s2) Q_DECL_NOTHROW;
-inline bool operator!=(QLatin1String s1, const QStringRef &s2) Q_DECL_NOTHROW
-{ return !(s1 == s2); }
-inline bool operator==(const QStringRef &s1, QLatin1String s2) Q_DECL_NOTHROW
-{ return s2 == s1; }
-inline bool operator!=(const QStringRef &s1, QLatin1String s2) Q_DECL_NOTHROW
-{ return s2 != s1; }
-
Q_CORE_EXPORT bool operator<(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW;
inline bool operator>(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW
{ return s2 < s1; }
@@ -1544,7 +1552,127 @@ inline bool operator<=(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHRO
inline bool operator>=(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW
{ return !(s1 < s2); }
+// QString <> QStringRef
+Q_CORE_EXPORT bool operator==(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW;
+inline bool operator!=(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) != 0; }
+inline bool operator< (const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) < 0; }
+inline bool operator> (const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) > 0; }
+inline bool operator<=(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) <= 0; }
+inline bool operator>=(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) >= 0; }
+
+inline bool operator==(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs == lhs; }
+inline bool operator!=(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs != lhs; }
+inline bool operator< (const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs > lhs; }
+inline bool operator> (const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs < lhs; }
+inline bool operator<=(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs >= lhs; }
+inline bool operator>=(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs <= lhs; }
+
+inline int QString::compare(const QStringRef &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
+{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
+inline int QString::compare(const QString &s1, const QStringRef &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
+{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
+inline int QStringRef::compare(const QString &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
+{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
+inline int QStringRef::compare(const QStringRef &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
+{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
+inline int QStringRef::compare(QLatin1String s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
+{ return QString::compare_helper(constData(), length(), s, cs); }
+inline int QStringRef::compare(const QStringRef &s1, const QString &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
+{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
+inline int QStringRef::compare(const QStringRef &s1, const QStringRef &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
+{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
+inline int QStringRef::compare(const QStringRef &s1, QLatin1String s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
+{ return QString::compare_helper(s1.constData(), s1.length(), s2, cs); }
+
+// QLatin1String <> QStringRef
+Q_CORE_EXPORT bool operator==(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW;
+inline bool operator!=(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) != 0; }
+inline bool operator< (QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) > 0; }
+inline bool operator> (QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) < 0; }
+inline bool operator<=(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) >= 0; }
+inline bool operator>=(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) <= 0; }
+
+inline bool operator==(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs == lhs; }
+inline bool operator!=(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs != lhs; }
+inline bool operator< (const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs > lhs; }
+inline bool operator> (const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs < lhs; }
+inline bool operator<=(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs >= lhs; }
+inline bool operator>=(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs <= lhs; }
+
+// QChar <> QString
+inline bool operator==(QChar lhs, const QString &rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) == 0; }
+inline bool operator< (QChar lhs, const QString &rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) < 0; }
+inline bool operator> (QChar lhs, const QString &rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) > 0; }
+
+inline bool operator!=(QChar lhs, const QString &rhs) Q_DECL_NOTHROW { return !(lhs == rhs); }
+inline bool operator<=(QChar lhs, const QString &rhs) Q_DECL_NOTHROW { return !(lhs > rhs); }
+inline bool operator>=(QChar lhs, const QString &rhs) Q_DECL_NOTHROW { return !(lhs < rhs); }
+
+inline bool operator==(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs == lhs; }
+inline bool operator!=(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs == lhs); }
+inline bool operator< (const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs > lhs; }
+inline bool operator> (const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs < lhs; }
+inline bool operator<=(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs < lhs); }
+inline bool operator>=(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs > lhs); }
+
+// QChar <> QStringRef
+inline bool operator==(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) == 0; }
+inline bool operator< (QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) < 0; }
+inline bool operator> (QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) > 0; }
+
+inline bool operator!=(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return !(lhs == rhs); }
+inline bool operator<=(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return !(lhs > rhs); }
+inline bool operator>=(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return !(lhs < rhs); }
+
+inline bool operator==(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs == lhs; }
+inline bool operator!=(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs == lhs); }
+inline bool operator< (const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs > lhs; }
+inline bool operator> (const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs < lhs; }
+inline bool operator<=(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs < lhs); }
+inline bool operator>=(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs > lhs); }
+
+// QChar <> QLatin1String
+inline bool operator==(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs) == 0; }
+inline bool operator< (QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs) < 0; }
+inline bool operator> (QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs) > 0; }
+
+inline bool operator!=(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW { return !(lhs == rhs); }
+inline bool operator<=(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW { return !(lhs > rhs); }
+inline bool operator>=(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW { return !(lhs < rhs); }
+
+inline bool operator==(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return rhs == lhs; }
+inline bool operator!=(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs == lhs); }
+inline bool operator< (QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return rhs > lhs; }
+inline bool operator> (QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return rhs < lhs; }
+inline bool operator<=(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs < lhs); }
+inline bool operator>=(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs > lhs); }
+
#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
+// QStringRef <> QByteArray
+inline QT_ASCII_CAST_WARN bool operator==(const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) == 0; }
+inline QT_ASCII_CAST_WARN bool operator!=(const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) != 0; }
+inline QT_ASCII_CAST_WARN bool operator< (const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) < 0; }
+inline QT_ASCII_CAST_WARN bool operator> (const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) > 0; }
+inline QT_ASCII_CAST_WARN bool operator<=(const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) <= 0; }
+inline QT_ASCII_CAST_WARN bool operator>=(const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) >= 0; }
+
+inline QT_ASCII_CAST_WARN bool operator==(const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) == 0; }
+inline QT_ASCII_CAST_WARN bool operator!=(const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) != 0; }
+inline QT_ASCII_CAST_WARN bool operator< (const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) > 0; }
+inline QT_ASCII_CAST_WARN bool operator> (const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) < 0; }
+inline QT_ASCII_CAST_WARN bool operator<=(const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) >= 0; }
+inline QT_ASCII_CAST_WARN bool operator>=(const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) <= 0; }
+
+// QStringRef <> const char *
inline QT_ASCII_CAST_WARN bool QStringRef::operator==(const char *s) const
{ return QString::compare_helper(constData(), size(), s, -1) == 0; }
inline QT_ASCII_CAST_WARN bool QStringRef::operator!=(const char *s) const
@@ -1572,23 +1700,6 @@ inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QStringRef &s2)
{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) <= 0; }
#endif // !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
-inline int QString::compare(const QStringRef &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
-{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
-inline int QString::compare(const QString &s1, const QStringRef &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
-{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
-inline int QStringRef::compare(const QString &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
-{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
-inline int QStringRef::compare(const QStringRef &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
-{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
-inline int QStringRef::compare(QLatin1String s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
-{ return QString::compare_helper(constData(), length(), s, cs); }
-inline int QStringRef::compare(const QStringRef &s1, const QString &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
-{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
-inline int QStringRef::compare(const QStringRef &s1, const QStringRef &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
-{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
-inline int QStringRef::compare(const QStringRef &s1, QLatin1String s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
-{ return QString::compare_helper(s1.constData(), s1.length(), s2, cs); }
-
inline int QString::localeAwareCompare(const QStringRef &s) const
{ return localeAwareCompare_helper(constData(), length(), s.constData(), s.length()); }
inline int QString::localeAwareCompare(const QString& s1, const QStringRef& s2)
diff --git a/src/corelib/tools/qstring_mac.mm b/src/corelib/tools/qstring_mac.mm
deleted file mode 100644
index 7b3d6b53c0..0000000000
--- a/src/corelib/tools/qstring_mac.mm
+++ /dev/null
@@ -1,83 +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 "qstring.h"
-
-#import <Foundation/Foundation.h>
-
-QT_BEGIN_NAMESPACE
-
-QString QString::fromCFString(CFStringRef string)
-{
- if (!string)
- return QString();
- CFIndex length = CFStringGetLength(string);
-
- // Fast path: CFStringGetCharactersPtr does not copy but may
- // return null for any and no reason.
- const UniChar *chars = CFStringGetCharactersPtr(string);
- if (chars)
- return QString(reinterpret_cast<const QChar *>(chars), length);
-
- QString ret(length, Qt::Uninitialized);
- CFStringGetCharacters(string, CFRangeMake(0, length), reinterpret_cast<UniChar *>(ret.data()));
- return ret;
-}
-
-CFStringRef QString::toCFString() const
-{
- return CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar *>(unicode()), length());
-}
-
-QString QString::fromNSString(const NSString *string)
-{
- if (!string)
- return QString();
- QString qstring;
- qstring.resize([string length]);
- [string getCharacters: reinterpret_cast<unichar*>(qstring.data()) range: NSMakeRange(0, [string length])];
- return qstring;
-}
-
-NSString *QString::toNSString() const
-{
- return [NSString stringWithCharacters: reinterpret_cast<const UniChar*>(unicode()) length: length()];
-}
-
-QT_END_NAMESPACE
diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h
index e01f9e16e8..87f15528bf 100644
--- a/src/corelib/tools/qstringlist.h
+++ b/src/corelib/tools/qstringlist.h
@@ -149,6 +149,7 @@ public:
Q_DECLARE_TYPEINFO(QStringList, Q_MOVABLE_TYPE);
+#ifndef Q_QDOC
inline QStringList *QListSpecialMethods<QString>::self()
{ return static_cast<QStringList *>(this); }
inline const QStringList *QListSpecialMethods<QString>::self() const
@@ -284,6 +285,7 @@ inline int QStringList::lastIndexOf(const QRegularExpression &rx, int from) cons
}
#endif // QT_NO_REGULAREXPRESSION
#endif // QT_BOOTSTRAPPED
+#endif // Q_QDOC
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qtimezoneprivate_win.cpp b/src/corelib/tools/qtimezoneprivate_win.cpp
index 8e32db48de..4febeda537 100644
--- a/src/corelib/tools/qtimezoneprivate_win.cpp
+++ b/src/corelib/tools/qtimezoneprivate_win.cpp
@@ -383,17 +383,11 @@ static void calculateTransitionsForYear(const QWinTimeZonePrivate::QWinTransitio
static QLocale::Country userCountry()
{
-#if defined(Q_OS_WINCE)
- // Guess that the syslem locale country is the right one to use
- // TODO Find if WinCE has equivalent api
- return QLocale::system().country();
-#else
const GEOID id = GetUserGeoID(GEOCLASS_NATION);
wchar_t code[3];
const int size = GetGeoInfo(id, GEO_ISO2, code, 3, 0);
return (size == 3) ? QLocalePrivate::codeToCountry(reinterpret_cast<const QChar*>(code), size)
: QLocale::AnyCountry;
-#endif // Q_OS_WINCE
}
// Create the system default time zone
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index b64ec756ba..4d77f4e43f 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -133,9 +133,6 @@ false: SOURCES += $$NO_PCH_SOURCES # Hack for QtCreator
SOURCES += tools/qelapsedtimer_mac.cpp
OBJECTIVE_SOURCES += tools/qlocale_mac.mm \
tools/qtimezoneprivate_mac.mm \
- tools/qstring_mac.mm \
- tools/qbytearray_mac.mm \
- tools/qdatetime_mac.mm
}
else:android {
SOURCES += tools/qelapsedtimer_unix.cpp tools/qlocale_unix.cpp tools/qtimezoneprivate_android.cpp
@@ -152,11 +149,11 @@ else:win32 {
} else:integrity:SOURCES += tools/qelapsedtimer_unix.cpp tools/qlocale_unix.cpp
else:SOURCES += tools/qelapsedtimer_generic.cpp
-contains(QT_CONFIG, zlib) {
- include($$PWD/../../3rdparty/zlib.pri)
+contains(QT_CONFIG, system-zlib) {
+ include($$PWD/../../3rdparty/zlib_dependency.pri)
} else {
CONFIG += no_core_dep
- include($$PWD/../../3rdparty/zlib_dependency.pri)
+ include($$PWD/../../3rdparty/zlib.pri)
}
contains(QT_CONFIG,icu) {
@@ -198,12 +195,10 @@ INCLUDEPATH += ../3rdparty/md5 \
../3rdparty/md4 \
../3rdparty/sha3
-contains(QT_CONFIG, doubleconversion) {
- include($$PWD/../../3rdparty/double-conversion/double-conversion.pri)
-} else:contains(QT_CONFIG, system-doubleconversion) {
+contains(QT_CONFIG, system-doubleconversion) {
LIBS_PRIVATE += -ldouble-conversion
-} else {
- DEFINES += QT_NO_DOUBLECONVERSION
+} else: contains(QT_CONFIG, doubleconversion) {
+ include($$PWD/../../3rdparty/double-conversion/double-conversion.pri)
}
# Note: libm should be present by default becaue this is C++