summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/codecs/qlatincodec.cpp18
-rw-r--r--src/corelib/codecs/qtextcodec.cpp11
-rw-r--r--src/corelib/codecs/qutfcodec.cpp6
-rw-r--r--src/corelib/configure.json2
-rw-r--r--src/corelib/corelib.pro1
-rw-r--r--src/corelib/global/qglobal.h30
-rw-r--r--src/corelib/global/qsystemdetection.h9
-rw-r--r--src/corelib/global/qt_pch.h4
-rw-r--r--src/corelib/io/qdir.cpp37
-rw-r--r--src/corelib/io/qdir_p.h6
-rw-r--r--src/corelib/io/qdiriterator.cpp6
-rw-r--r--src/corelib/io/qfile.cpp25
-rw-r--r--src/corelib/io/qfiledevice.cpp14
-rw-r--r--src/corelib/io/qfiledevice_p.h4
-rw-r--r--src/corelib/io/qfileinfo.cpp6
-rw-r--r--src/corelib/io/qfileinfo_p.h8
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp4
-rw-r--r--src/corelib/io/qfilesystemiterator_unix.cpp47
-rw-r--r--src/corelib/io/qfilesystemwatcher_inotify.cpp27
-rw-r--r--src/corelib/io/qfsfileengine.cpp45
-rw-r--r--src/corelib/io/qfsfileengine_p.h10
-rw-r--r--src/corelib/io/qipaddress.cpp2
-rw-r--r--src/corelib/io/qprocess.cpp7
-rw-r--r--src/corelib/io/qprocess_p.h50
-rw-r--r--src/corelib/io/qprocess_unix.cpp2
-rw-r--r--src/corelib/io/qresource.cpp70
-rw-r--r--src/corelib/io/qresource.h5
-rw-r--r--src/corelib/io/qsavefile.cpp37
-rw-r--r--src/corelib/io/qstandardpaths.cpp2
-rw-r--r--src/corelib/io/qstandardpaths_unix.cpp75
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp14
-rw-r--r--src/corelib/io/qtemporaryfile.cpp16
-rw-r--r--src/corelib/io/qtldurl.cpp6
-rw-r--r--src/corelib/io/qurl.cpp2
-rw-r--r--src/corelib/io/qurlidna.cpp5
-rw-r--r--src/corelib/io/qurlquery.cpp10
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp23
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.cpp64
-rw-r--r--src/corelib/kernel/qcore_mac_objc.mm5
-rw-r--r--src/corelib/kernel/qcore_mac_p.h10
-rw-r--r--src/corelib/kernel/qeventdispatcher_winrt_p.h2
-rw-r--r--src/corelib/kernel/qmetaobject.cpp2
-rw-r--r--src/corelib/kernel/qmetaobjectbuilder.cpp12
-rw-r--r--src/corelib/kernel/qmetatype.h2
-rw-r--r--src/corelib/kernel/qobject.cpp28
-rw-r--r--src/corelib/kernel/qobject_p.h9
-rw-r--r--src/corelib/kernel/qobjectdefs.h37
-rw-r--r--src/corelib/kernel/qsignalmapper.cpp8
-rw-r--r--src/corelib/kernel/qsignalmapper.h6
-rw-r--r--src/corelib/kernel/qtranslator.cpp3
-rw-r--r--src/corelib/kernel/qvariant.h2
-rw-r--r--src/corelib/plugin/qpluginloader.cpp2
-rw-r--r--src/corelib/serialization/qcborarray.cpp6
-rw-r--r--src/corelib/serialization/qcborstream.cpp10
-rw-r--r--src/corelib/serialization/qjson.cpp6
-rw-r--r--src/corelib/serialization/qjson_p.h97
-rw-r--r--src/corelib/serialization/qjsonarray.cpp2
-rw-r--r--src/corelib/serialization/qjsoncbor.cpp2
-rw-r--r--src/corelib/serialization/qjsondocument.cpp11
-rw-r--r--src/corelib/serialization/qjsondocument.h3
-rw-r--r--src/corelib/serialization/qjsonobject.cpp307
-rw-r--r--src/corelib/serialization/qjsonobject.h41
-rw-r--r--src/corelib/serialization/qjsonvalue.cpp11
-rw-r--r--src/corelib/serialization/qjsonvalue.h3
-rw-r--r--src/corelib/serialization/qtextstream.cpp2
-rw-r--r--src/corelib/serialization/qxmlstream.cpp6
-rw-r--r--src/corelib/text/UNICODE_LICENSE.txt (renamed from src/corelib/tools/UNICODE_LICENSE.txt)0
-rw-r--r--src/corelib/text/qbytearray.cpp (renamed from src/corelib/tools/qbytearray.cpp)9
-rw-r--r--src/corelib/text/qbytearray.h (renamed from src/corelib/tools/qbytearray.h)0
-rw-r--r--src/corelib/text/qbytearray_p.h (renamed from src/corelib/tools/qbytearray_p.h)2
-rw-r--r--src/corelib/text/qbytearraylist.cpp (renamed from src/corelib/tools/qbytearraylist.cpp)0
-rw-r--r--src/corelib/text/qbytearraylist.h (renamed from src/corelib/tools/qbytearraylist.h)0
-rw-r--r--src/corelib/text/qbytearraymatcher.cpp (renamed from src/corelib/tools/qbytearraymatcher.cpp)0
-rw-r--r--src/corelib/text/qbytearraymatcher.h (renamed from src/corelib/tools/qbytearraymatcher.h)0
-rw-r--r--src/corelib/text/qbytedata_p.h (renamed from src/corelib/tools/qbytedata_p.h)0
-rw-r--r--src/corelib/text/qchar.cpp (renamed from src/corelib/tools/qchar.cpp)18
-rw-r--r--src/corelib/text/qchar.h (renamed from src/corelib/tools/qchar.h)10
-rw-r--r--src/corelib/text/qcollator.cpp (renamed from src/corelib/tools/qcollator.cpp)0
-rw-r--r--src/corelib/text/qcollator.h (renamed from src/corelib/tools/qcollator.h)0
-rw-r--r--src/corelib/text/qcollator_icu.cpp (renamed from src/corelib/tools/qcollator_icu.cpp)0
-rw-r--r--src/corelib/text/qcollator_macx.cpp (renamed from src/corelib/tools/qcollator_macx.cpp)0
-rw-r--r--src/corelib/text/qcollator_p.h (renamed from src/corelib/tools/qcollator_p.h)0
-rw-r--r--src/corelib/text/qcollator_posix.cpp (renamed from src/corelib/tools/qcollator_posix.cpp)0
-rw-r--r--src/corelib/text/qcollator_win.cpp (renamed from src/corelib/tools/qcollator_win.cpp)0
-rw-r--r--src/corelib/text/qdoublescanprint_p.h (renamed from src/corelib/tools/qdoublescanprint_p.h)0
-rw-r--r--src/corelib/text/qharfbuzz.cpp (renamed from src/corelib/tools/qharfbuzz.cpp)0
-rw-r--r--src/corelib/text/qharfbuzz_p.h (renamed from src/corelib/tools/qharfbuzz_p.h)0
-rw-r--r--src/corelib/text/qlocale.cpp (renamed from src/corelib/tools/qlocale.cpp)198
-rw-r--r--src/corelib/text/qlocale.h (renamed from src/corelib/tools/qlocale.h)0
-rw-r--r--src/corelib/text/qlocale.qdoc (renamed from src/corelib/tools/qlocale.qdoc)0
-rw-r--r--src/corelib/text/qlocale_data_p.h (renamed from src/corelib/tools/qlocale_data_p.h)0
-rw-r--r--src/corelib/text/qlocale_icu.cpp (renamed from src/corelib/tools/qlocale_icu.cpp)0
-rw-r--r--src/corelib/text/qlocale_mac.mm (renamed from src/corelib/tools/qlocale_mac.mm)0
-rw-r--r--src/corelib/text/qlocale_p.h (renamed from src/corelib/tools/qlocale_p.h)8
-rw-r--r--src/corelib/text/qlocale_tools.cpp (renamed from src/corelib/tools/qlocale_tools.cpp)0
-rw-r--r--src/corelib/text/qlocale_tools_p.h (renamed from src/corelib/tools/qlocale_tools_p.h)0
-rw-r--r--src/corelib/text/qlocale_unix.cpp (renamed from src/corelib/tools/qlocale_unix.cpp)0
-rw-r--r--src/corelib/text/qlocale_win.cpp (renamed from src/corelib/tools/qlocale_win.cpp)0
-rw-r--r--src/corelib/text/qregexp.cpp (renamed from src/corelib/tools/qregexp.cpp)2
-rw-r--r--src/corelib/text/qregexp.h (renamed from src/corelib/tools/qregexp.h)0
-rw-r--r--src/corelib/text/qregularexpression.cpp (renamed from src/corelib/tools/qregularexpression.cpp)0
-rw-r--r--src/corelib/text/qregularexpression.h (renamed from src/corelib/tools/qregularexpression.h)0
-rw-r--r--src/corelib/text/qstring.cpp (renamed from src/corelib/tools/qstring.cpp)15
-rw-r--r--src/corelib/text/qstring.h (renamed from src/corelib/tools/qstring.h)61
-rw-r--r--src/corelib/text/qstring_compat.cpp (renamed from src/corelib/tools/qstring_compat.cpp)0
-rw-r--r--src/corelib/text/qstring_mips_dsp_asm.S (renamed from src/corelib/tools/qstring_mips_dsp_asm.S)0
-rw-r--r--src/corelib/text/qstringalgorithms.h (renamed from src/corelib/tools/qstringalgorithms.h)11
-rw-r--r--src/corelib/text/qstringalgorithms_p.h (renamed from src/corelib/tools/qstringalgorithms_p.h)0
-rw-r--r--src/corelib/text/qstringbuilder.cpp (renamed from src/corelib/tools/qstringbuilder.cpp)0
-rw-r--r--src/corelib/text/qstringbuilder.h (renamed from src/corelib/tools/qstringbuilder.h)0
-rw-r--r--src/corelib/text/qstringiterator.qdoc (renamed from src/corelib/tools/qstringiterator.qdoc)0
-rw-r--r--src/corelib/text/qstringiterator_p.h (renamed from src/corelib/tools/qstringiterator_p.h)0
-rw-r--r--src/corelib/text/qstringlist.cpp (renamed from src/corelib/tools/qstringlist.cpp)0
-rw-r--r--src/corelib/text/qstringlist.h (renamed from src/corelib/tools/qstringlist.h)0
-rw-r--r--src/corelib/text/qstringliteral.h (renamed from src/corelib/tools/qstringliteral.h)0
-rw-r--r--src/corelib/text/qstringmatcher.cpp (renamed from src/corelib/tools/qstringmatcher.cpp)0
-rw-r--r--src/corelib/text/qstringmatcher.h (renamed from src/corelib/tools/qstringmatcher.h)0
-rw-r--r--src/corelib/text/qstringview.cpp (renamed from src/corelib/tools/qstringview.cpp)27
-rw-r--r--src/corelib/text/qstringview.h (renamed from src/corelib/tools/qstringview.h)8
-rw-r--r--src/corelib/text/qt_attribution.json (renamed from src/corelib/tools/qt_attribution.json)0
-rw-r--r--src/corelib/text/qtextboundaryfinder.cpp (renamed from src/corelib/tools/qtextboundaryfinder.cpp)0
-rw-r--r--src/corelib/text/qtextboundaryfinder.h (renamed from src/corelib/tools/qtextboundaryfinder.h)0
-rw-r--r--src/corelib/text/qunicodetables.cpp (renamed from src/corelib/tools/qunicodetables.cpp)0
-rw-r--r--src/corelib/text/qunicodetables_p.h (renamed from src/corelib/tools/qunicodetables_p.h)0
-rw-r--r--src/corelib/text/qunicodetools.cpp (renamed from src/corelib/tools/qunicodetools.cpp)0
-rw-r--r--src/corelib/text/qunicodetools_p.h (renamed from src/corelib/tools/qunicodetools_p.h)0
-rw-r--r--src/corelib/text/qvsnprintf.cpp (renamed from src/corelib/tools/qvsnprintf.cpp)0
-rw-r--r--src/corelib/text/text.pri100
-rw-r--r--src/corelib/thread/qmutexpool.cpp151
-rw-r--r--src/corelib/thread/qmutexpool_p.h88
-rw-r--r--src/corelib/thread/qorderedmutexlocker_p.h2
-rw-r--r--src/corelib/thread/qthread.cpp8
-rw-r--r--src/corelib/thread/thread.pri2
-rw-r--r--src/corelib/time/qdatetime.cpp49
-rw-r--r--src/corelib/tools/qalgorithms.qdoc4
-rw-r--r--src/corelib/tools/qarraydatapointer.h13
-rw-r--r--src/corelib/tools/qcontainerfwd.h2
-rw-r--r--src/corelib/tools/qeasingcurve.cpp4
-rw-r--r--src/corelib/tools/qhash.h38
-rw-r--r--src/corelib/tools/qlinkedlist.cpp4
-rw-r--r--src/corelib/tools/qlinkedlist.h8
-rw-r--r--src/corelib/tools/qshareddata.h16
-rw-r--r--src/corelib/tools/qtimeline.cpp35
-rw-r--r--src/corelib/tools/qvarlengtharray.h4
-rw-r--r--src/corelib/tools/qvector.h2
-rw-r--r--src/corelib/tools/tools.pri88
146 files changed, 1296 insertions, 1036 deletions
diff --git a/src/corelib/codecs/qlatincodec.cpp b/src/corelib/codecs/qlatincodec.cpp
index 463c5a56ae..55e6f0ba4d 100644
--- a/src/corelib/codecs/qlatincodec.cpp
+++ b/src/corelib/codecs/qlatincodec.cpp
@@ -62,7 +62,7 @@ QByteArray QLatin1Codec::convertFromUnicode(const QChar *ch, int len, ConverterS
char *d = r.data();
int invalid = 0;
for (int i = 0; i < len; ++i) {
- if (ch[i] > 0xff) {
+ if (ch[i] > QChar(0xff)) {
d[i] = replacement;
++invalid;
} else {
@@ -112,28 +112,28 @@ QString QLatin15Codec::convertToUnicode(const char* chars, int len, ConverterSta
while(len--) {
switch(uc->unicode()) {
case 0xa4:
- *uc = 0x20ac;
+ *uc = QChar(0x20ac);
break;
case 0xa6:
- *uc = 0x0160;
+ *uc = QChar(0x0160);
break;
case 0xa8:
- *uc = 0x0161;
+ *uc = QChar(0x0161);
break;
case 0xb4:
- *uc = 0x017d;
+ *uc = QChar(0x017d);
break;
case 0xb8:
- *uc = 0x017e;
+ *uc = QChar(0x017e);
break;
case 0xbc:
- *uc = 0x0152;
+ *uc = QChar(0x0152);
break;
case 0xbd:
- *uc = 0x0153;
+ *uc = QChar(0x0153);
break;
case 0xbe:
- *uc = 0x0178;
+ *uc = QChar(0x0178);
break;
default:
break;
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 85cfcdbf48..8639e4f2f0 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -544,11 +544,9 @@ QTextCodec *QTextCodec::codecForName(const QByteArray &name)
#if !QT_CONFIG(icu)
QTextCodecCache *cache = &globalData->codecCache;
QTextCodec *codec;
- if (cache) {
- codec = cache->value(name);
- if (codec)
- return codec;
- }
+ codec = cache->value(name);
+ if (codec)
+ return codec;
for (TextCodecListConstIt it = globalData->allCodecs.constBegin(), cend = globalData->allCodecs.constEnd(); it != cend; ++it) {
QTextCodec *cursor = *it;
@@ -560,8 +558,7 @@ QTextCodec *QTextCodec::codecForName(const QByteArray &name)
QList<QByteArray> aliases = cursor->aliases();
for (ByteArrayListConstIt ait = aliases.constBegin(), acend = aliases.constEnd(); ait != acend; ++ait) {
if (qTextCodecNameMatch(*ait, name)) {
- if (cache)
- cache->insert(name, cursor);
+ cache->insert(name, cursor);
return cursor;
}
}
diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp
index 85736fdf02..af36bd7e2f 100644
--- a/src/corelib/codecs/qutfcodec.cpp
+++ b/src/corelib/codecs/qutfcodec.cpp
@@ -951,10 +951,10 @@ QString QUtf32::convertToUnicode(const char *chars, int len, QTextCodec::Convert
}
uint code = (endian == BigEndianness) ? qFromBigEndian<quint32>(tuple) : qFromLittleEndian<quint32>(tuple);
if (QChar::requiresSurrogates(code)) {
- *qch++ = QChar::highSurrogate(code);
- *qch++ = QChar::lowSurrogate(code);
+ *qch++ = QChar(QChar::highSurrogate(code));
+ *qch++ = QChar(QChar::lowSurrogate(code));
} else {
- *qch++ = code;
+ *qch++ = QChar(code);
}
num = 0;
}
diff --git a/src/corelib/configure.json b/src/corelib/configure.json
index 88c7bbfbed..83c30fb47b 100644
--- a/src/corelib/configure.json
+++ b/src/corelib/configure.json
@@ -596,7 +596,7 @@
"qDoubleSnprintf(argv[0], 1, invalidLocale, \"invalid format\", a);",
"qDoubleSscanf(argv[0], invalidLocale, \"invalid format\", &a, &argc);"
],
- "qmake": "DEFINES += QDSP_P_H=$$shell_quote(\\\"@PWD@/tools/qdoublescanprint_p.h\\\")"
+ "qmake": "DEFINES += QDSP_P_H=$$shell_quote(\\\"@PWD@/text/qdoublescanprint_p.h\\\")"
}
}
},
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index 521f840292..b9bcc70e17 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -36,6 +36,7 @@ qtConfig(animation): include(animation/animation.pri)
include(global/global.pri)
include(thread/thread.pri)
include(tools/tools.pri)
+include(text/text.pri)
include(time/time.pri)
include(io/io.pri)
include(itemmodels/itemmodels.pri)
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index f85824c7b3..736378508f 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
+** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2019 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -613,7 +613,8 @@ using qsizetype = QIntegerForSizeof<std::size_t>::Signed;
# define Q_ALWAYS_INLINE inline
#endif
-#if defined(Q_CC_GNU) && defined(Q_OS_WIN)
+#if defined(Q_CC_GNU) && defined(Q_OS_WIN) && !defined(QT_NO_DATA_RELOCATION)
+// ### Qt6: you can remove me
# define QT_INIT_METAOBJECT __attribute__((init_priority(101)))
#else
# define QT_INIT_METAOBJECT
@@ -1002,6 +1003,29 @@ QT_WARNING_DISABLE_MSVC(4530) /* C++ exception handler used, but unwind semantic
# endif
#endif
+// Work around MSVC warning about use of 3-arg algorithms
+// until we can depend on the C++14 4-arg ones.
+//
+// These algortithms do NOT check for equal length.
+// They need to be treated as if they called the 3-arg version (which they do)!
+#ifdef Q_CC_MSVC
+# define QT_3ARG_ALG(alg, f1, l1, f2, l2) \
+ std::alg(f1, l1, f2, l2)
+#else
+# define QT_3ARG_ALG(alg, f1, l1, f2, l2) \
+ [&f1, &l1, &f2, &l2]() { \
+ Q_UNUSED(l2); \
+ return std::alg(f1, l1, f2); \
+ }()
+#endif
+template <typename ForwardIterator1, typename ForwardIterator2>
+inline bool qt_is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
+ ForwardIterator2 first2, ForwardIterator2 last2)
+{
+ return QT_3ARG_ALG(is_permutation, first1, last1, first2, last2);
+}
+#undef QT_3ARG_ALG
+
// this adds const to non-const objects (like std::as_const)
template <typename T>
Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) noexcept { return t; }
diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h
index 02e2f77c6b..4ebbe16ead 100644
--- a/src/corelib/global/qsystemdetection.h
+++ b/src/corelib/global/qsystemdetection.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2019 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -180,6 +181,12 @@
#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINRT)
# define Q_OS_WINDOWS
# define Q_OS_WIN
+# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+// On Windows, pointers to dllimport'ed variables are not constant expressions,
+// so to keep to certain initializations (like QMetaObject) constexpr, we need
+// to use functions instead.
+# define QT_NO_DATA_RELOCATION
+# endif
#endif
#if defined(Q_OS_WIN)
diff --git a/src/corelib/global/qt_pch.h b/src/corelib/global/qt_pch.h
index 3972991618..0dfd6c745f 100644
--- a/src/corelib/global/qt_pch.h
+++ b/src/corelib/global/qt_pch.h
@@ -55,6 +55,10 @@
#include <stdlib.h>
#include <qglobal.h>
#ifdef Q_OS_WIN
+# ifdef Q_CC_MINGW
+// <unistd.h> must be included before any other header pulls in <time.h>.
+# include <unistd.h> // Define _POSIX_THREAD_SAFE_FUNCTIONS to obtain localtime_r()
+# endif
# define _POSIX_
# include <limits.h>
# undef _POSIX_
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 62dae3577c..fae935fc24 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -153,7 +153,7 @@ QDirPrivate::QDirPrivate(const QDirPrivate &copy)
bool QDirPrivate::exists() const
{
- if (fileEngine.isNull()) {
+ if (!fileEngine) {
QFileSystemEngine::fillMetaData(dirEntry, metaData,
QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType); // always stat
return metaData.exists() && metaData.isDirectory();
@@ -226,7 +226,7 @@ inline void QDirPrivate::resolveAbsoluteEntry() const
return;
QString absoluteName;
- if (fileEngine.isNull()) {
+ if (!fileEngine) {
if (!dirEntry.isRelative() && dirEntry.isClean()) {
absoluteDirEntry = dirEntry;
return;
@@ -693,7 +693,7 @@ QString QDir::absolutePath() const
QString QDir::canonicalPath() const
{
const QDirPrivate* d = d_ptr.constData();
- if (d->fileEngine.isNull()) {
+ if (!d->fileEngine) {
QFileSystemEntry answer = QFileSystemEngine::canonicalName(d->dirEntry, d->metaData);
return answer.filePath();
}
@@ -947,6 +947,12 @@ QString QDir::fromNativeSeparators(const QString &pathName)
int i = pathName.indexOf(QLatin1Char('\\'));
if (i != -1) {
QString n(pathName);
+ if (n.startsWith(QLatin1String("\\\\?\\"))) {
+ n.remove(0, 4);
+ i = n.indexOf(QLatin1Char('\\'));
+ if (i == -1)
+ return n;
+ }
QChar * const data = n.data();
data[i++] = QLatin1Char('/');
@@ -1496,7 +1502,7 @@ bool QDir::mkdir(const QString &dirName) const
}
QString fn = filePath(dirName);
- if (d->fileEngine.isNull())
+ if (!d->fileEngine)
return QFileSystemEngine::createDirectory(QFileSystemEntry(fn), false);
return d->fileEngine->mkdir(fn, false);
}
@@ -1520,7 +1526,7 @@ bool QDir::rmdir(const QString &dirName) const
}
QString fn = filePath(dirName);
- if (d->fileEngine.isNull())
+ if (!d->fileEngine)
return QFileSystemEngine::removeDirectory(QFileSystemEntry(fn), false);
return d->fileEngine->rmdir(fn, false);
@@ -1548,7 +1554,7 @@ bool QDir::mkpath(const QString &dirPath) const
}
QString fn = filePath(dirPath);
- if (d->fileEngine.isNull())
+ if (!d->fileEngine)
return QFileSystemEngine::createDirectory(QFileSystemEntry(fn), true);
return d->fileEngine->mkdir(fn, true);
}
@@ -1574,7 +1580,7 @@ bool QDir::rmpath(const QString &dirPath) const
}
QString fn = filePath(dirPath);
- if (d->fileEngine.isNull())
+ if (!d->fileEngine)
return QFileSystemEngine::removeDirectory(QFileSystemEntry(fn), true);
return d->fileEngine->rmdir(fn, true);
}
@@ -1647,7 +1653,7 @@ bool QDir::isReadable() const
{
const QDirPrivate* d = d_ptr.constData();
- if (d->fileEngine.isNull()) {
+ if (!d->fileEngine) {
if (!d->metaData.hasFlags(QFileSystemMetaData::UserReadPermission))
QFileSystemEngine::fillMetaData(d->dirEntry, d->metaData, QFileSystemMetaData::UserReadPermission);
@@ -1692,7 +1698,7 @@ bool QDir::exists() const
*/
bool QDir::isRoot() const
{
- if (d_ptr->fileEngine.isNull())
+ if (!d_ptr->fileEngine)
return d_ptr->dirEntry.isRoot();
return d_ptr->fileEngine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::RootFlag;
}
@@ -1724,7 +1730,7 @@ bool QDir::isRoot() const
*/
bool QDir::isRelative() const
{
- if (d_ptr->fileEngine.isNull())
+ if (!d_ptr->fileEngine)
return d_ptr->dirEntry.isRelative();
return d_ptr->fileEngine->isRelativePath();
}
@@ -1741,7 +1747,7 @@ bool QDir::makeAbsolute()
{
const QDirPrivate *d = d_ptr.constData();
QScopedPointer<QDirPrivate> dir;
- if (!d->fileEngine.isNull()) {
+ if (!!d->fileEngine) {
QString absolutePath = d->fileEngine->fileName(QAbstractFileEngine::AbsoluteName);
if (QDir::isRelativePath(absolutePath))
return false;
@@ -1774,8 +1780,8 @@ bool QDir::operator==(const QDir &dir) const
if (d == other)
return true;
Qt::CaseSensitivity sensitive;
- if (d->fileEngine.isNull() || other->fileEngine.isNull()) {
- if (d->fileEngine.data() != other->fileEngine.data()) // one is native, the other is a custom file-engine
+ if (!d->fileEngine || !other->fileEngine) {
+ if (d->fileEngine.get() != other->fileEngine.get()) // one is native, the other is a custom file-engine
return false;
sensitive = QFileSystemEngine::isCaseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive;
@@ -2339,6 +2345,11 @@ static QString qt_cleanPath(const QString &path, bool *ok)
if (path.isEmpty())
return path;
QString name = path;
+#if defined (Q_OS_WIN)
+ if (name.startsWith(QLatin1String("\\\\?\\")))
+ name.remove(0, 4);
+#endif
+
QChar dir_separator = QDir::separator();
if (dir_separator != QLatin1Char('/'))
name.replace(dir_separator, QLatin1Char('/'));
diff --git a/src/corelib/io/qdir_p.h b/src/corelib/io/qdir_p.h
index 0f3ab7f899..af105de8db 100644
--- a/src/corelib/io/qdir_p.h
+++ b/src/corelib/io/qdir_p.h
@@ -54,6 +54,8 @@
#include "qfilesystementry_p.h"
#include "qfilesystemmetadata_p.h"
+#include <memory>
+
QT_BEGIN_NAMESPACE
class QDirPrivate : public QSharedData
@@ -82,7 +84,7 @@ public:
static inline QChar getFilterSepChar(const QString &nameFilter);
- static inline QStringList splitFilters(const QString &nameFilter, QChar sep = 0);
+ static inline QStringList splitFilters(const QString &nameFilter, QChar sep = {});
void setPath(const QString &path);
@@ -98,7 +100,7 @@ public:
QDir::SortFlags sort;
QDir::Filters filters;
- QScopedPointer<QAbstractFileEngine> fileEngine;
+ std::unique_ptr<QAbstractFileEngine> fileEngine;
QFileSystemEntry dirEntry;
mutable QFileSystemEntry absoluteDirEntry;
diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp
index 303caf29a4..ce436b06e3 100644
--- a/src/corelib/io/qdiriterator.cpp
+++ b/src/corelib/io/qdiriterator.cpp
@@ -107,6 +107,8 @@
#include <QtCore/private/qfilesystemengine_p.h>
#include <QtCore/private/qfileinfo_p.h>
+#include <memory>
+
QT_BEGIN_NAMESPACE
template <class Iterator>
@@ -132,7 +134,7 @@ public:
void checkAndPushDirectory(const QFileInfo &);
bool matchesFilters(const QString &fileName, const QFileInfo &fi) const;
- QScopedPointer<QAbstractFileEngine> engine;
+ std::unique_ptr<QAbstractFileEngine> engine;
QFileSystemEntry dirEntry;
const QStringList nameFilters;
@@ -435,7 +437,7 @@ bool QDirIteratorPrivate::matchesFilters(const QString &fileName, const QFileInf
QDirIterator::QDirIterator(const QDir &dir, IteratorFlags flags)
{
const QDirPrivate *other = dir.d_ptr.constData();
- d.reset(new QDirIteratorPrivate(other->dirEntry, other->nameFilters, other->filters, flags, !other->fileEngine.isNull()));
+ d.reset(new QDirIteratorPrivate(other->dirEntry, other->nameFilters, other->filters, flags, bool(other->fileEngine)));
}
/*!
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index 9f9a9e3040..95f03ef816 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -55,6 +55,8 @@
# include "qcoreapplication.h"
#endif
+#include <private/qmemory_p.h>
+
#ifdef QT_NO_QOBJECT
#define tr(X) QString::fromLatin1(X)
#endif
@@ -85,10 +87,9 @@ QFilePrivate::openExternalFile(int flags, int fd, QFile::FileHandleFlags handleF
Q_UNUSED(fd);
return false;
#else
- delete fileEngine;
- fileEngine = nullptr;
- QFSFileEngine *fe = new QFSFileEngine;
- fileEngine = fe;
+ auto fs = qt_make_unique<QFSFileEngine>();
+ auto fe = fs.get();
+ fileEngine = std::move(fs);
return fe->open(QIODevice::OpenMode(flags), fd, handleFlags);
#endif
}
@@ -101,10 +102,9 @@ QFilePrivate::openExternalFile(int flags, FILE *fh, QFile::FileHandleFlags handl
Q_UNUSED(fh);
return false;
#else
- delete fileEngine;
- fileEngine = nullptr;
- QFSFileEngine *fe = new QFSFileEngine;
- fileEngine = fe;
+ auto fs = qt_make_unique<QFSFileEngine>();
+ auto fe = fs.get();
+ fileEngine = std::move(fs);
return fe->open(QIODevice::OpenMode(flags), fh, handleFlags);
#endif
}
@@ -112,8 +112,8 @@ QFilePrivate::openExternalFile(int flags, FILE *fh, QFile::FileHandleFlags handl
QAbstractFileEngine *QFilePrivate::engine() const
{
if (!fileEngine)
- fileEngine = QAbstractFileEngine::create(fileName);
- return fileEngine;
+ fileEngine.reset(QAbstractFileEngine::create(fileName));
+ return fileEngine.get();
}
//************* QFile
@@ -334,10 +334,7 @@ QFile::setFileName(const QString &name)
file_already_open(*this, "setFileName");
close();
}
- if(d->fileEngine) { //get a new file engine later
- delete d->fileEngine;
- d->fileEngine = nullptr;
- }
+ d->fileEngine.reset(); //get a new file engine later
d->fileName = name;
}
diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp
index 2f74547054..ee619d99cc 100644
--- a/src/corelib/io/qfiledevice.cpp
+++ b/src/corelib/io/qfiledevice.cpp
@@ -42,6 +42,8 @@
#include "qfiledevice_p.h"
#include "qfsfileengine_p.h"
+#include <private/qmemory_p.h>
+
#ifdef QT_NO_QOBJECT
#define tr(X) QString::fromLatin1(X)
#endif
@@ -53,24 +55,20 @@ QT_BEGIN_NAMESPACE
#endif
QFileDevicePrivate::QFileDevicePrivate()
- : fileEngine(nullptr),
- cachedSize(0),
+ : cachedSize(0),
error(QFile::NoError), lastWasWrite(false)
{
writeBufferChunkSize = QFILE_WRITEBUFFER_SIZE;
}
QFileDevicePrivate::~QFileDevicePrivate()
-{
- delete fileEngine;
- fileEngine = nullptr;
-}
+ = default;
QAbstractFileEngine * QFileDevicePrivate::engine() const
{
if (!fileEngine)
- fileEngine = new QFSFileEngine;
- return fileEngine;
+ fileEngine = qt_make_unique<QFSFileEngine>();
+ return fileEngine.get();
}
void QFileDevicePrivate::setError(QFileDevice::FileError err)
diff --git a/src/corelib/io/qfiledevice_p.h b/src/corelib/io/qfiledevice_p.h
index 47053d01b7..aef3fca811 100644
--- a/src/corelib/io/qfiledevice_p.h
+++ b/src/corelib/io/qfiledevice_p.h
@@ -53,6 +53,8 @@
#include "private/qiodevice_p.h"
+#include <memory>
+
QT_BEGIN_NAMESPACE
class QAbstractFileEngine;
@@ -75,7 +77,7 @@ protected:
void setError(QFileDevice::FileError err, const QString &errorString);
void setError(QFileDevice::FileError err, int errNum);
- mutable QAbstractFileEngine *fileEngine;
+ mutable std::unique_ptr<QAbstractFileEngine> fileEngine;
mutable qint64 cachedSize;
QFileDevice::FileHandleFlags handleFlags;
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index f5b398feae..a5a3bc8b3e 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -707,11 +707,11 @@ bool QFileInfo::exists(const QString &file)
return false;
QFileSystemEntry entry(file);
QFileSystemMetaData data;
- QAbstractFileEngine *engine =
- QFileSystemEngine::resolveEntryAndCreateLegacyEngine(entry, data);
+ std::unique_ptr<QAbstractFileEngine> engine
+ {QFileSystemEngine::resolveEntryAndCreateLegacyEngine(entry, data)};
// Expensive fallback to non-QFileSystemEngine implementation
if (engine)
- return QFileInfo(new QFileInfoPrivate(entry, data, engine)).exists();
+ return QFileInfo(new QFileInfoPrivate(entry, data, std::move(engine))).exists();
QFileSystemEngine::fillMetaData(entry, data, QFileSystemMetaData::ExistsAttribute);
return data.exists();
diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h
index 36f440812f..333ea70adc 100644
--- a/src/corelib/io/qfileinfo_p.h
+++ b/src/corelib/io/qfileinfo_p.h
@@ -61,6 +61,8 @@
#include <QtCore/private/qfilesystementry_p.h>
#include <QtCore/private/qfilesystemmetadata_p.h>
+#include <memory>
+
QT_BEGIN_NAMESPACE
class QFileInfoPrivate : public QSharedData
@@ -126,10 +128,10 @@ public:
metaData = QFileSystemMetaData();
}
- inline QFileInfoPrivate(const QFileSystemEntry &file, const QFileSystemMetaData &data, QAbstractFileEngine *engine)
+ inline QFileInfoPrivate(const QFileSystemEntry &file, const QFileSystemMetaData &data, std::unique_ptr<QAbstractFileEngine> engine)
: fileEntry(file),
metaData(data),
- fileEngine(engine),
+ fileEngine{std::move(engine)},
cachedFlags(0),
#ifndef QT_NO_FSFILEENGINE
isDefaultConstructed(false),
@@ -163,7 +165,7 @@ public:
QFileSystemEntry fileEntry;
mutable QFileSystemMetaData metaData;
- QScopedPointer<QAbstractFileEngine> const fileEngine;
+ std::unique_ptr<QAbstractFileEngine> const fileEngine;
mutable QString fileNames[QAbstractFileEngine::NFileNames];
mutable QString fileOwners[2]; // QAbstractFileEngine::FileOwner: OwnerUser and OwnerGroup
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 066a7c3f01..74865fe31f 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -822,6 +822,8 @@ QString QFileSystemEngine::resolveUserName(uint userId)
#endif
if (pw)
return QFile::decodeName(QByteArray(pw->pw_name));
+#else // Integrity || WASM
+ Q_UNUSED(userId);
#endif
return QString();
}
@@ -859,6 +861,8 @@ QString QFileSystemEngine::resolveGroupName(uint groupId)
#endif
if (gr)
return QFile::decodeName(QByteArray(gr->gr_name));
+#else // Integrity || WASM
+ Q_UNUSED(groupId);
#endif
return QString();
}
diff --git a/src/corelib/io/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp
index 5ac7e13a2e..2d09c277eb 100644
--- a/src/corelib/io/qfilesystemiterator_unix.cpp
+++ b/src/corelib/io/qfilesystemiterator_unix.cpp
@@ -40,13 +40,54 @@
#include "qplatformdefs.h"
#include "qfilesystemiterator_p.h"
+#if QT_CONFIG(textcodec)
+# include <qtextcodec.h>
+# include <private/qutfcodec_p.h>
+#endif
+
#ifndef QT_NO_FILESYSTEMITERATOR
+#include <memory>
+
#include <stdlib.h>
#include <errno.h>
QT_BEGIN_NAMESPACE
+static bool checkNameDecodable(const char *d_name, qsizetype len)
+{
+ // This function is called in a loop from advance() below, but the loop is
+ // usually run only once.
+
+#if QT_CONFIG(textcodec)
+ // We identify the codecs by their RFC 2978 MIBenum values. In this
+ // function:
+ // 3 US-ASCII (ANSI X3.4-1986)
+ // 4 Latin1 (ISO-8859-1)
+ // 106 UTF-8
+ QTextCodec *codec = QTextCodec::codecForLocale();
+# ifdef QT_LOCALE_IS_UTF8
+ int mibEnum = 106;
+# else
+ int mibEnum = codec->mibEnum();
+# endif
+ if (Q_LIKELY(mibEnum == 106)) // UTF-8
+ return QUtf8::isValidUtf8(d_name, len).isValidUtf8;
+ if (mibEnum == 3) // US-ASCII
+ return QtPrivate::isAscii(QLatin1String(d_name, len));
+ if (mibEnum == 4) // Latin 1
+ return true;
+
+ // fall back to generic QTextCodec
+ QTextCodec::ConverterState cs(QTextCodec::IgnoreHeader);
+ codec->toUnicode(d_name, len, &cs);
+ return cs.invalidChars == 0 && cs.remainingChars == 0;
+#else
+ // if we have no text codecs, then QString::fromLocal8Bit is fromLatin1
+ return true;
+#endif
+}
+
QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters,
const QStringList &nameFilters, QDirIterator::IteratorFlags flags)
: nativePath(entry.nativeFilePath())
@@ -81,9 +122,9 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa
dirEntry = QT_READDIR(dir);
if (dirEntry) {
- // process entries with correct UTF-8 names only
- if (QFile::encodeName(QFile::decodeName(dirEntry->d_name)) == dirEntry->d_name) {
- fileEntry = QFileSystemEntry(nativePath + QByteArray(dirEntry->d_name), QFileSystemEntry::FromNativePath());
+ qsizetype len = strlen(dirEntry->d_name);
+ if (checkNameDecodable(dirEntry->d_name, len)) {
+ fileEntry = QFileSystemEntry(nativePath + QByteArray(dirEntry->d_name, len), QFileSystemEntry::FromNativePath());
metaData.fillFromDirEnt(*dirEntry);
return true;
}
diff --git a/src/corelib/io/qfilesystemwatcher_inotify.cpp b/src/corelib/io/qfilesystemwatcher_inotify.cpp
index 5fb5685f42..ca1f6cc359 100644
--- a/src/corelib/io/qfilesystemwatcher_inotify.cpp
+++ b/src/corelib/io/qfilesystemwatcher_inotify.cpp
@@ -422,16 +422,27 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
}
}
-QString QInotifyFileSystemWatcherEngine::getPathFromID(int id) const
+template <typename Hash, typename Key>
+typename Hash::const_iterator
+find_last_in_equal_range(const Hash &c, const Key &key)
{
- QHash<int, QString>::const_iterator i = idToPath.find(id);
- while (i != idToPath.constEnd() && i.key() == id) {
- if ((i + 1) == idToPath.constEnd() || (i + 1).key() != id) {
- return i.value();
- }
+ // find c.equal_range(key).second - 1 without backwards iteration:
+ auto i = c.find(key);
+ const auto end = c.cend();
+ if (i == end)
+ return end;
+ decltype(i) prev;
+ do {
+ prev = i;
++i;
- }
- return QString();
+ } while (i != end && i.key() == key);
+ return prev;
+}
+
+QString QInotifyFileSystemWatcherEngine::getPathFromID(int id) const
+{
+ auto i = find_last_in_equal_range(idToPath, id);
+ return i == idToPath.cend() ? QString() : i.value() ;
}
QT_END_NAMESPACE
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp
index 0db27f3e25..0d73839f8d 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -167,19 +167,21 @@ QFSFileEngine::QFSFileEngine(QFSFileEnginePrivate &dd)
/*!
\internal
*/
-bool QFSFileEngine::processOpenModeFlags(QIODevice::OpenMode *mode)
+ProcessOpenModeResult processOpenModeFlags(QIODevice::OpenMode openMode)
{
- QIODevice::OpenMode &openMode = *mode;
+ ProcessOpenModeResult result;
+ result.ok = false;
if ((openMode & QFile::NewOnly) && (openMode & QFile::ExistingOnly)) {
qWarning("NewOnly and ExistingOnly are mutually exclusive");
- setError(QFile::OpenError, QLatin1String("NewOnly and ExistingOnly are mutually exclusive"));
- return false;
+ result.error = QLatin1String("NewOnly and ExistingOnly are mutually exclusive");
+ return result;
}
if ((openMode & QFile::ExistingOnly) && !(openMode & (QFile::ReadOnly | QFile::WriteOnly))) {
qWarning("ExistingOnly must be specified alongside ReadOnly, WriteOnly, or ReadWrite");
- setError(QFile::OpenError, QLatin1String("ExistingOnly must be specified alongside ReadOnly, WriteOnly, or ReadWrite"));
- return false;
+ result.error = QLatin1String(
+ "ExistingOnly must be specified alongside ReadOnly, WriteOnly, or ReadWrite");
+ return result;
}
// Either Append or NewOnly implies WriteOnly
@@ -190,7 +192,9 @@ bool QFSFileEngine::processOpenModeFlags(QIODevice::OpenMode *mode)
if ((openMode & QFile::WriteOnly) && !(openMode & (QFile::ReadOnly | QFile::Append | QFile::NewOnly)))
openMode |= QFile::Truncate;
- return true;
+ result.ok = true;
+ result.openMode = openMode;
+ return result;
}
/*!
@@ -234,16 +238,19 @@ bool QFSFileEngine::open(QIODevice::OpenMode openMode)
return false;
}
- if (!processOpenModeFlags(&openMode))
+ const ProcessOpenModeResult res = processOpenModeFlags(openMode);
+ if (!res.ok) {
+ setError(QFileDevice::OpenError, res.error);
return false;
+ }
- d->openMode = openMode;
+ d->openMode = res.openMode;
d->lastFlushFailed = false;
d->tried_stat = 0;
d->fh = nullptr;
d->fd = -1;
- return d->nativeOpen(openMode);
+ return d->nativeOpen(d->openMode);
}
/*!
@@ -262,17 +269,20 @@ bool QFSFileEngine::open(QIODevice::OpenMode openMode, FILE *fh, QFile::FileHand
Q_D(QFSFileEngine);
- if (!processOpenModeFlags(&openMode))
+ const ProcessOpenModeResult res = processOpenModeFlags(openMode);
+ if (!res.ok) {
+ setError(QFileDevice::OpenError, res.error);
return false;
+ }
- d->openMode = openMode;
+ d->openMode = res.openMode;
d->lastFlushFailed = false;
d->closeFileHandle = (handleFlags & QFile::AutoCloseHandle);
d->fileEntry.clear();
d->tried_stat = 0;
d->fd = -1;
- return d->openFh(openMode, fh);
+ return d->openFh(d->openMode, fh);
}
/*!
@@ -321,10 +331,13 @@ bool QFSFileEngine::open(QIODevice::OpenMode openMode, int fd, QFile::FileHandle
{
Q_D(QFSFileEngine);
- if (!processOpenModeFlags(&openMode))
+ const ProcessOpenModeResult res = processOpenModeFlags(openMode);
+ if (!res.ok) {
+ setError(QFileDevice::OpenError, res.error);
return false;
+ }
- d->openMode = openMode;
+ d->openMode = res.openMode;
d->lastFlushFailed = false;
d->closeFileHandle = (handleFlags & QFile::AutoCloseHandle);
d->fileEntry.clear();
@@ -332,7 +345,7 @@ bool QFSFileEngine::open(QIODevice::OpenMode openMode, int fd, QFile::FileHandle
d->fd = -1;
d->tried_stat = 0;
- return d->openFd(openMode, fd);
+ return d->openFd(d->openMode, fd);
}
diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h
index 0f416f4886..639c01571a 100644
--- a/src/corelib/io/qfsfileengine_p.h
+++ b/src/corelib/io/qfsfileengine_p.h
@@ -61,6 +61,13 @@
QT_BEGIN_NAMESPACE
+struct ProcessOpenModeResult {
+ bool ok;
+ QIODevice::OpenMode openMode;
+ QString error;
+};
+Q_CORE_EXPORT ProcessOpenModeResult processOpenModeFlags(QIODevice::OpenMode mode);
+
class QFSFileEnginePrivate;
class Q_CORE_EXPORT QFSFileEngine : public QAbstractFileEngine
@@ -131,9 +138,6 @@ public:
protected:
QFSFileEngine(QFSFileEnginePrivate &dd);
-
-private:
- inline bool processOpenModeFlags(QIODevice::OpenMode *mode);
};
class Q_AUTOTEST_EXPORT QFSFileEnginePrivate : public QAbstractFileEnginePrivate
diff --git a/src/corelib/io/qipaddress.cpp b/src/corelib/io/qipaddress.cpp
index b3421fca8f..ddc5b6607f 100644
--- a/src/corelib/io/qipaddress.cpp
+++ b/src/corelib/io/qipaddress.cpp
@@ -312,7 +312,7 @@ void toString(QString &appendTo, const IPv6Address address)
}
}
- const QChar colon = ushort(':');
+ const QChar colon = u':';
if (zeroRunLength < 4)
zeroRunOffset = -1;
else if (zeroRunOffset == 0)
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 0b964e6a21..35ca2542f7 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -202,6 +202,7 @@ void QProcessEnvironmentPrivate::insert(const QProcessEnvironmentPrivate &other)
vars.insert(it.key(), it.value());
#ifdef Q_OS_UNIX
+ const OrderedNameMapMutexLocker locker(this, &other);
auto nit = other.nameMap.constBegin();
const auto nend = other.nameMap.constEnd();
for ( ; nit != nend; ++nit)
@@ -275,7 +276,6 @@ bool QProcessEnvironment::operator==(const QProcessEnvironment &other) const
return true;
if (d) {
if (other.d) {
- QProcessEnvironmentPrivate::OrderedMutexLocker locker(d, other.d);
return d->vars == other.d->vars;
} else {
return isEmpty();
@@ -322,7 +322,6 @@ bool QProcessEnvironment::contains(const QString &name) const
{
if (!d)
return false;
- QProcessEnvironmentPrivate::MutexLocker locker(d);
return d->vars.contains(d->prepareName(name));
}
@@ -373,7 +372,6 @@ QString QProcessEnvironment::value(const QString &name, const QString &defaultVa
if (!d)
return defaultValue;
- QProcessEnvironmentPrivate::MutexLocker locker(d);
const auto it = d->vars.constFind(d->prepareName(name));
if (it == d->vars.constEnd())
return defaultValue;
@@ -398,7 +396,6 @@ QStringList QProcessEnvironment::toStringList() const
{
if (!d)
return QStringList();
- QProcessEnvironmentPrivate::MutexLocker locker(d);
return d->toList();
}
@@ -412,7 +409,6 @@ QStringList QProcessEnvironment::keys() const
{
if (!d)
return QStringList();
- QProcessEnvironmentPrivate::MutexLocker locker(d);
return d->keys();
}
@@ -429,7 +425,6 @@ void QProcessEnvironment::insert(const QProcessEnvironment &e)
return;
// our re-impl of detach() detaches from null
- QProcessEnvironmentPrivate::MutexLocker locker(e.d);
d->insert(*e.d);
}
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h
index d02e87837c..2587530c09 100644
--- a/src/corelib/io/qprocess_p.h
+++ b/src/corelib/io/qprocess_p.h
@@ -146,16 +146,22 @@ public:
inline QString nameToString(const Key &name) const { return name; }
inline Value prepareValue(const QString &value) const { return value; }
inline QString valueToString(const Value &value) const { return value; }
- struct MutexLocker {
- MutexLocker(const QProcessEnvironmentPrivate *) {}
+#else
+ struct NameMapMutexLocker : public QMutexLocker
+ {
+ NameMapMutexLocker(const QProcessEnvironmentPrivate *d) : QMutexLocker(&d->nameMapMutex) {}
};
- struct OrderedMutexLocker {
- OrderedMutexLocker(const QProcessEnvironmentPrivate *,
- const QProcessEnvironmentPrivate *) {}
+ struct OrderedNameMapMutexLocker : public QOrderedMutexLocker
+ {
+ OrderedNameMapMutexLocker(const QProcessEnvironmentPrivate *d1,
+ const QProcessEnvironmentPrivate *d2)
+ : QOrderedMutexLocker(&d1->nameMapMutex, &d2->nameMapMutex)
+ {}
};
-#else
+
inline Key prepareName(const QString &name) const
{
+ const NameMapMutexLocker locker(this);
Key &ent = nameMap[name];
if (ent.isEmpty())
ent = name.toLocal8Bit();
@@ -164,40 +170,27 @@ public:
inline QString nameToString(const Key &name) const
{
const QString sname = QString::fromLocal8Bit(name);
- nameMap[sname] = name;
+ {
+ const NameMapMutexLocker locker(this);
+ nameMap[sname] = name;
+ }
return sname;
}
inline Value prepareValue(const QString &value) const { return Value(value); }
inline QString valueToString(const Value &value) const { return value.string(); }
- struct MutexLocker : public QMutexLocker
- {
- MutexLocker(const QProcessEnvironmentPrivate *d) : QMutexLocker(&d->mutex) {}
- };
- struct OrderedMutexLocker : public QOrderedMutexLocker
- {
- OrderedMutexLocker(const QProcessEnvironmentPrivate *d1,
- const QProcessEnvironmentPrivate *d2) :
- QOrderedMutexLocker(&d1->mutex, &d2->mutex)
- {}
- };
-
QProcessEnvironmentPrivate() : QSharedData() {}
QProcessEnvironmentPrivate(const QProcessEnvironmentPrivate &other) :
- QSharedData()
+ QSharedData(), vars(other.vars)
{
- // This being locked ensures that the functions that only assign
- // d pointers don't need explicit locking.
// We don't need to lock our own mutex, as this object is new and
// consequently not shared. For the same reason, non-const methods
// do not need a lock, as they detach objects (however, we need to
// ensure that they really detach before using prepareName()).
- MutexLocker locker(&other);
- vars = other.vars;
+ NameMapMutexLocker locker(&other);
nameMap = other.nameMap;
- // We need to detach our members, so that our mutex can protect them.
- // As we are being detached, they likely would be detached a moment later anyway.
- vars.detach();
+ // We need to detach our nameMap, so that our mutex can protect it.
+ // As we are being detached, it likely would be detached a moment later anyway.
nameMap.detach();
}
#endif
@@ -208,8 +201,7 @@ public:
#ifdef Q_OS_UNIX
typedef QHash<QString, Key> NameHash;
mutable NameHash nameMap;
-
- mutable QMutex mutex;
+ mutable QMutex nameMapMutex;
#endif
static QProcessEnvironment fromList(const QStringList &list);
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 1d5b76a8a4..951fc4ccaa 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -438,7 +438,6 @@ void QProcessPrivate::startProcess()
int envc = 0;
char **envp = 0;
if (environment.d.constData()) {
- QProcessEnvironmentPrivate::MutexLocker locker(environment.d);
envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
}
@@ -970,7 +969,6 @@ bool QProcessPrivate::startDetached(qint64 *pid)
int envc = 0;
char **envp = nullptr;
if (environment.d.constData()) {
- QProcessEnvironmentPrivate::MutexLocker locker(environment.d);
envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
}
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index fcc5b69179..52b746d04a 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
-** Copyright (C) 2018 Intel Corporation.
+** Copyright (C) 2019 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -279,14 +279,14 @@ static inline QStringList *resourceSearchPaths()
This enum is used by compressionAlgorithm() to indicate which algorithm the
RCC tool used to compress the payload.
- \value NoCompression Contents are not compressed (isCompressed() is false).
+ \value NoCompression Contents are not compressed
\value ZlibCompression Contents are compressed using \l{zlib}{https://zlib.net} and can
be decompressed using the qUncompress() function.
\value ZstdCompression Contents are compressed using \l{zstd}{https://zstd.net}. To
decompress, use the \c{ZSTD_decompress} function from the zstd
library.
- \sa compressionAlgorithm(), isCompressed()
+ \sa compressionAlgorithm()
*/
class QResourcePrivate {
@@ -551,13 +551,20 @@ bool QResource::isValid() const
\sa isDir()
*/
-
+#if QT_DEPRECATED_SINCE(5, 13)
/*!
+ \obsolete
+
Returns \c true if the resource represents a file and the data backing it
is in a compressed format, false otherwise. If the data is compressed,
check compressionAlgorithm() to verify what algorithm to use to decompress
the data.
+ \note This function is deprecated and can be replaced with
+ \code
+ compressionAlgorithm() != NoCompression
+ \endcode
+
\sa data(), compressionAlgorithm(), isFile()
*/
@@ -565,6 +572,7 @@ bool QResource::isCompressed() const
{
return compressionAlgorithm() != NoCompression;
}
+#endif
/*!
\since 5.13
@@ -582,7 +590,7 @@ bool QResource::isCompressed() const
See \l{http://facebook.github.io/zstd/zstd_manual.html}{Zstandard manual}.
- \sa isCompressed(), data(), isFile()
+ \sa data(), isFile()
*/
QResource::Compression QResource::compressionAlgorithm() const
{
@@ -606,11 +614,11 @@ qint64 QResource::size() const
/*!
Returns direct access to a read only segment of data that this resource
- represents. If the resource is compressed the data returns is
- compressed and qUncompress() must be used to access the data. If the
- resource is a directory \nullptr is returned.
+ represents. If the resource is compressed the data returned is compressed
+ and the appropriate library functions must be used to access the data. If
+ the resource is a directory \nullptr is returned.
- \sa size(), isCompressed(), isFile()
+ \sa size(), compressionAlgorithm(), isFile()
*/
const uchar *QResource::data() const
@@ -940,12 +948,15 @@ bool QResourceRoot::mappingRootSubdir(const QString &path, QString *match) const
Q_CORE_EXPORT bool qRegisterResourceData(int version, const unsigned char *tree,
const unsigned char *name, const unsigned char *data)
{
+ if (resourceGlobalData.isDestroyed())
+ return false;
QMutexLocker lock(resourceMutex());
- if (version >= 0x01 && version <= 0x3 && resourceList()) {
+ ResourceList *list = resourceList();
+ if (version >= 0x01 && version <= 0x3) {
bool found = false;
QResourceRoot res(version, tree, name, data);
- for(int i = 0; i < resourceList()->size(); ++i) {
- if(*resourceList()->at(i) == res) {
+ for (int i = 0; i < list->size(); ++i) {
+ if (*list->at(i) == res) {
found = true;
break;
}
@@ -953,7 +964,7 @@ Q_CORE_EXPORT bool qRegisterResourceData(int version, const unsigned char *tree,
if(!found) {
QResourceRoot *root = new QResourceRoot(version, tree, name, data);
root->ref.ref();
- resourceList()->append(root);
+ list->append(root);
}
return true;
}
@@ -967,11 +978,12 @@ Q_CORE_EXPORT bool qUnregisterResourceData(int version, const unsigned char *tre
return false;
QMutexLocker lock(resourceMutex());
- if (version >= 0x01 && version <= 0x3 && resourceList()) {
+ if (version >= 0x01 && version <= 0x3) {
QResourceRoot res(version, tree, name, data);
- for(int i = 0; i < resourceList()->size(); ) {
- if(*resourceList()->at(i) == res) {
- QResourceRoot *root = resourceList()->takeAt(i);
+ ResourceList *list = resourceList();
+ for (int i = 0; i < list->size(); ) {
+ if (*list->at(i) == res) {
+ QResourceRoot *root = list->takeAt(i);
if(!root->ref.deref())
delete root;
} else {
@@ -1217,7 +1229,7 @@ QResource::unregisterResource(const QString &rccFilename, const QString &resourc
if(res->type() == QResourceRoot::Resource_File) {
QDynamicFileResourceRoot *root = reinterpret_cast<QDynamicFileResourceRoot*>(res);
if (root->mappingFile() == rccFilename && root->mappingRoot() == r) {
- resourceList()->removeAt(i);
+ list->removeAt(i);
if(!root->ref.deref()) {
delete root;
return true;
@@ -1288,7 +1300,7 @@ QResource::unregisterResource(const uchar *rccData, const QString &resourceRoot)
if(res->type() == QResourceRoot::Resource_Buffer) {
QDynamicBufferResourceRoot *root = reinterpret_cast<QDynamicBufferResourceRoot*>(res);
if (root->mappingBuffer() == rccData && root->mappingRoot() == r) {
- resourceList()->removeAt(i);
+ list->removeAt(i);
if(!root->ref.deref()) {
delete root;
return true;
@@ -1366,9 +1378,15 @@ bool QResourceFileEngine::open(QIODevice::OpenMode flags)
qWarning("QResourceFileEngine::open: Missing file name");
return false;
}
- if(flags & QIODevice::WriteOnly)
+ if (flags & QIODevice::WriteOnly)
return false;
- d->uncompress();
+ if (d->resource.compressionAlgorithm() != QResource::NoCompression) {
+ d->uncompress();
+ if (d->uncompressed.isNull()) {
+ d->errorString = QSystemError::stdString(EIO);
+ return false;
+ }
+ }
if (!d->resource.isValid()) {
d->errorString = QSystemError::stdString(ENOENT);
return false;
@@ -1395,7 +1413,7 @@ qint64 QResourceFileEngine::read(char *data, qint64 len)
len = size()-d->offset;
if(len <= 0)
return 0;
- if(d->resource.isCompressed())
+ if (!d->uncompressed.isNull())
memcpy(data, d->uncompressed.constData()+d->offset, len);
else
memcpy(data, d->resource.data()+d->offset, len);
@@ -1431,9 +1449,9 @@ bool QResourceFileEngine::link(const QString &)
qint64 QResourceFileEngine::size() const
{
Q_D(const QResourceFileEngine);
- if(!d->resource.isValid())
+ if (!d->resource.isValid())
return 0;
- if (d->resource.isCompressed()) {
+ if (d->resource.compressionAlgorithm() != QResource::NoCompression) {
d->uncompress();
return d->uncompressed.size();
}
@@ -1596,7 +1614,7 @@ uchar *QResourceFileEnginePrivate::map(qint64 offset, qint64 size, QFile::Memory
Q_UNUSED(flags);
qint64 max = resource.size();
- if (resource.isCompressed()) {
+ if (resource.compressionAlgorithm() != QResource::NoCompression) {
uncompress();
max = uncompressed.size();
}
@@ -1609,7 +1627,7 @@ uchar *QResourceFileEnginePrivate::map(qint64 offset, qint64 size, QFile::Memory
}
const uchar *address = resource.data();
- if (resource.isCompressed())
+ if (resource.compressionAlgorithm() != QResource::NoCompression)
address = reinterpret_cast<const uchar *>(uncompressed.constData());
return const_cast<uchar *>(address) + offset;
diff --git a/src/corelib/io/qresource.h b/src/corelib/io/qresource.h
index 5e798de436..5ee8d5d266 100644
--- a/src/corelib/io/qresource.h
+++ b/src/corelib/io/qresource.h
@@ -72,7 +72,6 @@ public:
bool isValid() const;
- bool isCompressed() const;
Compression compressionAlgorithm() const;
qint64 size() const;
const uchar *data() const;
@@ -84,6 +83,10 @@ public:
QT_DEPRECATED_X("Use QDir::searchPaths() instead")
static QStringList searchPaths();
#endif
+#if QT_DEPRECATED_SINCE(5, 15)
+ QT_DEPRECATED_VERSION_X_5_15("Use QResource::compressionAlgorithm() instead")
+ bool isCompressed() const;
+#endif
static bool registerResource(const QString &rccFilename, const QString &resourceRoot=QString());
static bool unregisterResource(const QString &rccFilename, const QString &resourceRoot=QString());
diff --git a/src/corelib/io/qsavefile.cpp b/src/corelib/io/qsavefile.cpp
index 915d0a0a00..f41e6302a2 100644
--- a/src/corelib/io/qsavefile.cpp
+++ b/src/corelib/io/qsavefile.cpp
@@ -150,8 +150,7 @@ QSaveFile::~QSaveFile()
QFileDevice::close();
if (d->fileEngine) {
d->fileEngine->remove();
- delete d->fileEngine;
- d->fileEngine = nullptr;
+ d->fileEngine.reset();
}
}
@@ -197,6 +196,7 @@ bool QSaveFile::open(OpenMode mode)
return false;
}
unsetError();
+ d->writeError = QFileDevice::NoError;
if ((mode & (ReadOnly | WriteOnly)) == 0) {
qWarning("QSaveFile::open: Open mode not specified");
return false;
@@ -234,7 +234,7 @@ bool QSaveFile::open(OpenMode mode)
}
auto openDirectly = [&]() {
- d->fileEngine = QAbstractFileEngine::create(d->finalFileName);
+ d->fileEngine.reset(QAbstractFileEngine::create(d->finalFileName));
if (d->fileEngine->open(mode | QIODevice::Unbuffered)) {
d->useTemporaryFile = false;
QFileDevice::open(mode);
@@ -251,8 +251,7 @@ bool QSaveFile::open(OpenMode mode)
if (openDirectly())
return true;
d->setError(d->fileEngine->error(), d->fileEngine->errorString());
- delete d->fileEngine;
- d->fileEngine = nullptr;
+ d->fileEngine.reset();
} else {
QString msg =
QSaveFile::tr("QSaveFile cannot open '%1' without direct write fallback "
@@ -264,18 +263,17 @@ bool QSaveFile::open(OpenMode mode)
}
#endif
- d->fileEngine = new QTemporaryFileEngine(&d->finalFileName, QTemporaryFileEngine::Win32NonShared);
+ d->fileEngine.reset(new QTemporaryFileEngine(&d->finalFileName, QTemporaryFileEngine::Win32NonShared));
// if the target file exists, we'll copy its permissions below,
// but until then, let's ensure the temporary file is not accessible
// to a third party
int perm = (existingFile.exists() ? 0600 : 0666);
- static_cast<QTemporaryFileEngine *>(d->fileEngine)->initialize(d->finalFileName, perm);
+ static_cast<QTemporaryFileEngine *>(d->fileEngine.get())->initialize(d->finalFileName, perm);
// Same as in QFile: QIODevice provides the buffering, so there's no need to request it from the file engine.
if (!d->fileEngine->open(mode | QIODevice::Unbuffered)) {
QFileDevice::FileError err = d->fileEngine->error();
#ifdef Q_OS_UNIX
if (d->directWriteFallback && err == QFileDevice::OpenError && errno == EACCES) {
- delete d->fileEngine;
if (openDirectly())
return true;
err = d->fileEngine->error();
@@ -284,8 +282,7 @@ bool QSaveFile::open(OpenMode mode)
if (err == QFileDevice::UnspecifiedError)
err = QFileDevice::OpenError;
d->setError(err, d->fileEngine->errorString());
- delete d->fileEngine;
- d->fileEngine = nullptr;
+ d->fileEngine.reset();
return false;
}
@@ -331,30 +328,26 @@ bool QSaveFile::commit()
}
QFileDevice::close(); // calls flush()
+ const auto fe = std::move(d->fileEngine);
+
// Sync to disk if possible. Ignore errors (e.g. not supported).
- d->fileEngine->syncToDisk();
+ fe->syncToDisk();
if (d->useTemporaryFile) {
if (d->writeError != QFileDevice::NoError) {
- d->fileEngine->remove();
+ fe->remove();
d->writeError = QFileDevice::NoError;
- delete d->fileEngine;
- d->fileEngine = nullptr;
return false;
}
// atomically replace old file with new file
// Can't use QFile::rename for that, must use the file engine directly
- Q_ASSERT(d->fileEngine);
- if (!d->fileEngine->renameOverwrite(d->finalFileName)) {
- d->setError(d->fileEngine->error(), d->fileEngine->errorString());
- d->fileEngine->remove();
- delete d->fileEngine;
- d->fileEngine = nullptr;
+ Q_ASSERT(fe);
+ if (!fe->renameOverwrite(d->finalFileName)) {
+ d->setError(fe->error(), fe->errorString());
+ fe->remove();
return false;
}
}
- delete d->fileEngine;
- d->fileEngine = nullptr;
return true;
}
diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp
index dbf650d5f6..f56fef7f8e 100644
--- a/src/corelib/io/qstandardpaths.cpp
+++ b/src/corelib/io/qstandardpaths.cpp
@@ -297,7 +297,7 @@ QT_BEGIN_NAMESPACE
\li "<APPROOT>/tmp"
\row \li HomeLocation
\li "<APPROOT>/files"
- \li "<APPROOT>" (not writable)
+ \li system defined
\row \li DataLocation
\li "<APPROOT>/files", "<USER>/<APPNAME>/files"
\li "<APPROOT>/Library/Application Support"
diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp
index f4f8787968..6425890e3f 100644
--- a/src/corelib/io/qstandardpaths_unix.cpp
+++ b/src/corelib/io/qstandardpaths_unix.cpp
@@ -71,6 +71,28 @@ static void appendOrganizationAndApp(QString &path)
#endif
}
+#if QT_CONFIG(regularexpression)
+static QLatin1String xdg_key_name(QStandardPaths::StandardLocation type)
+{
+ switch (type) {
+ case QStandardPaths::DesktopLocation:
+ return QLatin1String("DESKTOP");
+ case QStandardPaths::DocumentsLocation:
+ return QLatin1String("DOCUMENTS");
+ case QStandardPaths::PicturesLocation:
+ return QLatin1String("PICTURES");
+ case QStandardPaths::MusicLocation:
+ return QLatin1String("MUSIC");
+ case QStandardPaths::MoviesLocation:
+ return QLatin1String("VIDEOS");
+ case QStandardPaths::DownloadLocation:
+ return QLatin1String("DOWNLOAD");
+ default:
+ return QLatin1String();
+ }
+}
+#endif
+
QString QStandardPaths::writableLocation(StandardLocation type)
{
switch (type) {
@@ -182,61 +204,32 @@ QString QStandardPaths::writableLocation(StandardLocation type)
if (xdgConfigHome.isEmpty())
xdgConfigHome = QDir::homePath() + QLatin1String("/.config");
QFile file(xdgConfigHome + QLatin1String("/user-dirs.dirs"));
- if (!isTestModeEnabled() && file.open(QIODevice::ReadOnly)) {
- QHash<QString, QString> lines;
+ const QLatin1String key = xdg_key_name(type);
+ if (!key.isEmpty() && !isTestModeEnabled() && file.open(QIODevice::ReadOnly)) {
QTextStream stream(&file);
// Only look for lines like: XDG_DESKTOP_DIR="$HOME/Desktop"
QRegularExpression exp(QLatin1String("^XDG_(.*)_DIR=(.*)$"));
+ QString result;
while (!stream.atEnd()) {
const QString &line = stream.readLine();
QRegularExpressionMatch match = exp.match(line);
- if (match.hasMatch()) {
- const QStringList lst = match.capturedTexts();
- const QString key = lst.at(1);
- QString value = lst.at(2);
+ if (match.hasMatch() && match.capturedView(1) == key) {
+ QStringView value = match.capturedView(2);
if (value.length() > 2
&& value.startsWith(QLatin1Char('\"'))
&& value.endsWith(QLatin1Char('\"')))
value = value.mid(1, value.length() - 2);
- // Store the key and value: "DESKTOP", "$HOME/Desktop"
- lines[key] = value;
- }
- }
-
- QString key;
- switch (type) {
- case DesktopLocation:
- key = QLatin1String("DESKTOP");
- break;
- case DocumentsLocation:
- key = QLatin1String("DOCUMENTS");
- break;
- case PicturesLocation:
- key = QLatin1String("PICTURES");
- break;
- case MusicLocation:
- key = QLatin1String("MUSIC");
- break;
- case MoviesLocation:
- key = QLatin1String("VIDEOS");
- break;
- case DownloadLocation:
- key = QLatin1String("DOWNLOAD");
- break;
- default:
- break;
- }
- if (!key.isEmpty()) {
- QString value = lines.value(key);
- if (!value.isEmpty()) {
// value can start with $HOME
if (value.startsWith(QLatin1String("$HOME")))
- value = QDir::homePath() + value.midRef(5);
- if (value.length() > 1 && value.endsWith(QLatin1Char('/')))
- value.chop(1);
- return value;
+ result = QDir::homePath() + value.mid(5);
+ else
+ result = value.toString();
+ if (result.length() > 1 && result.endsWith(QLatin1Char('/')))
+ result.chop(1);
}
}
+ if (!result.isNull())
+ return result;
}
#endif // QT_CONFIG(regularexpression)
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp
index 4669c20711..1e72241e68 100644
--- a/src/corelib/io/qstorageinfo_unix.cpp
+++ b/src/corelib/io/qstorageinfo_unix.cpp
@@ -468,8 +468,18 @@ inline bool QStorageIterator::next()
size_t len = strlen(buffer.data());
if (len == 0)
return false;
- if (ptr[len - 1] == '\n')
- ptr[len - 1] = '\0';
+ while (Q_UNLIKELY(ptr[len - 1] != '\n' && !feof(fp))) {
+ // buffer wasn't large enough. Enlarge and try again.
+ // (we're readidng from the kernel, so OOM is unlikely)
+ buffer.resize((buffer.size() + 4096) & ~4095);
+ ptr = buffer.data();
+ if (fgets(ptr + len, buffer.size() - len, fp) == nullptr)
+ return false;
+
+ len += strlen(ptr + len);
+ Q_ASSERT(len < size_t(buffer.size()));
+ }
+ ptr[len - 1] = '\0';
// parse the line
bool ok;
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index c89ad06a1f..acd31f4d84 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -544,10 +544,10 @@ QTemporaryFilePrivate::~QTemporaryFilePrivate()
QAbstractFileEngine *QTemporaryFilePrivate::engine() const
{
if (!fileEngine) {
- fileEngine = new QTemporaryFileEngine(&templateName);
+ fileEngine.reset(new QTemporaryFileEngine(&templateName));
resetFileEngine();
}
- return fileEngine;
+ return fileEngine.get();
}
void QTemporaryFilePrivate::resetFileEngine() const
@@ -555,7 +555,7 @@ void QTemporaryFilePrivate::resetFileEngine() const
if (!fileEngine)
return;
- QTemporaryFileEngine *tef = static_cast<QTemporaryFileEngine *>(fileEngine);
+ QTemporaryFileEngine *tef = static_cast<QTemporaryFileEngine *>(fileEngine.get());
if (fileName.isEmpty())
tef->initialize(templateName, 0600);
else
@@ -568,7 +568,7 @@ void QTemporaryFilePrivate::materializeUnnamedFile()
if (!fileName.isEmpty() || !fileEngine)
return;
- auto *tef = static_cast<QTemporaryFileEngine *>(fileEngine);
+ auto *tef = static_cast<QTemporaryFileEngine *>(fileEngine.get());
fileName = tef->fileName(QAbstractFileEngine::DefaultName);
#endif
}
@@ -792,7 +792,7 @@ void QTemporaryFile::setAutoRemove(bool b)
QString QTemporaryFile::fileName() const
{
Q_D(const QTemporaryFile);
- auto tef = static_cast<QTemporaryFileEngine *>(d->fileEngine);
+ auto tef = static_cast<QTemporaryFileEngine *>(d->fileEngine.get());
if (tef && tef->isReallyOpen())
const_cast<QTemporaryFilePrivate *>(d)->materializeUnnamedFile();
@@ -841,7 +841,7 @@ void QTemporaryFile::setFileTemplate(const QString &name)
bool QTemporaryFile::rename(const QString &newName)
{
Q_D(QTemporaryFile);
- auto tef = static_cast<QTemporaryFileEngine *>(d->fileEngine);
+ auto tef = static_cast<QTemporaryFileEngine *>(d->fileEngine.get());
if (!tef || !tef->isReallyOpen() || !tef->filePathWasTemplate)
return QFile::rename(newName);
@@ -947,7 +947,7 @@ QTemporaryFile *QTemporaryFile::createNativeFile(QFile &file)
bool QTemporaryFile::open(OpenMode flags)
{
Q_D(QTemporaryFile);
- auto tef = static_cast<QTemporaryFileEngine *>(d->fileEngine);
+ auto tef = static_cast<QTemporaryFileEngine *>(d->fileEngine.get());
if (tef && tef->isReallyOpen()) {
setOpenMode(flags);
return true;
@@ -961,7 +961,7 @@ bool QTemporaryFile::open(OpenMode flags)
d->resetFileEngine();
if (QFile::open(flags)) {
- tef = static_cast<QTemporaryFileEngine *>(d->fileEngine);
+ tef = static_cast<QTemporaryFileEngine *>(d->fileEngine.get());
if (tef->isUnnamedFile())
d->fileName.clear();
else
diff --git a/src/corelib/io/qtldurl.cpp b/src/corelib/io/qtldurl.cpp
index a934d19fa2..912609ec91 100644
--- a/src/corelib/io/qtldurl.cpp
+++ b/src/corelib/io/qtldurl.cpp
@@ -59,9 +59,9 @@ enum TLDMatchType {
static bool containsTLDEntry(QStringView entry, TLDMatchType match)
{
const QStringView matchSymbols[] = {
- QStringViewLiteral(""),
- QStringViewLiteral("*"),
- QStringViewLiteral("!"),
+ u"",
+ u"*",
+ u"!",
};
const auto symbol = matchSymbols[match];
int index = qt_hash(entry, qt_hash(symbol)) % tldCount;
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index d9ebc6c750..878e007fb0 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -1010,7 +1010,7 @@ inline bool QUrlPrivate::setScheme(const QString &value, int len, bool doSetErro
for (int i = needsLowercasing; i >= 0; --i) {
ushort c = schemeData[i].unicode();
if (c >= 'A' && c <= 'Z')
- schemeData[i] = c + 0x20;
+ schemeData[i] = QChar(c + 0x20);
}
}
diff --git a/src/corelib/io/qurlidna.cpp b/src/corelib/io/qurlidna.cpp
index 2f89d22660..a2f0caa606 100644
--- a/src/corelib/io/qurlidna.cpp
+++ b/src/corelib/io/qurlidna.cpp
@@ -2220,9 +2220,8 @@ Q_AUTOTEST_EXPORT void qt_punycodeEncoder(const QChar *s, int ucLength, QString
bool skipped = false;
// copy all basic code points verbatim to output.
for (uint j = 0; j < (uint) ucLength; ++j) {
- ushort js = s[j].unicode();
- if (js < 0x80)
- *d++ = js;
+ if (s[j].unicode() < 0x80)
+ *d++ = s[j];
else
skipped = true;
}
diff --git a/src/corelib/io/qurlquery.cpp b/src/corelib/io/qurlquery.cpp
index 36a2880bf1..8d80a2d8bd 100644
--- a/src/corelib/io/qurlquery.cpp
+++ b/src/corelib/io/qurlquery.cpp
@@ -146,7 +146,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QUrlQuery(std::initializer_list<QPair<QString, QString>> list)
+ \fn QUrlQuery::QUrlQuery(std::initializer_list<QPair<QString, QString>> list)
\since 5.13
@@ -293,9 +293,9 @@ void QUrlQueryPrivate::setQuery(const QString &query)
const QChar *delimiter = nullptr;
while (pos != end) {
// scan for the component parts of this pair
- if (!delimiter && pos->unicode() == valueDelimiter)
+ if (!delimiter && *pos == valueDelimiter)
delimiter = pos;
- if (pos->unicode() == pairDelimiter)
+ if (*pos == pairDelimiter)
break;
++pos;
}
@@ -584,8 +584,8 @@ QString QUrlQuery::query(QUrl::ComponentFormattingOptions encoding) const
*/
void QUrlQuery::setQueryDelimiters(QChar valueDelimiter, QChar pairDelimiter)
{
- d->valueDelimiter = valueDelimiter.unicode();
- d->pairDelimiter = pairDelimiter.unicode();
+ d->valueDelimiter = valueDelimiter;
+ d->pairDelimiter = pairDelimiter;
}
/*!
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp
index 2eacb3cc94..e19d9479f8 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -532,21 +532,16 @@ void QAbstractItemModelPrivate::invalidatePersistentIndex(const QModelIndex &ind
}
}
-namespace {
- struct DefaultRoleNames : public QHash<int, QByteArray>
+using DefaultRoleNames = QHash<int, QByteArray>;
+Q_GLOBAL_STATIC_WITH_ARGS(DefaultRoleNames, qDefaultRoleNames, (
{
- DefaultRoleNames() {
- (*this)[Qt::DisplayRole] = "display";
- (*this)[Qt::DecorationRole] = "decoration";
- (*this)[Qt::EditRole] = "edit";
- (*this)[Qt::ToolTipRole] = "toolTip";
- (*this)[Qt::StatusTipRole] = "statusTip";
- (*this)[Qt::WhatsThisRole] = "whatsThis";
- }
- };
-}
-
-Q_GLOBAL_STATIC(DefaultRoleNames, qDefaultRoleNames)
+ { Qt::DisplayRole, "display" },
+ { Qt::DecorationRole, "decoration" },
+ { Qt::EditRole, "edit" },
+ { Qt::ToolTipRole, "toolTip" },
+ { Qt::StatusTipRole, "statusTip" },
+ { Qt::WhatsThisRole, "whatsThis" },
+ }))
const QHash<int,QByteArray> &QAbstractItemModelPrivate::defaultRoleNames()
{
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
index d13e6199db..675bf4b8c3 100644
--- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
@@ -64,11 +64,7 @@ struct QSortFilterProxyModelDataChanged
static inline QSet<int> qVectorToSet(const QVector<int> &vector)
{
- QSet<int> set;
- set.reserve(vector.size());
- for(int i=0; i < vector.size(); ++i)
- set << vector.at(i);
- return set;
+ return {vector.begin(), vector.end()};
}
class QSortFilterProxyModelLessThan
@@ -130,7 +126,7 @@ struct QRowsRemoval
{
}
- bool contains(QModelIndex parent, int row)
+ bool contains(QModelIndex parent, int row) const
{
do {
if (parent == parent_source)
@@ -470,8 +466,8 @@ bool QSortFilterProxyModelPrivate::filterRecursiveAcceptsRow(int source_row, con
void QSortFilterProxyModelPrivate::remove_from_mapping(const QModelIndex &source_parent)
{
if (Mapping *m = source_index_mapping.take(source_parent)) {
- for (int i = 0; i < m->mapped_children.size(); ++i)
- remove_from_mapping(m->mapped_children.at(i));
+ for (const QModelIndex &mappedIdx : qAsConst(m->mapped_children))
+ remove_from_mapping(mappedIdx);
delete m;
}
}
@@ -607,9 +603,9 @@ void QSortFilterProxyModelPrivate::sort()
Q_Q(QSortFilterProxyModel);
emit q->layoutAboutToBeChanged(QList<QPersistentModelIndex>(), QAbstractItemModel::VerticalSortHint);
QModelIndexPairList source_indexes = store_persistent_indexes();
- IndexMap::const_iterator it = source_index_mapping.constBegin();
- for (; it != source_index_mapping.constEnd(); ++it) {
- QModelIndex source_parent = it.key();
+ const auto end = source_index_mapping.constEnd();
+ for (auto it = source_index_mapping.constBegin(); it != end; ++it) {
+ const QModelIndex &source_parent = it.key();
Mapping *m = it.value();
sort_source_rows(m->source_rows, source_parent);
build_source_to_proxy_mapping(m->source_rows, m->proxy_rows);
@@ -735,13 +731,14 @@ void QSortFilterProxyModelPrivate::remove_source_items(
if (!proxy_parent.isValid() && source_parent.isValid())
return; // nothing to do (already removed)
- QVector<QPair<int, int> > proxy_intervals;
- proxy_intervals = proxy_intervals_for_source_items(source_to_proxy, source_items);
+ const auto proxy_intervals = proxy_intervals_for_source_items(
+ source_to_proxy, source_items);
- for (int i = proxy_intervals.size()-1; i >= 0; --i) {
- QPair<int, int> interval = proxy_intervals.at(i);
- int proxy_start = interval.first;
- int proxy_end = interval.second;
+ const auto end = proxy_intervals.rend();
+ for (auto it = proxy_intervals.rbegin(); it != end; ++it) {
+ const QPair<int, int> &interval = *it;
+ const int proxy_start = interval.first;
+ const int proxy_end = interval.second;
remove_proxy_interval(source_to_proxy, proxy_to_source, proxy_start, proxy_end,
proxy_parent, orient, emit_signal);
}
@@ -875,15 +872,15 @@ void QSortFilterProxyModelPrivate::insert_source_items(
if (!proxy_parent.isValid() && source_parent.isValid())
return; // nothing to do (source_parent is not mapped)
- QVector<QPair<int, QVector<int> > > proxy_intervals;
- proxy_intervals = proxy_intervals_for_source_items_to_add(
+ const auto proxy_intervals = proxy_intervals_for_source_items_to_add(
proxy_to_source, source_items, source_parent, orient);
- for (int i = proxy_intervals.size()-1; i >= 0; --i) {
- QPair<int, QVector<int> > interval = proxy_intervals.at(i);
- int proxy_start = interval.first;
- QVector<int> source_items = interval.second;
- int proxy_end = proxy_start + source_items.size() - 1;
+ const auto end = proxy_intervals.rend();
+ for (auto it = proxy_intervals.rbegin(); it != end; ++it) {
+ const QPair<int, QVector<int> > &interval = *it;
+ const int proxy_start = interval.first;
+ const QVector<int> &source_items = interval.second;
+ const int proxy_end = proxy_start + source_items.size() - 1;
if (emit_signal) {
if (orient == Qt::Vertical)
@@ -1195,8 +1192,8 @@ QModelIndexPairList QSortFilterProxyModelPrivate::store_persistent_indexes() con
Q_Q(const QSortFilterProxyModel);
QModelIndexPairList source_indexes;
source_indexes.reserve(persistent.indexes.count());
- for (QPersistentModelIndexData *data : qAsConst(persistent.indexes)) {
- QModelIndex proxy_index = data->index;
+ for (const QPersistentModelIndexData *data : qAsConst(persistent.indexes)) {
+ const QModelIndex &proxy_index = data->index;
QModelIndex source_index = q->mapToSource(proxy_index);
source_indexes.append(qMakePair(proxy_index, QPersistentModelIndex(source_index)));
}
@@ -1217,9 +1214,9 @@ void QSortFilterProxyModelPrivate::update_persistent_indexes(
const int numSourceIndexes = source_indexes.count();
from.reserve(numSourceIndexes);
to.reserve(numSourceIndexes);
- for (int i = 0; i < numSourceIndexes; ++i) {
- QModelIndex source_index = source_indexes.at(i).second;
- QModelIndex old_proxy_index = source_indexes.at(i).first;
+ for (const auto &indexPair : source_indexes) {
+ const QPersistentModelIndex &source_index = indexPair.second;
+ const QModelIndex &old_proxy_index = indexPair.first;
create_mapping(source_index.parent());
QModelIndex proxy_index = q->mapFromSource(source_index);
from << old_proxy_index;
@@ -1264,7 +1261,7 @@ void QSortFilterProxyModelPrivate::filter_changed(const QModelIndex &source_pare
const QVector<QModelIndex> mappedChildren = m->mapped_children;
QVector<int> indexesToRemove;
for (int i = 0; i < mappedChildren.size(); ++i) {
- const QModelIndex source_child_index = mappedChildren.at(i);
+ const QModelIndex &source_child_index = mappedChildren.at(i);
if (rows_removed.contains(source_child_index.row()) || columns_removed.contains(source_child_index.column())) {
indexesToRemove.push_back(i);
remove_from_mapping(source_child_index);
@@ -2296,10 +2293,9 @@ QMimeData *QSortFilterProxyModel::mimeData(const QModelIndexList &indexes) const
{
Q_D(const QSortFilterProxyModel);
QModelIndexList source_indexes;
- const int numIndexes = indexes.count();
- source_indexes.reserve(numIndexes);
- for (int i = 0; i < numIndexes; ++i)
- source_indexes << mapToSource(indexes.at(i));
+ source_indexes.reserve(indexes.count());
+ for (const QModelIndex &idx : indexes)
+ source_indexes << mapToSource(idx);
return d->model->mimeData(source_indexes);
}
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm
index 15b69acbd4..9e9e71c397 100644
--- a/src/corelib/kernel/qcore_mac_objc.mm
+++ b/src/corelib/kernel/qcore_mac_objc.mm
@@ -514,10 +514,9 @@ Q_CONSTRUCTOR_FUNCTION(qt_apple_check_os_version);
// -------------------------------------------------------------------------
-void QMacKeyValueObserver::addObserver()
+void QMacKeyValueObserver::addObserver(NSKeyValueObservingOptions options)
{
- [object addObserver:observer forKeyPath:keyPath
- options:NSKeyValueObservingOptionNew context:callback.get()];
+ [object addObserver:observer forKeyPath:keyPath options:options context:callback.get()];
}
void QMacKeyValueObserver::removeObserver() {
diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h
index 0e1a5fe345..447dcd9cbe 100644
--- a/src/corelib/kernel/qcore_mac_p.h
+++ b/src/corelib/kernel/qcore_mac_p.h
@@ -350,8 +350,12 @@ public:
QMacKeyValueObserver() {}
// Note: QMacKeyValueObserver must not outlive the object observed!
- QMacKeyValueObserver(id object, NSString *keyPath, Callback callback)
- : object(object), keyPath(keyPath), callback(new Callback(callback)) { addObserver(); }
+ QMacKeyValueObserver(id object, NSString *keyPath, Callback callback,
+ NSKeyValueObservingOptions options = NSKeyValueObservingOptionNew)
+ : object(object), keyPath(keyPath), callback(new Callback(callback))
+ {
+ addObserver(options);
+ }
QMacKeyValueObserver(const QMacKeyValueObserver &other)
: QMacKeyValueObserver(other.object, other.keyPath, *other.callback.get()) {}
@@ -381,7 +385,7 @@ private:
std::swap(first.callback, second.callback);
}
- void addObserver();
+ void addObserver(NSKeyValueObservingOptions options);
id object = nil;
NSString *keyPath = nullptr;
diff --git a/src/corelib/kernel/qeventdispatcher_winrt_p.h b/src/corelib/kernel/qeventdispatcher_winrt_p.h
index 8b998a7958..2672f11123 100644
--- a/src/corelib/kernel/qeventdispatcher_winrt_p.h
+++ b/src/corelib/kernel/qeventdispatcher_winrt_p.h
@@ -57,7 +57,7 @@
#include <qt_windows.h>
-namespace std { template <typename T> class function; }
+#include <functional>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 56217262f2..acb1f54bdf 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -953,7 +953,7 @@ static const QMetaObject *QMetaObject_findMetaObject(const QMetaObject *self, co
return self;
if (self->d.relatedMetaObjects) {
Q_ASSERT(priv(self->d.data)->revision >= 2);
- const QMetaObject * const *e = self->d.relatedMetaObjects;
+ const auto *e = self->d.relatedMetaObjects;
if (e) {
while (*e) {
if (const QMetaObject *m =QMetaObject_findMetaObject((*e), name))
diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp
index d2030f0275..f77c4ce32f 100644
--- a/src/corelib/kernel/qmetaobjectbuilder.cpp
+++ b/src/corelib/kernel/qmetaobjectbuilder.cpp
@@ -747,7 +747,7 @@ void QMetaObjectBuilder::addMetaObject
if ((members & RelatedMetaObjects) != 0) {
Q_ASSERT(priv(prototype->d.data)->revision >= 2);
- const QMetaObject * const *objects = prototype->d.relatedMetaObjects;
+ const auto *objects = prototype->d.relatedMetaObjects;
if (objects) {
while (*objects != 0) {
addRelatedMetaObject(*objects);
@@ -1464,16 +1464,16 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
// Create the relatedMetaObjects block if we need one.
if (d->relatedMetaObjects.size() > 0) {
- ALIGN(size, QMetaObject *);
- const QMetaObject **objects =
- reinterpret_cast<const QMetaObject **>(buf + size);
+ using SuperData = QMetaObject::SuperData;
+ ALIGN(size, SuperData);
+ auto objects = reinterpret_cast<SuperData *>(buf + size);
if (buf) {
meta->d.relatedMetaObjects = objects;
for (index = 0; index < d->relatedMetaObjects.size(); ++index)
objects[index] = d->relatedMetaObjects[index];
- objects[index] = 0;
+ objects[index] = nullptr;
}
- size += sizeof(QMetaObject *) * (d->relatedMetaObjects.size() + 1);
+ size += sizeof(SuperData) * (d->relatedMetaObjects.size() + 1);
}
// Align the final size and return it.
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index a97764ede4..44cce73359 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -216,7 +216,7 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId();
F(QQueue) \
F(QStack) \
F(QSet) \
- F(QLinkedList)
+ /*end*/
#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_2ARG(F) \
F(QHash, class) \
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 5c1ae8aa43..d364ae1087 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -93,12 +93,6 @@ QAbstractDynamicMetaObject::~QAbstractDynamicMetaObject()
{
}
-
-struct QSlotObjectBaseDeleter { // for use with QScopedPointer<QSlotObjectBase,...>
- static void cleanup(QtPrivate::QSlotObjectBase *slot) {
- if (slot) slot->destroyIfLastRef();
- }
-};
static int *queuedConnectionTypes(const QList<QByteArray> &typeNames)
{
int *types = new int [typeNames.count() + 1];
@@ -3380,7 +3374,7 @@ QObjectPrivate::Connection *QMetaObjectPrivate::connect(const QObject *sender,
type &= Qt::UniqueConnection - 1;
}
- QScopedPointer<QObjectPrivate::Connection> c(new QObjectPrivate::Connection);
+ std::unique_ptr<QObjectPrivate::Connection> c{new QObjectPrivate::Connection};
c->sender = s;
c->signal_index = signal_index;
c->receiver.storeRelaxed(r);
@@ -3394,14 +3388,14 @@ QObjectPrivate::Connection *QMetaObjectPrivate::connect(const QObject *sender,
c->argumentTypes.storeRelaxed(types);
c->callFunction = callFunction;
- QObjectPrivate::get(s)->addConnection(signal_index, c.data());
+ QObjectPrivate::get(s)->addConnection(signal_index, c.get());
locker.unlock();
QMetaMethod smethod = QMetaObjectPrivate::signal(smeta, signal_index);
if (smethod.isValid())
s->connectNotify(smethod);
- return c.take();
+ return c.release();
}
/*!
@@ -3791,10 +3785,16 @@ void doActivate(QObject *sender, int signal_index, void **argv)
if (c->isSlotObject) {
c->slotObj->ref();
- QScopedPointer<QtPrivate::QSlotObjectBase, QSlotObjectBaseDeleter> obj(c->slotObj);
+
+ struct Deleter {
+ void operator()(QtPrivate::QSlotObjectBase *slot) const {
+ if (slot) slot->destroyIfLastRef();
+ }
+ };
+ const std::unique_ptr<QtPrivate::QSlotObjectBase, Deleter> obj{c->slotObj};
{
- Q_TRACE_SCOPE(QMetaObject_activate_slot_functor, obj.data());
+ Q_TRACE_SCOPE(QMetaObject_activate_slot_functor, obj.get());
obj->call(receiver, argv);
}
} else if (c->callFunction && c->method_offset <= receiver->metaObject()->methodOffset()) {
@@ -4947,7 +4947,7 @@ QMetaObject::Connection QObjectPrivate::connectImpl(const QObject *sender, int s
type = static_cast<Qt::ConnectionType>(type ^ Qt::UniqueConnection);
}
- QScopedPointer<QObjectPrivate::Connection> c(new QObjectPrivate::Connection);
+ std::unique_ptr<QObjectPrivate::Connection> c{new QObjectPrivate::Connection};
c->sender = s;
c->signal_index = signal_index;
QThreadData *td = r->d_func()->threadData;
@@ -4962,8 +4962,8 @@ QMetaObject::Connection QObjectPrivate::connectImpl(const QObject *sender, int s
c->ownArgumentTypes = false;
}
- QObjectPrivate::get(s)->addConnection(signal_index, c.data());
- QMetaObject::Connection ret(c.take());
+ QObjectPrivate::get(s)->addConnection(signal_index, c.get());
+ QMetaObject::Connection ret(c.release());
locker.unlock();
QMetaMethod method = QMetaObjectPrivate::signal(senderMetaObject, signal_index);
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 9cf1bfed08..95ffc1b2e8 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -486,8 +486,11 @@ class Q_CORE_EXPORT QAbstractMetaCallEvent : public QEvent
{
public:
QAbstractMetaCallEvent(const QObject *sender, int signalId, QSemaphore *semaphore = nullptr)
- : QEvent(MetaCall), signalId_(signalId), sender_(sender), semaphore_(semaphore)
- {}
+ : QEvent(MetaCall), signalId_(signalId), sender_(sender)
+#if QT_CONFIG(thread)
+ , semaphore_(semaphore)
+#endif
+ { Q_UNUSED(semaphore); }
~QAbstractMetaCallEvent();
virtual void placeMetaCall(QObject *object) = 0;
@@ -498,7 +501,9 @@ public:
private:
int signalId_;
const QObject *sender_;
+#if QT_CONFIG(thread)
QSemaphore *semaphore_;
+#endif
};
class Q_CORE_EXPORT QMetaCallEvent : public QAbstractMetaCallEvent
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index ef22b6e67f..dc2d832fe5 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
+** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2019 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -572,13 +572,42 @@ struct Q_CORE_EXPORT QMetaObject
int static_metacall(Call, int, void **) const;
static int metacall(QObject *, Call, int, void **);
+ template <const QMetaObject &MO> static constexpr const QMetaObject *staticMetaObject()
+ {
+ return &MO;
+ }
+
+ struct SuperData {
+ const QMetaObject *direct;
+ SuperData() = default;
+ constexpr SuperData(std::nullptr_t) : direct(nullptr) {}
+ constexpr SuperData(const QMetaObject *mo) : direct(mo) {}
+
+ constexpr const QMetaObject *operator->() const { return operator const QMetaObject *(); }
+
+#ifdef QT_NO_DATA_RELOCATION
+ using Getter = const QMetaObject *(*)();
+ Getter indirect = nullptr;
+ constexpr SuperData(Getter g) : direct(nullptr), indirect(g) {}
+ constexpr operator const QMetaObject *() const
+ { return indirect ? indirect() : direct; }
+ template <const QMetaObject &MO> static constexpr SuperData link()
+ { return SuperData(QMetaObject::staticMetaObject<MO>); }
+#else
+ constexpr operator const QMetaObject *() const
+ { return direct; }
+ template <const QMetaObject &MO> static constexpr SuperData link()
+ { return SuperData(QMetaObject::staticMetaObject<MO>()); }
+#endif
+ };
+
struct { // private data
- const QMetaObject *superdata;
+ SuperData superdata;
const QByteArrayData *stringdata;
const uint *data;
typedef void (*StaticMetacallFunction)(QObject *, QMetaObject::Call, int, void **);
StaticMetacallFunction static_metacall;
- const QMetaObject * const *relatedMetaObjects;
+ const SuperData *relatedMetaObjects;
void *extradata; //reserved for future use
} d;
diff --git a/src/corelib/kernel/qsignalmapper.cpp b/src/corelib/kernel/qsignalmapper.cpp
index 34fea861cd..24b174972f 100644
--- a/src/corelib/kernel/qsignalmapper.cpp
+++ b/src/corelib/kernel/qsignalmapper.cpp
@@ -38,7 +38,6 @@
****************************************************************************/
#include "qglobal.h"
-#if QT_DEPRECATED_SINCE(5, 10)
#include "qsignalmapper.h"
#include "qhash.h"
@@ -64,7 +63,6 @@ public:
/*!
\class QSignalMapper
\inmodule QtCore
- \obsolete The recommended solution is connecting the signal to a lambda.
\brief The QSignalMapper class bundles signals from identifiable senders.
\ingroup objectmodel
@@ -72,7 +70,9 @@ public:
This class collects a set of parameterless signals, and re-emits
them with integer, string or widget parameters corresponding to
- the object that sent the signal.
+ the object that sent the signal. Note that in most cases you can
+ use lambdas for passing custom parameters to slots. This is less
+ costly and will simplify the code.
The class supports the mapping of particular strings or integers
with particular objects using setMapping(). The objects' signals
@@ -314,5 +314,3 @@ void QSignalMapper::map(QObject *sender)
QT_END_NAMESPACE
#include "moc_qsignalmapper.cpp"
-
-#endif
diff --git a/src/corelib/kernel/qsignalmapper.h b/src/corelib/kernel/qsignalmapper.h
index 6c4cfa9627..0da1e8f87d 100644
--- a/src/corelib/kernel/qsignalmapper.h
+++ b/src/corelib/kernel/qsignalmapper.h
@@ -42,8 +42,6 @@
#include <QtCore/qobject.h>
-#if QT_DEPRECATED_SINCE(5, 10)
-
QT_BEGIN_NAMESPACE
class QSignalMapperPrivate;
@@ -53,7 +51,7 @@ class Q_CORE_EXPORT QSignalMapper : public QObject
Q_OBJECT
Q_DECLARE_PRIVATE(QSignalMapper)
public:
- QT_DEPRECATED explicit QSignalMapper(QObject *parent = nullptr);
+ explicit QSignalMapper(QObject *parent = nullptr);
~QSignalMapper();
void setMapping(QObject *sender, int id);
@@ -84,6 +82,4 @@ private:
QT_END_NAMESPACE
-#endif
-
#endif // QSIGNALMAPPER_H
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index 637ef84d21..ddb96ecad6 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -528,7 +528,8 @@ bool QTranslatorPrivate::do_load(const QString &realname, const QString &directo
// memory, so no need to use QFile to copy it again.
Q_ASSERT(!d->resource);
d->resource = new QResource(realname);
- if (resource->isValid() && !resource->isCompressed() && resource->size() >= MagicLength
+ if (resource->isValid() && resource->compressionAlgorithm() == QResource::NoCompression
+ && resource->size() >= MagicLength
&& !memcmp(resource->data(), magic, MagicLength)) {
d->unmapLength = resource->size();
d->unmapPointer = reinterpret_cast<char *>(const_cast<uchar *>(resource->data()));
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index c8cb551863..39b7e4c0ce 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -362,7 +362,7 @@ class Q_CORE_EXPORT QVariant
static inline QVariant fromValue(const T &value)
{ return QVariant(qMetaTypeId<T>(), &value, QTypeInfo<T>::isPointer); }
-#if QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L
+#if (QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L) || defined(Q_CLANG_QDOC)
template<typename... Types>
static inline QVariant fromStdVariant(const std::variant<Types...> &value)
{
diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp
index 00480198bd..4e0c3a511b 100644
--- a/src/corelib/plugin/qpluginloader.cpp
+++ b/src/corelib/plugin/qpluginloader.cpp
@@ -92,7 +92,7 @@ QT_BEGIN_NAMESPACE
but if other instances of QPluginLoader are using the same
library, the call will fail, and unloading will only happen when
every instance has called unload(). Right before the unloading
- happen, the root component will also be deleted.
+ happens, the root component will also be deleted.
See \l{How to Create Qt Plugins} for more information about
how to make your application extensible through plugins.
diff --git a/src/corelib/serialization/qcborarray.cpp b/src/corelib/serialization/qcborarray.cpp
index 28ae40f3df..ca0156e07d 100644
--- a/src/corelib/serialization/qcborarray.cpp
+++ b/src/corelib/serialization/qcborarray.cpp
@@ -273,7 +273,7 @@ QCborValue QCborArray::at(qsizetype i) const
not be empty.
QCborValueRef has the exact same API as \l QCborValue, with one important
- difference: if you assign new values to it, this map will be updated with
+ difference: if you assign new values to it, this array will be updated with
that new value.
\sa operator[](), at(), last(), insert(), prepend(), append(),
@@ -287,7 +287,7 @@ QCborValue QCborArray::at(qsizetype i) const
not be empty.
QCborValueRef has the exact same API as \l QCborValue, with one important
- difference: if you assign new values to it, this map will be updated with
+ difference: if you assign new values to it, this array will be updated with
that new value.
\sa operator[](), at(), first(), insert(), prepend(), append(),
@@ -302,7 +302,7 @@ QCborValue QCborArray::at(qsizetype i) const
with undefined entries, until it has an entry at the specified index.
QCborValueRef has the exact same API as \l QCborValue, with one important
- difference: if you assign new values to it, this map will be updated with
+ difference: if you assign new values to it, this array will be updated with
that new value.
\sa at(), first(), last(), insert(), prepend(), append(),
diff --git a/src/corelib/serialization/qcborstream.cpp b/src/corelib/serialization/qcborstream.cpp
index 078c14a32d..c598eee213 100644
--- a/src/corelib/serialization/qcborstream.cpp
+++ b/src/corelib/serialization/qcborstream.cpp
@@ -1972,7 +1972,15 @@ inline void QCborStreamReader::preparse()
if (lastError() == QCborError::NoError) {
type_ = cbor_value_get_type(&d->currentElement);
- if (type_ != CborInvalidType) {
+ if (type_ == CborInvalidType) {
+ // We may have reached the end.
+ if (d->device && d->containerStack.isEmpty()) {
+ d->buffer.clear();
+ if (d->bufferStart)
+ d->device->skip(d->bufferStart);
+ d->bufferStart = 0;
+ }
+ } else {
d->lastError = {};
// Undo the type mapping that TinyCBOR does (we have an explicit type
// for negative integer and we don't have separate types for Boolean,
diff --git a/src/corelib/serialization/qjson.cpp b/src/corelib/serialization/qjson.cpp
index d74ffb2a20..76f1eae1ce 100644
--- a/src/corelib/serialization/qjson.cpp
+++ b/src/corelib/serialization/qjson.cpp
@@ -175,7 +175,7 @@ void Base::removeItems(int pos, int numItems)
length -= numItems;
}
-int Object::indexOf(const QString &key, bool *exists) const
+int Object::indexOf(QStringView key, bool *exists) const
{
int min = 0;
int n = length;
@@ -257,7 +257,7 @@ bool Array::isValid(int maxSize) const
}
-bool Entry::operator ==(const QString &key) const
+bool Entry::operator ==(QStringView key) const
{
if (value.latinKey)
return (shallowLatin1Key() == key);
@@ -270,7 +270,7 @@ bool Entry::operator==(QLatin1String key) const
if (value.latinKey)
return shallowLatin1Key() == key;
else
- return shallowKey() == key;
+ return shallowKey() == QString(key); // ### conversion to QString
}
bool Entry::operator ==(const Entry &other) const
diff --git a/src/corelib/serialization/qjson_p.h b/src/corelib/serialization/qjson_p.h
index 9de53d5b74..7978bed7da 100644
--- a/src/corelib/serialization/qjson_p.h
+++ b/src/corelib/serialization/qjson_p.h
@@ -66,11 +66,13 @@
#include <limits.h>
#include <limits>
+#include <type_traits>
QT_BEGIN_NAMESPACE
// in qstring.cpp
void qt_to_latin1_unchecked(uchar *dst, const ushort *uc, qsizetype len);
+void qt_from_latin1(ushort *dst, const char *str, size_t size) noexcept;
/*
This defines a binary data structure for Json data. The data structure is optimised for fast reading
@@ -153,16 +155,24 @@ typedef qle_uint offset;
// round the size up to the next 4 byte boundary
inline int alignedSize(int size) { return (size + 3) & ~3; }
-static inline bool useCompressed(const QString &s)
+const int MaxLatin1Length = 0x7fff;
+
+static inline bool useCompressed(QStringView s)
{
- if (s.length() >= 0x8000)
+ if (s.length() > MaxLatin1Length)
return false;
return QtPrivate::isLatin1(s);
}
-static inline int qStringSize(const QString &string, bool compress)
+static inline bool useCompressed(QLatin1String s)
+{
+ return s.size() <= MaxLatin1Length;
+}
+
+template <typename T>
+static inline int qStringSize(T string, bool compress)
{
- int l = 2 + string.length();
+ int l = 2 + string.size();
if (!compress)
l *= 2;
return alignedSize(l);
@@ -214,37 +224,49 @@ public:
return maxSize >= 0 && uint(d->length) <= maxSize / sizeof(ushort);
}
- inline String &operator=(const QString &str)
+ inline String &operator=(QStringView str)
{
d->length = str.length();
+ qToLittleEndian<quint16>(str.utf16(), str.length(), d->utf16);
+ fillTrailingZeros();
+ return *this;
+ }
+
+ inline String &operator=(QLatin1String str)
+ {
+ d->length = str.size();
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- const ushort *uc = (const ushort *)str.unicode();
- for (int i = 0; i < str.length(); ++i)
- d->utf16[i] = uc[i];
+ for (int i = 0; i < str.size(); ++i)
+ d->utf16[i] = str[i].unicode();
#else
- memcpy(d->utf16, str.unicode(), str.length()*sizeof(ushort));
+ qt_from_latin1((ushort *)d->utf16, str.data(), str.size());
#endif
- if (str.length() & 1)
- d->utf16[str.length()] = 0;
+ fillTrailingZeros();
return *this;
}
- inline bool operator ==(const QString &str) const {
+ void fillTrailingZeros()
+ {
+ if (d->length & 1)
+ d->utf16[d->length] = 0;
+ }
+
+ inline bool operator ==(QStringView str) const {
int slen = str.length();
int l = d->length;
if (slen != l)
return false;
- const ushort *s = (const ushort *)str.constData();
+ const ushort *s = (const ushort *)str.utf16();
const qle_ushort *a = d->utf16;
const ushort *b = s;
while (l-- && *a == *b)
a++,b++;
return (l == -1);
}
- inline bool operator !=(const QString &str) const {
+ inline bool operator !=(QStringView str) const {
return !operator ==(str);
}
- inline bool operator >=(const QString &str) const {
+ inline bool operator >=(QStringView str) const {
// ###
return toString() >= str;
}
@@ -292,18 +314,34 @@ public:
return byteSize() <= maxSize;
}
- inline Latin1String &operator=(const QString &str)
+ inline Latin1String &operator=(QStringView str)
{
int len = d->length = str.length();
uchar *l = (uchar *)d->latin1;
- const ushort *uc = (const ushort *)str.unicode();
+ const ushort *uc = (const ushort *)str.utf16();
qt_to_latin1_unchecked(l, uc, len);
- for ( ; (quintptr)(l+len) & 0x3; ++len)
- l[len] = 0;
+ fillTrailingZeros();
return *this;
}
+ inline Latin1String &operator=(QLatin1String str)
+ {
+ int len = d->length = str.size();
+ uchar *l = (uchar *)d->latin1;
+ memcpy(l, str.data(), len);
+
+ fillTrailingZeros();
+ return *this;
+ }
+
+ void fillTrailingZeros()
+ {
+ uchar *l = (uchar *)d->latin1;
+ for (int len = d->length; (quintptr)(l + len) & 0x3; ++len)
+ l[len] = 0;
+ }
+
QLatin1String toQLatin1String() const noexcept {
return QLatin1String(d->latin1, d->length);
}
@@ -351,11 +389,11 @@ public:
{ \
return lhs.toQLatin1String() op rhs; \
} \
- inline bool operator op(const QString &lhs, Latin1String rhs) noexcept \
+ inline bool operator op(QStringView lhs, Latin1String rhs) noexcept \
{ \
return lhs op rhs.toQLatin1String(); \
} \
- inline bool operator op(Latin1String lhs, const QString &rhs) noexcept \
+ inline bool operator op(Latin1String lhs, QStringView rhs) noexcept \
{ \
return lhs.toQLatin1String() op rhs; \
} \
@@ -419,7 +457,8 @@ inline bool String::operator<(const Latin1String &str) const
}
-static inline void copyString(char *dest, const QString &str, bool compress)
+template <typename T>
+static inline void copyString(char *dest, T str, bool compress)
{
if (compress) {
Latin1String string(dest);
@@ -469,7 +508,7 @@ public:
Entry *entryAt(int i) const {
return reinterpret_cast<Entry *>(((char *)this) + table()[i]);
}
- int indexOf(const QString &key, bool *exists) const;
+ int indexOf(QStringView key, bool *exists) const;
int indexOf(QLatin1String key, bool *exists) const;
bool isValid(int maxSize) const;
@@ -577,9 +616,9 @@ public:
return shallowKey().isValid(maxSize);
}
- bool operator ==(const QString &key) const;
- inline bool operator !=(const QString &key) const { return !operator ==(key); }
- inline bool operator >=(const QString &key) const;
+ bool operator ==(QStringView key) const;
+ inline bool operator !=(QStringView key) const { return !operator ==(key); }
+ inline bool operator >=(QStringView key) const;
bool operator==(QLatin1String key) const;
inline bool operator!=(QLatin1String key) const { return !operator ==(key); }
@@ -589,7 +628,7 @@ public:
bool operator >=(const Entry &other) const;
};
-inline bool Entry::operator >=(const QString &key) const
+inline bool Entry::operator >=(QStringView key) const
{
if (value.latinKey)
return (shallowLatin1Key() >= key);
@@ -602,10 +641,10 @@ inline bool Entry::operator >=(QLatin1String key) const
if (value.latinKey)
return shallowLatin1Key() >= key;
else
- return shallowKey() >= key;
+ return shallowKey() >= QString(key); // ### conversion to QString
}
-inline bool operator <(const QString &key, const Entry &e)
+inline bool operator <(QStringView key, const Entry &e)
{ return e >= key; }
inline bool operator<(QLatin1String key, const Entry &e)
diff --git a/src/corelib/serialization/qjsonarray.cpp b/src/corelib/serialization/qjsonarray.cpp
index 6b327619ad..9636ac5856 100644
--- a/src/corelib/serialization/qjsonarray.cpp
+++ b/src/corelib/serialization/qjsonarray.cpp
@@ -845,7 +845,7 @@ bool QJsonArray::operator!=(const QJsonArray &other) const
The return value is of type QJsonValueRef, a helper class for QJsonArray
and QJsonObject. When you get an object of type QJsonValueRef, you can
use it as if it were a reference to a QJsonValue. If you assign to it,
- the assignment will apply to the character in the QJsonArray of QJsonObject
+ the assignment will apply to the element in the QJsonArray or QJsonObject
from which you got the reference.
\sa operator+()
diff --git a/src/corelib/serialization/qjsoncbor.cpp b/src/corelib/serialization/qjsoncbor.cpp
index e0c390f610..d6a0c8c48a 100644
--- a/src/corelib/serialization/qjsoncbor.cpp
+++ b/src/corelib/serialization/qjsoncbor.cpp
@@ -421,7 +421,7 @@ QJsonArray QCborArray::toJsonArray() const
}
/*!
- Recursively converts every \l QCborValue value in this array to JSON using
+ Recursively converts every \l QCborValue value in this map to JSON using
QCborValue::toJsonValue() and creates a string key for all keys that aren't
strings, then returns the corresponding QJsonObject composed of those
associations.
diff --git a/src/corelib/serialization/qjsondocument.cpp b/src/corelib/serialization/qjsondocument.cpp
index f8027efb58..193b80ee22 100644
--- a/src/corelib/serialization/qjsondocument.cpp
+++ b/src/corelib/serialization/qjsondocument.cpp
@@ -544,6 +544,7 @@ void QJsonDocument::setArray(const QJsonArray &array)
d->ref.ref();
}
+#if QT_STRINGVIEW_LEVEL < 2
/*!
Returns a QJsonValue representing the value for the key \a key.
@@ -558,6 +559,16 @@ void QJsonDocument::setArray(const QJsonArray &array)
*/
const QJsonValue QJsonDocument::operator[](const QString &key) const
{
+ return (*this)[QStringView(key)];
+}
+#endif
+
+/*!
+ \overload
+ \since 5.14
+*/
+const QJsonValue QJsonDocument::operator[](QStringView key) const
+{
if (!isObject())
return QJsonValue(QJsonValue::Undefined);
diff --git a/src/corelib/serialization/qjsondocument.h b/src/corelib/serialization/qjsondocument.h
index a8006a6cc5..a8e7485f5d 100644
--- a/src/corelib/serialization/qjsondocument.h
+++ b/src/corelib/serialization/qjsondocument.h
@@ -146,7 +146,10 @@ public:
void setObject(const QJsonObject &object);
void setArray(const QJsonArray &array);
+#if QT_STRINGVIEW_LEVEL < 2
const QJsonValue operator[](const QString &key) const;
+#endif
+ const QJsonValue operator[](QStringView key) const;
const QJsonValue operator[](QLatin1String key) const;
const QJsonValue operator[](int i) const;
diff --git a/src/corelib/serialization/qjsonobject.cpp b/src/corelib/serialization/qjsonobject.cpp
index c1a6328b2f..329bc4d2c9 100644
--- a/src/corelib/serialization/qjsonobject.cpp
+++ b/src/corelib/serialization/qjsonobject.cpp
@@ -377,6 +377,7 @@ bool QJsonObject::isEmpty() const
return !o->length;
}
+#if QT_STRINGVIEW_LEVEL < 2
/*!
Returns a QJsonValue representing the value for the key \a key.
@@ -386,14 +387,17 @@ bool QJsonObject::isEmpty() const
*/
QJsonValue QJsonObject::value(const QString &key) const
{
- if (!d)
- return QJsonValue(QJsonValue::Undefined);
+ return value(QStringView(key));
+}
+#endif
- bool keyExists;
- int i = o->indexOf(key, &keyExists);
- if (!keyExists)
- return QJsonValue(QJsonValue::Undefined);
- return QJsonValue(d, o, o->entryAt(i)->value);
+/*!
+ \overload
+ \since 5.14
+*/
+QJsonValue QJsonObject::value(QStringView key) const
+{
+ return valueImpl(key);
}
/*!
@@ -402,6 +406,15 @@ QJsonValue QJsonObject::value(const QString &key) const
*/
QJsonValue QJsonObject::value(QLatin1String key) const
{
+ return valueImpl(key);
+}
+
+/*!
+ \internal
+*/
+template <typename T>
+QJsonValue QJsonObject::valueImpl(T key) const
+{
if (!d)
return QJsonValue(QJsonValue::Undefined);
@@ -412,6 +425,7 @@ QJsonValue QJsonObject::value(QLatin1String key) const
return QJsonValue(d, o, o->entryAt(i)->value);
}
+#if QT_STRINGVIEW_LEVEL < 2
/*!
Returns a QJsonValue representing the value for the key \a key.
@@ -423,8 +437,16 @@ QJsonValue QJsonObject::value(QLatin1String key) const
*/
QJsonValue QJsonObject::operator [](const QString &key) const
{
- return value(key);
+ return (*this)[QStringView(key)];
}
+#endif
+
+/*!
+ \fn QJsonValue QJsonObject::operator [](QStringView key) const
+
+ \overload
+ \since 5.14
+*/
/*!
\fn QJsonValue QJsonObject::operator [](QLatin1String key) const
@@ -433,6 +455,7 @@ QJsonValue QJsonObject::operator [](const QString &key) const
\since 5.7
*/
+#if QT_STRINGVIEW_LEVEL < 2
/*!
Returns a reference to the value for \a key.
@@ -446,14 +469,17 @@ QJsonValue QJsonObject::operator [](const QString &key) const
*/
QJsonValueRef QJsonObject::operator [](const QString &key)
{
- // ### somewhat inefficient, as we lookup the key twice if it doesn't yet exist
- bool keyExists = false;
- int index = o ? o->indexOf(key, &keyExists) : -1;
- if (!keyExists) {
- iterator i = insert(key, QJsonValue());
- index = i.i;
- }
- return QJsonValueRef(this, index);
+ return (*this)[QStringView(key)];
+}
+#endif
+
+/*!
+ \overload
+ \since 5.14
+*/
+QJsonValueRef QJsonObject::operator [](QStringView key)
+{
+ return atImpl(key);
}
/*!
@@ -462,10 +488,25 @@ QJsonValueRef QJsonObject::operator [](const QString &key)
*/
QJsonValueRef QJsonObject::operator [](QLatin1String key)
{
- // ### optimize me
- return operator[](QString(key));
+ return atImpl(key);
+}
+
+/*!
+ \internal
+*/
+template <typename T>
+QJsonValueRef QJsonObject::atImpl(T key)
+{
+ bool keyExists = false;
+ int index = o ? o->indexOf(key, &keyExists) : 0;
+ if (!keyExists) {
+ iterator i = insertAt(index, key, QJsonValue(), false);
+ index = i.i;
+ }
+ return QJsonValueRef(this, index);
}
+#if QT_STRINGVIEW_LEVEL < 2
/*!
Inserts a new item with the key \a key and a value of \a value.
@@ -481,10 +522,49 @@ QJsonValueRef QJsonObject::operator [](QLatin1String key)
*/
QJsonObject::iterator QJsonObject::insert(const QString &key, const QJsonValue &value)
{
+ return insert(QStringView(key), value);
+}
+#endif
+
+/*!
+ \overload
+ \since 5.14
+*/
+QJsonObject::iterator QJsonObject::insert(QStringView key, const QJsonValue &value)
+{
+ return insertImpl(key, value);
+}
+
+/*!
+ \overload
+ \since 5.14
+*/
+QJsonObject::iterator QJsonObject::insert(QLatin1String key, const QJsonValue &value)
+{
+ return insertImpl(key, value);
+}
+
+/*!
+ \internal
+*/
+template <typename T>
+QJsonObject::iterator QJsonObject::insertImpl(T key, const QJsonValue &value)
+{
if (value.t == QJsonValue::Undefined) {
remove(key);
return end();
}
+ bool keyExists = false;
+ int pos = o ? o->indexOf(key, &keyExists) : 0;
+ return insertAt(pos, key, value, keyExists);
+}
+
+/*!
+ \internal
+ */
+template <typename T>
+QJsonObject::iterator QJsonObject::insertAt(int pos, T key, const QJsonValue &value, bool keyExists)
+{
QJsonValue val = value;
bool latinOrIntValue;
@@ -500,8 +580,6 @@ QJsonObject::iterator QJsonObject::insert(const QString &key, const QJsonValue &
if (!o->length)
o->tableOffset = sizeof(QJsonPrivate::Object);
- bool keyExists = false;
- int pos = o->indexOf(key, &keyExists);
if (keyExists)
++d->compactionCounter;
@@ -518,12 +596,12 @@ QJsonObject::iterator QJsonObject::insert(const QString &key, const QJsonValue &
if (valueSize)
QJsonPrivate::Value::copyData(val, (char *)e + valueOffset, latinOrIntValue);
- if (d->compactionCounter > 32u && d->compactionCounter >= unsigned(o->length) / 2u)
- compact();
+ compactIfNeeded();
return iterator(this, pos);
}
+#if QT_STRINGVIEW_LEVEL < 2
/*!
Removes \a key from the object.
@@ -531,6 +609,34 @@ QJsonObject::iterator QJsonObject::insert(const QString &key, const QJsonValue &
*/
void QJsonObject::remove(const QString &key)
{
+ remove(QStringView(key));
+}
+#endif
+
+/*!
+ \overload
+ \since 5.14
+*/
+void QJsonObject::remove(QStringView key)
+{
+ removeImpl(key);
+}
+
+/*!
+ \overload
+ \since 5.14
+*/
+void QJsonObject::remove(QLatin1String key)
+{
+ removeImpl(key);
+}
+
+/*!
+ \internal
+*/
+template <typename T>
+void QJsonObject::removeImpl(T key)
+{
if (!d)
return;
@@ -539,13 +645,10 @@ void QJsonObject::remove(const QString &key)
if (!keyExists)
return;
- detach2();
- o->removeItems(index, 1);
- ++d->compactionCounter;
- if (d->compactionCounter > 32u && d->compactionCounter >= unsigned(o->length) / 2u)
- compact();
+ removeAt(index);
}
+#if QT_STRINGVIEW_LEVEL < 2
/*!
Removes \a key from the object.
@@ -557,6 +660,34 @@ void QJsonObject::remove(const QString &key)
*/
QJsonValue QJsonObject::take(const QString &key)
{
+ return take(QStringView(key));
+}
+#endif
+
+/*!
+ \overload
+ \since 5.14
+*/
+QJsonValue QJsonObject::take(QStringView key)
+{
+ return takeImpl(key);
+}
+
+/*!
+ \overload
+ \since 5.14
+*/
+QJsonValue QJsonObject::take(QLatin1String key)
+{
+ return takeImpl(key);
+}
+
+/*!
+ \internal
+*/
+template <typename T>
+QJsonValue QJsonObject::takeImpl(T key)
+{
if (!o)
return QJsonValue(QJsonValue::Undefined);
@@ -566,15 +697,12 @@ QJsonValue QJsonObject::take(const QString &key)
return QJsonValue(QJsonValue::Undefined);
QJsonValue v(d, o, o->entryAt(index)->value);
- detach2();
- o->removeItems(index, 1);
- ++d->compactionCounter;
- if (d->compactionCounter > 32u && d->compactionCounter >= unsigned(o->length) / 2u)
- compact();
+ removeAt(index);
return v;
}
+#if QT_STRINGVIEW_LEVEL < 2
/*!
Returns \c true if the object contains key \a key.
@@ -582,12 +710,17 @@ QJsonValue QJsonObject::take(const QString &key)
*/
bool QJsonObject::contains(const QString &key) const
{
- if (!o)
- return false;
+ return contains(QStringView(key));
+}
+#endif
- bool keyExists;
- o->indexOf(key, &keyExists);
- return keyExists;
+/*!
+ \overload
+ \since 5.14
+*/
+bool QJsonObject::contains(QStringView key) const
+{
+ return containsImpl(key);
}
/*!
@@ -596,6 +729,15 @@ bool QJsonObject::contains(const QString &key) const
*/
bool QJsonObject::contains(QLatin1String key) const
{
+ return containsImpl(key);
+}
+
+/*!
+ \internal
+*/
+template <typename T>
+bool QJsonObject::containsImpl(T key) const
+{
if (!o)
return false;
@@ -652,15 +794,13 @@ QJsonObject::iterator QJsonObject::erase(QJsonObject::iterator it)
int index = it.i;
- o->removeItems(index, 1);
- ++d->compactionCounter;
- if (d->compactionCounter > 32u && d->compactionCounter >= unsigned(o->length) / 2u)
- compact();
+ removeAt(index);
// iterator hasn't changed
return it;
}
+#if QT_STRINGVIEW_LEVEL < 2
/*!
Returns an iterator pointing to the item with key \a key in the
map.
@@ -670,12 +810,17 @@ QJsonObject::iterator QJsonObject::erase(QJsonObject::iterator it)
*/
QJsonObject::iterator QJsonObject::find(const QString &key)
{
- bool keyExists = false;
- int index = o ? o->indexOf(key, &keyExists) : 0;
- if (!keyExists)
- return end();
- detach2();
- return iterator(this, index);
+ return find(QStringView(key));
+}
+#endif
+
+/*!
+ \overload
+ \since 5.14
+*/
+QJsonObject::iterator QJsonObject::find(QStringView key)
+{
+ return findImpl(key);
}
/*!
@@ -684,6 +829,15 @@ QJsonObject::iterator QJsonObject::find(const QString &key)
*/
QJsonObject::iterator QJsonObject::find(QLatin1String key)
{
+ return findImpl(key);
+}
+
+/*!
+ \internal
+*/
+template <typename T>
+QJsonObject::iterator QJsonObject::findImpl(T key)
+{
bool keyExists = false;
int index = o ? o->indexOf(key, &keyExists) : 0;
if (!keyExists)
@@ -692,10 +846,18 @@ QJsonObject::iterator QJsonObject::find(QLatin1String key)
return iterator(this, index);
}
+#if QT_STRINGVIEW_LEVEL < 2
/*! \fn QJsonObject::const_iterator QJsonObject::find(const QString &key) const
\overload
*/
+#endif
+
+/*! \fn QJsonObject::const_iterator QJsonObject::find(QStringView key) const
+
+ \overload
+ \since 5.14
+*/
/*! \fn QJsonObject::const_iterator QJsonObject::find(QLatin1String key) const
@@ -703,6 +865,7 @@ QJsonObject::iterator QJsonObject::find(QLatin1String key)
\since 5.7
*/
+#if QT_STRINGVIEW_LEVEL < 2
/*!
Returns a const iterator pointing to the item with key \a key in the
map.
@@ -712,11 +875,17 @@ QJsonObject::iterator QJsonObject::find(QLatin1String key)
*/
QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const
{
- bool keyExists = false;
- int index = o ? o->indexOf(key, &keyExists) : 0;
- if (!keyExists)
- return end();
- return const_iterator(this, index);
+ return constFind(QStringView(key));
+}
+#endif
+
+/*!
+ \overload
+ \since 5.14
+*/
+QJsonObject::const_iterator QJsonObject::constFind(QStringView key) const
+{
+ return constFindImpl(key);
}
/*!
@@ -725,6 +894,15 @@ QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const
*/
QJsonObject::const_iterator QJsonObject::constFind(QLatin1String key) const
{
+ return constFindImpl(key);
+}
+
+/*!
+ \internal
+*/
+template <typename T>
+QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const
+{
bool keyExists = false;
int index = o ? o->indexOf(key, &keyExists) : 0;
if (!keyExists)
@@ -1261,6 +1439,15 @@ void QJsonObject::compact()
/*!
\internal
*/
+void QJsonObject::compactIfNeeded()
+{
+ if (d->compactionCounter > 32u && d->compactionCounter >= unsigned(o->length) / 2u)
+ compact();
+}
+
+/*!
+ \internal
+ */
QString QJsonObject::keyAt(int i) const
{
Q_ASSERT(o && i >= 0 && i < (int)o->length);
@@ -1289,7 +1476,21 @@ void QJsonObject::setValueAt(int i, const QJsonValue &val)
Q_ASSERT(o && i >= 0 && i < (int)o->length);
QJsonPrivate::Entry *e = o->entryAt(i);
- insert(e->key(), val);
+ if (val.t == QJsonValue::Undefined)
+ removeAt(i);
+ else
+ insertAt(i, e->key(), val, true);
+}
+
+/*!
+ \internal
+ */
+void QJsonObject::removeAt(int index)
+{
+ detach2();
+ o->removeItems(index, 1);
+ ++d->compactionCounter;
+ compactIfNeeded();
}
uint qHash(const QJsonObject &object, uint seed)
diff --git a/src/corelib/serialization/qjsonobject.h b/src/corelib/serialization/qjsonobject.h
index d8e2ab9ca7..05463f6f36 100644
--- a/src/corelib/serialization/qjsonobject.h
+++ b/src/corelib/serialization/qjsonobject.h
@@ -100,16 +100,28 @@ public:
inline int length() const { return size(); }
bool isEmpty() const;
+#if QT_STRINGVIEW_LEVEL < 2
QJsonValue value(const QString &key) const;
- QJsonValue value(QLatin1String key) const;
QJsonValue operator[] (const QString &key) const;
- QJsonValue operator[] (QLatin1String key) const { return value(key); }
QJsonValueRef operator[] (const QString &key);
+#endif
+ QJsonValue value(QStringView key) const;
+ QJsonValue value(QLatin1String key) const;
+ QJsonValue operator[] (QStringView key) const { return value(key); }
+ QJsonValue operator[] (QLatin1String key) const { return value(key); }
+ QJsonValueRef operator[] (QStringView key);
QJsonValueRef operator[] (QLatin1String key);
+#if QT_STRINGVIEW_LEVEL < 2
void remove(const QString &key);
QJsonValue take(const QString &key);
bool contains(const QString &key) const;
+#endif
+ void remove(QStringView key);
+ void remove(QLatin1String key);
+ QJsonValue take(QStringView key);
+ QJsonValue take(QLatin1String key);
+ bool contains(QStringView key) const;
bool contains(QLatin1String key) const;
bool operator==(const QJsonObject &other) const;
@@ -218,13 +230,20 @@ public:
// more Qt
typedef iterator Iterator;
typedef const_iterator ConstIterator;
+#if QT_STRINGVIEW_LEVEL < 2
iterator find(const QString &key);
- iterator find(QLatin1String key);
const_iterator find(const QString &key) const { return constFind(key); }
- const_iterator find(QLatin1String key) const { return constFind(key); }
const_iterator constFind(const QString &key) const;
- const_iterator constFind(QLatin1String key) const;
iterator insert(const QString &key, const QJsonValue &value);
+#endif
+ iterator find(QStringView key);
+ iterator find(QLatin1String key);
+ const_iterator find(QStringView key) const { return constFind(key); }
+ const_iterator find(QLatin1String key) const { return constFind(key); }
+ const_iterator constFind(QStringView key) const;
+ const_iterator constFind(QLatin1String key) const;
+ iterator insert(QStringView key, const QJsonValue &value);
+ iterator insert(QLatin1String key, const QJsonValue &value);
// STL compatibility
typedef QJsonValue mapped_type;
@@ -247,10 +266,22 @@ private:
void detach(uint reserve = 0);
bool detach2(uint reserve = 0);
void compact();
+ void compactIfNeeded();
+
+ template <typename T> QJsonValue valueImpl(T key) const;
+ template <typename T> QJsonValueRef atImpl(T key);
+ template <typename T> void removeImpl(T key);
+ template <typename T> QJsonValue takeImpl(T key);
+ template <typename T> bool containsImpl(T key) const;
+ template <typename T> iterator findImpl(T key);
+ template <typename T> const_iterator constFindImpl(T key) const;
+ template <typename T> iterator insertImpl(T key, const QJsonValue &value);
QString keyAt(int i) const;
QJsonValue valueAt(int i) const;
void setValueAt(int i, const QJsonValue &val);
+ void removeAt(int i);
+ template <typename T> iterator insertAt(int i, T key, const QJsonValue &val, bool exists);
QJsonPrivate::Data *d;
QJsonPrivate::Object *o;
diff --git a/src/corelib/serialization/qjsonvalue.cpp b/src/corelib/serialization/qjsonvalue.cpp
index 0bd28581f3..5f07a6a03e 100644
--- a/src/corelib/serialization/qjsonvalue.cpp
+++ b/src/corelib/serialization/qjsonvalue.cpp
@@ -694,6 +694,7 @@ QJsonObject QJsonValue::toObject() const
return toObject(QJsonObject());
}
+#if QT_STRINGVIEW_LEVEL < 2
/*!
Returns a QJsonValue representing the value for the key \a key.
@@ -708,6 +709,16 @@ QJsonObject QJsonValue::toObject() const
*/
const QJsonValue QJsonValue::operator[](const QString &key) const
{
+ return (*this)[QStringView(key)];
+}
+#endif
+
+/*!
+ \overload
+ \since 5.14
+*/
+const QJsonValue QJsonValue::operator[](QStringView key) const
+{
if (!isObject())
return QJsonValue(QJsonValue::Undefined);
diff --git a/src/corelib/serialization/qjsonvalue.h b/src/corelib/serialization/qjsonvalue.h
index 37d84f9e60..430fa06c0f 100644
--- a/src/corelib/serialization/qjsonvalue.h
+++ b/src/corelib/serialization/qjsonvalue.h
@@ -137,7 +137,10 @@ public:
QJsonObject toObject() const;
QJsonObject toObject(const QJsonObject &defaultValue) const;
+#if QT_STRINGVIEW_LEVEL < 2
const QJsonValue operator[](const QString &key) const;
+#endif
+ const QJsonValue operator[](QStringView key) const;
const QJsonValue operator[](QLatin1String key) const;
const QJsonValue operator[](int i) const;
diff --git a/src/corelib/serialization/qtextstream.cpp b/src/corelib/serialization/qtextstream.cpp
index 9d4bc223ab..a675c3cede 100644
--- a/src/corelib/serialization/qtextstream.cpp
+++ b/src/corelib/serialization/qtextstream.cpp
@@ -888,7 +888,7 @@ inline bool QTextStreamPrivate::getChar(QChar *ch)
if ((string && stringOffset == string->size())
|| (device && readBuffer.isEmpty() && !fillReadBuffer())) {
if (ch)
- *ch = 0;
+ *ch = QChar();
return false;
}
if (ch)
diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp
index be3a476cb2..500e0aa6be 100644
--- a/src/corelib/serialization/qxmlstream.cpp
+++ b/src/corelib/serialization/qxmlstream.cpp
@@ -782,8 +782,8 @@ QXmlStreamPrivateTagStack::QXmlStreamPrivateTagStack()
tagStackStringStorage.reserve(32);
tagStackStringStorageSize = 0;
NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push();
- namespaceDeclaration.prefix = addToStringStorage(QStringViewLiteral("xml"));
- namespaceDeclaration.namespaceUri = addToStringStorage(QStringViewLiteral("http://www.w3.org/XML/1998/namespace"));
+ namespaceDeclaration.prefix = addToStringStorage(u"xml");
+ namespaceDeclaration.namespaceUri = addToStringStorage(u"http://www.w3.org/XML/1998/namespace");
initialTagStackStringStorageSize = tagStackStringStorageSize;
}
@@ -1423,7 +1423,7 @@ inline int QXmlStreamReaderPrivate::fastScanNMTOKEN()
int n = 0;
uint c;
while ((c = getChar()) != StreamEOF) {
- if (fastDetermineNameChar(c) == NotName) {
+ if (fastDetermineNameChar(QChar(c)) == NotName) {
putChar(c);
return n;
} else {
diff --git a/src/corelib/tools/UNICODE_LICENSE.txt b/src/corelib/text/UNICODE_LICENSE.txt
index 1c73202b74..1c73202b74 100644
--- a/src/corelib/tools/UNICODE_LICENSE.txt
+++ b/src/corelib/text/UNICODE_LICENSE.txt
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/text/qbytearray.cpp
index ecbb4743af..c50e087c10 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/text/qbytearray.cpp
@@ -40,7 +40,7 @@
#include "qbytearray.h"
#include "qbytearraymatcher.h"
-#include "qtools_p.h"
+#include "private/qtools_p.h"
#include "qstring.h"
#include "qlist.h"
#include "qlocale.h"
@@ -972,12 +972,11 @@ QByteArray qUncompress(const uchar* data, int nbytes)
\section2 8-bit Character Comparisons
In QByteArray, the notion of uppercase and lowercase and of which
- character is greater than or less than another character is
- locale dependent. This affects functions that support a case
+ character is greater than or less than another character is done
+ in the Latin-1 locale. This affects functions that support a case
insensitive option or that compare or lowercase or uppercase
their arguments. Case insensitive operations and comparisons will
- be accurate if both strings contain only ASCII characters. (If \c
- $LC_CTYPE is set, most Unix systems do "the right thing".)
+ be accurate if both strings contain only Latin-1 characters.
Functions that this affects include contains(), indexOf(),
lastIndexOf(), operator<(), operator<=(), operator>(),
operator>=(), isLower(), isUpper(), toLower() and toUpper().
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/text/qbytearray.h
index 7c571706d8..7c571706d8 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/text/qbytearray.h
diff --git a/src/corelib/tools/qbytearray_p.h b/src/corelib/text/qbytearray_p.h
index 6ebff739cd..3c6257f786 100644
--- a/src/corelib/tools/qbytearray_p.h
+++ b/src/corelib/text/qbytearray_p.h
@@ -52,7 +52,7 @@
//
#include <QtCore/qbytearray.h>
-#include "qtools_p.h"
+#include "private/qtools_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/tools/qbytearraylist.cpp b/src/corelib/text/qbytearraylist.cpp
index d04555ed4d..d04555ed4d 100644
--- a/src/corelib/tools/qbytearraylist.cpp
+++ b/src/corelib/text/qbytearraylist.cpp
diff --git a/src/corelib/tools/qbytearraylist.h b/src/corelib/text/qbytearraylist.h
index 0250b649b8..0250b649b8 100644
--- a/src/corelib/tools/qbytearraylist.h
+++ b/src/corelib/text/qbytearraylist.h
diff --git a/src/corelib/tools/qbytearraymatcher.cpp b/src/corelib/text/qbytearraymatcher.cpp
index 72e09226af..72e09226af 100644
--- a/src/corelib/tools/qbytearraymatcher.cpp
+++ b/src/corelib/text/qbytearraymatcher.cpp
diff --git a/src/corelib/tools/qbytearraymatcher.h b/src/corelib/text/qbytearraymatcher.h
index 0eedfc1d20..0eedfc1d20 100644
--- a/src/corelib/tools/qbytearraymatcher.h
+++ b/src/corelib/text/qbytearraymatcher.h
diff --git a/src/corelib/tools/qbytedata_p.h b/src/corelib/text/qbytedata_p.h
index b319d75811..b319d75811 100644
--- a/src/corelib/tools/qbytedata_p.h
+++ b/src/corelib/text/qbytedata_p.h
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/text/qchar.cpp
index e097e4a5fe..0c190c6a3d 100644
--- a/src/corelib/tools/qchar.cpp
+++ b/src/corelib/text/qchar.cpp
@@ -1885,11 +1885,11 @@ static void composeHelper(QString *str, QChar::UnicodeVersion version, int from)
QChar *d = s.data();
// ligatureHelper() never changes planes
if (QChar::requiresSurrogates(ligature)) {
- d[starter] = QChar::highSurrogate(ligature);
- d[starter + 1] = QChar::lowSurrogate(ligature);
+ d[starter] = QChar(QChar::highSurrogate(ligature));
+ d[starter + 1] = QChar(QChar::lowSurrogate(ligature));
s.remove(i, 2);
} else {
- d[starter] = ligature;
+ d[starter] = QChar(ligature);
s.remove(i, 1);
}
continue;
@@ -1962,16 +1962,16 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
int p = pos;
// exchange characters
if (!QChar::requiresSurrogates(u2)) {
- uc[p++] = u2;
+ uc[p++] = QChar(u2);
} else {
- uc[p++] = QChar::highSurrogate(u2);
- uc[p++] = QChar::lowSurrogate(u2);
+ uc[p++] = QChar(QChar::highSurrogate(u2));
+ uc[p++] = QChar(QChar::lowSurrogate(u2));
}
if (!QChar::requiresSurrogates(u1)) {
- uc[p++] = u1;
+ uc[p++] = QChar(u1);
} else {
- uc[p++] = QChar::highSurrogate(u1);
- uc[p++] = QChar::lowSurrogate(u1);
+ uc[p++] = QChar(QChar::highSurrogate(u1));
+ uc[p++] = QChar(QChar::lowSurrogate(u1));
}
if (pos > 0)
--pos;
diff --git a/src/corelib/tools/qchar.h b/src/corelib/text/qchar.h
index 73344ecf52..e028a24c24 100644
--- a/src/corelib/tools/qchar.h
+++ b/src/corelib/text/qchar.h
@@ -443,17 +443,17 @@ public:
#endif
inline unsigned char combiningClass() const noexcept { return QChar::combiningClass(ucs); }
- inline QChar mirroredChar() const noexcept { return QChar::mirroredChar(ucs); }
+ inline QChar mirroredChar() const noexcept { return QChar(QChar::mirroredChar(ucs)); }
inline bool hasMirrored() const noexcept { return QChar::hasMirrored(ucs); }
QString decomposition() const;
inline Decomposition decompositionTag() const noexcept { return QChar::decompositionTag(ucs); }
inline int digitValue() const noexcept { return QChar::digitValue(ucs); }
- inline QChar toLower() const noexcept { return QChar::toLower(ucs); }
- inline QChar toUpper() const noexcept { return QChar::toUpper(ucs); }
- inline QChar toTitleCase() const noexcept { return QChar::toTitleCase(ucs); }
- inline QChar toCaseFolded() const noexcept { return QChar::toCaseFolded(ucs); }
+ inline QChar toLower() const noexcept { return QChar(QChar::toLower(ucs)); }
+ inline QChar toUpper() const noexcept { return QChar(QChar::toUpper(ucs)); }
+ inline QChar toTitleCase() const noexcept { return QChar(QChar::toTitleCase(ucs)); }
+ inline QChar toCaseFolded() const noexcept { return QChar(QChar::toCaseFolded(ucs)); }
inline Script script() const noexcept { return QChar::script(ucs); }
diff --git a/src/corelib/tools/qcollator.cpp b/src/corelib/text/qcollator.cpp
index 958216bde8..958216bde8 100644
--- a/src/corelib/tools/qcollator.cpp
+++ b/src/corelib/text/qcollator.cpp
diff --git a/src/corelib/tools/qcollator.h b/src/corelib/text/qcollator.h
index 6bb5038371..6bb5038371 100644
--- a/src/corelib/tools/qcollator.h
+++ b/src/corelib/text/qcollator.h
diff --git a/src/corelib/tools/qcollator_icu.cpp b/src/corelib/text/qcollator_icu.cpp
index 8acda45070..8acda45070 100644
--- a/src/corelib/tools/qcollator_icu.cpp
+++ b/src/corelib/text/qcollator_icu.cpp
diff --git a/src/corelib/tools/qcollator_macx.cpp b/src/corelib/text/qcollator_macx.cpp
index 071d7c048f..071d7c048f 100644
--- a/src/corelib/tools/qcollator_macx.cpp
+++ b/src/corelib/text/qcollator_macx.cpp
diff --git a/src/corelib/tools/qcollator_p.h b/src/corelib/text/qcollator_p.h
index fc2d434a8d..fc2d434a8d 100644
--- a/src/corelib/tools/qcollator_p.h
+++ b/src/corelib/text/qcollator_p.h
diff --git a/src/corelib/tools/qcollator_posix.cpp b/src/corelib/text/qcollator_posix.cpp
index 9cbc539ebe..9cbc539ebe 100644
--- a/src/corelib/tools/qcollator_posix.cpp
+++ b/src/corelib/text/qcollator_posix.cpp
diff --git a/src/corelib/tools/qcollator_win.cpp b/src/corelib/text/qcollator_win.cpp
index 9d81de882f..9d81de882f 100644
--- a/src/corelib/tools/qcollator_win.cpp
+++ b/src/corelib/text/qcollator_win.cpp
diff --git a/src/corelib/tools/qdoublescanprint_p.h b/src/corelib/text/qdoublescanprint_p.h
index 3865c69a99..3865c69a99 100644
--- a/src/corelib/tools/qdoublescanprint_p.h
+++ b/src/corelib/text/qdoublescanprint_p.h
diff --git a/src/corelib/tools/qharfbuzz.cpp b/src/corelib/text/qharfbuzz.cpp
index a3e266ccd2..a3e266ccd2 100644
--- a/src/corelib/tools/qharfbuzz.cpp
+++ b/src/corelib/text/qharfbuzz.cpp
diff --git a/src/corelib/tools/qharfbuzz_p.h b/src/corelib/text/qharfbuzz_p.h
index 2a0307d35f..2a0307d35f 100644
--- a/src/corelib/tools/qharfbuzz_p.h
+++ b/src/corelib/text/qharfbuzz_p.h
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/text/qlocale.cpp
index 939f8eb34d..5685d87c85 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Copyright (C) 2019 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
@@ -304,7 +304,8 @@ QByteArray QLocaleId::name(char separator) const
(script_id != QLocale::AnyScript ? script_code_list + 4 * script_id : nullptr);
const unsigned char *country =
(country_id != QLocale::AnyCountry ? country_code_list + 3 * country_id : nullptr);
- char len = (lang[2] != 0 ? 3 : 2) + (script ? 4+1 : 0) + (country ? (country[2] != 0 ? 3 : 2)+1 : 0);
+ char len = (lang[2] != 0 ? 3 : 2) + (script ? 4 + 1 : 0)
+ + (country ? (country[2] != 0 ? 3 : 2) + 1 : 0);
QByteArray name(len, Qt::Uninitialized);
char *uc = name.data();
*uc++ = lang[0];
@@ -335,7 +336,8 @@ QByteArray QLocalePrivate::bcp47Name(char separator) const
if (m_data->m_language_id == QLocale::C)
return QByteArrayLiteral("en");
- QLocaleId localeId = QLocaleId::fromIds(m_data->m_language_id, m_data->m_script_id, m_data->m_country_id);
+ QLocaleId localeId = QLocaleId::fromIds(m_data->m_language_id, m_data->m_script_id,
+ m_data->m_country_id);
return localeId.withLikelySubtagsRemoved().name(separator);
}
@@ -367,8 +369,10 @@ static const QLocaleData *findLocaleDataById(const QLocaleId &localeId)
} while (data->m_language_id && data->m_language_id == localeId.language_id);
} else {
do {
- if (data->m_script_id == localeId.script_id && data->m_country_id == localeId.country_id)
+ if (data->m_script_id == localeId.script_id
+ && data->m_country_id == localeId.country_id) {
return data;
+ }
++data;
} while (data->m_language_id && data->m_language_id == localeId.language_id);
}
@@ -376,7 +380,8 @@ static const QLocaleData *findLocaleDataById(const QLocaleId &localeId)
return nullptr;
}
-const QLocaleData *QLocaleData::findLocaleData(QLocale::Language language, QLocale::Script script, QLocale::Country country)
+const QLocaleData *QLocaleData::findLocaleData(QLocale::Language language, QLocale::Script script,
+ QLocale::Country country)
{
QLocaleId localeId = QLocaleId::fromIds(language, script, country);
QLocaleId likelyId = localeId.withLikelySubtagsAdded();
@@ -438,7 +443,8 @@ const QLocaleData *QLocaleData::findLocaleData(QLocale::Language language, QLoca
return locale_data + idx;
}
-static bool parse_locale_tag(const QString &input, int &i, QString *result, const QString &separators)
+static bool parse_locale_tag(const QString &input, int &i, QString *result,
+ const QString &separators)
{
*result = QString(8, Qt::Uninitialized); // worst case according to BCP47
QChar *pch = result->data();
@@ -487,7 +493,8 @@ bool qt_splitLocaleName(const QString &name, QString &lang, QString &script, QSt
state = ScriptState;
break;
case ScriptState: {
- QString scripts = QString::fromLatin1((const char *)script_code_list, sizeof(script_code_list) - 1);
+ QString scripts = QString::fromLatin1((const char *)script_code_list,
+ sizeof(script_code_list) - 1);
if (value.length() == 4 && scripts.indexOf(value) % 4 == 0) {
// script name is always 4 characters
script = value;
@@ -560,8 +567,8 @@ QString qt_readEscapedFormatString(QStringView format, int *idx)
while (i < format.size()) {
if (format.at(i).unicode() == '\'') {
- if (i + 1 < format.size() && format.at(i + 1).unicode() == '\'') {
- // "''" inside of a quoted string
+ if (format.mid(i + 1).startsWith(QLatin1Char('\''))) {
+ // "''" inside a quoted string
result.append(QLatin1Char('\''));
i += 2;
} else {
@@ -610,7 +617,8 @@ static QLocale::NumberOptions default_number_options = QLocale::DefaultNumberOpt
static const QLocaleData *const c_data = locale_data;
static QLocalePrivate *c_private()
{
- static QLocalePrivate c_locale = { c_data, Q_BASIC_ATOMIC_INITIALIZER(1), QLocale::OmitGroupSeparator };
+ static QLocalePrivate c_locale =
+ { c_data, Q_BASIC_ATOMIC_INITIALIZER(1), QLocale::OmitGroupSeparator };
return &c_locale;
}
@@ -833,9 +841,11 @@ QLocale::QLocale(QLocalePrivate &dd)
"language[_script][_country][.codeset][@modifier]" or "C", where:
\list
- \li language is a lowercase, two-letter, ISO 639 language code (also some three-letter codes),
+ \li language is a lowercase, two-letter, ISO 639 language code (also some
+ three-letter codes),
\li script is a titlecase, four-letter, ISO 15924 script code,
- \li country is an uppercase, two-letter, ISO 3166 country code (also "419" as defined by United Nations),
+ \li country is an uppercase, two-letter, ISO 3166 country code
+ (also "419" as defined by United Nations),
\li and codeset and modifier are ignored.
\endlist
@@ -1036,9 +1046,11 @@ QString QLocale::quoteString(const QStringRef &str, QuotationStyle style) const
if (d->m_data == systemData()) {
QVariant res;
if (style == QLocale::AlternateQuotation)
- res = systemLocale()->query(QSystemLocale::StringToAlternateQuotation, QVariant::fromValue(str));
+ res = systemLocale()->query(QSystemLocale::StringToAlternateQuotation,
+ QVariant::fromValue(str));
if (res.isNull() || style == QLocale::StandardQuotation)
- res = systemLocale()->query(QSystemLocale::StringToStandardQuotation, QVariant::fromValue(str));
+ res = systemLocale()->query(QSystemLocale::StringToStandardQuotation,
+ QVariant::fromValue(str));
if (!res.isNull())
return res.toString();
}
@@ -1046,8 +1058,9 @@ QString QLocale::quoteString(const QStringRef &str, QuotationStyle style) const
if (style == QLocale::StandardQuotation)
return QChar(d->m_data->m_quotation_start) % str % QChar(d->m_data->m_quotation_end);
- else
- return QChar(d->m_data->m_alternate_quotation_start) % str % QChar(d->m_data->m_alternate_quotation_end);
+
+ return QChar(d->m_data->m_alternate_quotation_start)
+ % str % QChar(d->m_data->m_alternate_quotation_end);
}
/*!
@@ -1060,8 +1073,8 @@ QString QLocale::createSeparatedList(const QStringList &list) const
{
#ifndef QT_NO_SYSTEMLOCALE
if (d->m_data == systemData()) {
- QVariant res;
- res = systemLocale()->query(QSystemLocale::ListToSeparatedString, QVariant::fromValue(list));
+ QVariant res =
+ systemLocale()->query(QSystemLocale::ListToSeparatedString, QVariant::fromValue(list));
if (!res.isNull())
return res.toString();
@@ -1072,12 +1085,20 @@ QString QLocale::createSeparatedList(const QStringList &list) const
if (size == 1) {
return list.at(0);
} else if (size == 2) {
- QString format = getLocaleData(list_pattern_part_data + d->m_data->m_list_pattern_part_two_idx, d->m_data->m_list_pattern_part_two_size);
+ QString format = getLocaleData(
+ list_pattern_part_data + d->m_data->m_list_pattern_part_two_idx,
+ d->m_data->m_list_pattern_part_two_size);
return format.arg(list.at(0), list.at(1));
} else if (size > 2) {
- QString formatStart = getLocaleData(list_pattern_part_data + d->m_data->m_list_pattern_part_start_idx, d->m_data->m_list_pattern_part_start_size);
- QString formatMid = getLocaleData(list_pattern_part_data + d->m_data->m_list_pattern_part_mid_idx, d->m_data->m_list_pattern_part_mid_size);
- QString formatEnd = getLocaleData(list_pattern_part_data + d->m_data->m_list_pattern_part_end_idx, d->m_data->m_list_pattern_part_end_size);
+ QString formatStart = getLocaleData(
+ list_pattern_part_data + d->m_data->m_list_pattern_part_start_idx,
+ d->m_data->m_list_pattern_part_start_size);
+ QString formatMid = getLocaleData(
+ list_pattern_part_data + d->m_data->m_list_pattern_part_mid_idx,
+ d->m_data->m_list_pattern_part_mid_size);
+ QString formatEnd = getLocaleData(
+ list_pattern_part_data + d->m_data->m_list_pattern_part_end_idx,
+ d->m_data->m_list_pattern_part_end_size);
QString result = formatStart.arg(list.at(0), list.at(1));
for (int i = 2; i < size - 1; ++i)
result = formatMid.arg(result, list.at(i));
@@ -1187,7 +1208,8 @@ static qulonglong toIntegral_helper(const QLocaleData *d, QStringView str, bool
template <typename T> static inline
T toIntegral_helper(const QLocalePrivate *d, QStringView str, bool *ok)
{
- using Int64 = typename std::conditional<std::is_unsigned<T>::value, qulonglong, qlonglong>::type;
+ using Int64 =
+ typename std::conditional<std::is_unsigned<T>::value, qulonglong, qlonglong>::type;
// we select the right overload by the last, unused parameter
Int64 val = toIntegral_helper(d->m_data, str, ok, d->m_numberOptions, Int64());
@@ -1203,8 +1225,8 @@ T toIntegral_helper(const QLocalePrivate *d, QStringView str, bool *ok)
/*!
\since 4.8
- Returns the dash-separated language, script and country (and possibly other BCP47 fields)
- of this locale as a string.
+ Returns the dash-separated language, script and country (and possibly other
+ BCP47 fields) of this locale as a string.
Unlike the uiLanguages() the returned value of the bcp47Name() represents
the locale name of the QLocale data but not the language the user-interface
@@ -1966,7 +1988,8 @@ QString QLocale::toString(const QDate &date, FormatType format) const
#ifndef QT_NO_SYSTEMLOCALE
if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(format == LongFormat
- ? QSystemLocale::DateToStringLong : QSystemLocale::DateToStringShort,
+ ? QSystemLocale::DateToStringLong
+ : QSystemLocale::DateToStringShort,
date);
if (!res.isNull())
return res.toString();
@@ -2094,7 +2117,8 @@ QString QLocale::toString(const QTime &time, FormatType format) const
#ifndef QT_NO_SYSTEMLOCALE
if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(format == LongFormat
- ? QSystemLocale::TimeToStringLong : QSystemLocale::TimeToStringShort,
+ ? QSystemLocale::TimeToStringLong
+ : QSystemLocale::TimeToStringShort,
time);
if (!res.isNull())
return res.toString();
@@ -2121,7 +2145,8 @@ QString QLocale::dateFormat(FormatType format) const
#ifndef QT_NO_SYSTEMLOCALE
if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(format == LongFormat
- ? QSystemLocale::DateFormatLong : QSystemLocale::DateFormatShort,
+ ? QSystemLocale::DateFormatLong
+ : QSystemLocale::DateFormatShort,
QVariant());
if (!res.isNull())
return res.toString();
@@ -2158,7 +2183,8 @@ QString QLocale::timeFormat(FormatType format) const
#ifndef QT_NO_SYSTEMLOCALE
if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(format == LongFormat
- ? QSystemLocale::TimeFormatLong : QSystemLocale::TimeFormatShort,
+ ? QSystemLocale::TimeFormatLong
+ : QSystemLocale::TimeFormatShort,
QVariant());
if (!res.isNull())
return res.toString();
@@ -2499,8 +2525,8 @@ QString QLocale::toString(double i, char f, int prec) const
/*!
Returns a QLocale object initialized to the system locale.
- On Windows and Mac, this locale will use the decimal/grouping characters and date/time
- formats specified in the system configuration panel.
+ On Windows and Mac, this locale will use the decimal/grouping characters and
+ date/time formats specified in the system configuration panel.
\sa c()
*/
@@ -2521,10 +2547,12 @@ QLocale QLocale::system()
script and \a country.
Getting a list of all locales:
- QList<QLocale> allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry);
+ QList<QLocale> allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript,
+ QLocale::AnyCountry);
Getting a list of locales suitable for Russia:
- QList<QLocale> locales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::Russia);
+ QList<QLocale> locales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript,
+ QLocale::Russia);
*/
QList<QLocale> QLocale::matchingLocales(QLocale::Language language,
QLocale::Script script,
@@ -2538,8 +2566,10 @@ QList<QLocale> QLocale::matchingLocales(QLocale::Language language,
return QList<QLocale>() << QLocale(QLocale::C);
QList<QLocale> result;
- if (language == QLocale::AnyLanguage && script == QLocale::AnyScript && country == QLocale::AnyCountry)
+ if (language == QLocale::AnyLanguage && script == QLocale::AnyScript
+ && country == QLocale::AnyCountry) {
result.reserve(locale_data_size);
+ }
const QLocaleData *data = locale_data + locale_index[language];
while ( (data != locale_data + locale_data_size)
&& (language == QLocale::AnyLanguage || data->m_language_id == uint(language))) {
@@ -2599,7 +2629,8 @@ QString QLocale::monthName(int month, FormatType type) const
#ifndef QT_NO_SYSTEMLOCALE
if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(type == LongFormat
- ? QSystemLocale::MonthNameLong : QSystemLocale::MonthNameShort,
+ ? QSystemLocale::MonthNameLong
+ : QSystemLocale::MonthNameShort,
month);
if (!res.isNull())
return res.toString();
@@ -2645,7 +2676,8 @@ QString QLocale::standaloneMonthName(int month, FormatType type) const
#ifndef QT_NO_SYSTEMLOCALE
if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(type == LongFormat
- ? QSystemLocale::StandaloneMonthNameLong : QSystemLocale::StandaloneMonthNameShort,
+ ? QSystemLocale::StandaloneMonthNameLong
+ : QSystemLocale::StandaloneMonthNameShort,
month);
if (!res.isNull())
return res.toString();
@@ -2692,7 +2724,8 @@ QString QLocale::dayName(int day, FormatType type) const
#ifndef QT_NO_SYSTEMLOCALE
if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(type == LongFormat
- ? QSystemLocale::DayNameLong : QSystemLocale::DayNameShort,
+ ? QSystemLocale::DayNameLong
+ : QSystemLocale::DayNameShort,
day);
if (!res.isNull())
return res.toString();
@@ -2741,7 +2774,8 @@ QString QLocale::standaloneDayName(int day, FormatType type) const
#ifndef QT_NO_SYSTEMLOCALE
if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(type == LongFormat
- ? QSystemLocale::DayNameLong : QSystemLocale::DayNameShort,
+ ? QSystemLocale::DayNameLong
+ : QSystemLocale::DayNameShort,
day);
if (!res.isNull())
return res.toString();
@@ -3025,7 +3059,8 @@ QString QLocalePrivate::dateTimeToString(QStringView format, const QDateTime &da
case 4: {
const int yr = date.year();
const int len = (yr < 0) ? 5 : 4;
- result.append(m_data->longLongToString(yr, -1, 10, len, QLocaleData::ZeroPadded));
+ result.append(m_data->longLongToString(yr, -1, 10, len,
+ QLocaleData::ZeroPadded));
break;
}
case 2:
@@ -3047,7 +3082,8 @@ QString QLocalePrivate::dateTimeToString(QStringView format, const QDateTime &da
result.append(m_data->longLongToString(date.month()));
break;
case 2:
- result.append(m_data->longLongToString(date.month(), -1, 10, 2, QLocaleData::ZeroPadded));
+ result.append(m_data->longLongToString(date.month(), -1, 10, 2,
+ QLocaleData::ZeroPadded));
break;
case 3:
result.append(q->monthName(date.month(), QLocale::ShortFormat));
@@ -3066,7 +3102,8 @@ QString QLocalePrivate::dateTimeToString(QStringView format, const QDateTime &da
result.append(m_data->longLongToString(date.day()));
break;
case 2:
- result.append(m_data->longLongToString(date.day(), -1, 10, 2, QLocaleData::ZeroPadded));
+ result.append(m_data->longLongToString(date.day(), -1, 10, 2,
+ QLocaleData::ZeroPadded));
break;
case 3:
result.append(q->dayName(date.dayOfWeek(), QLocale::ShortFormat));
@@ -3099,7 +3136,8 @@ QString QLocalePrivate::dateTimeToString(QStringView format, const QDateTime &da
result.append(m_data->longLongToString(hour));
break;
case 2:
- result.append(m_data->longLongToString(hour, -1, 10, 2, QLocaleData::ZeroPadded));
+ result.append(m_data->longLongToString(hour, -1, 10, 2,
+ QLocaleData::ZeroPadded));
break;
}
break;
@@ -3112,7 +3150,8 @@ QString QLocalePrivate::dateTimeToString(QStringView format, const QDateTime &da
result.append(m_data->longLongToString(time.hour()));
break;
case 2:
- result.append(m_data->longLongToString(time.hour(), -1, 10, 2, QLocaleData::ZeroPadded));
+ result.append(m_data->longLongToString(time.hour(), -1, 10, 2,
+ QLocaleData::ZeroPadded));
break;
}
break;
@@ -3125,7 +3164,8 @@ QString QLocalePrivate::dateTimeToString(QStringView format, const QDateTime &da
result.append(m_data->longLongToString(time.minute()));
break;
case 2:
- result.append(m_data->longLongToString(time.minute(), -1, 10, 2, QLocaleData::ZeroPadded));
+ result.append(m_data->longLongToString(time.minute(), -1, 10, 2,
+ QLocaleData::ZeroPadded));
break;
}
break;
@@ -3138,42 +3178,32 @@ QString QLocalePrivate::dateTimeToString(QStringView format, const QDateTime &da
result.append(m_data->longLongToString(time.second()));
break;
case 2:
- result.append(m_data->longLongToString(time.second(), -1, 10, 2, QLocaleData::ZeroPadded));
+ result.append(m_data->longLongToString(time.second(), -1, 10, 2,
+ QLocaleData::ZeroPadded));
break;
}
break;
case 'a':
used = true;
- if (i + 1 < format.size() && format.at(i + 1).unicode() == 'p') {
- repeat = 2;
- } else {
- repeat = 1;
- }
+ repeat = format.mid(i + 1).startsWith(QLatin1Char('p')) ? 2 : 1;
result.append(time.hour() < 12 ? q->amText().toLower() : q->pmText().toLower());
break;
case 'A':
used = true;
- if (i + 1 < format.size() && format.at(i + 1).unicode() == 'P') {
- repeat = 2;
- } else {
- repeat = 1;
- }
+ repeat = format.mid(i + 1).startsWith(QLatin1Char('P')) ? 2 : 1;
result.append(time.hour() < 12 ? q->amText().toUpper() : q->pmText().toUpper());
break;
case 'z':
used = true;
- if (repeat >= 3) {
- repeat = 3;
- } else {
- repeat = 1;
- }
+ repeat = (repeat >= 3) ? 3 : 1;
// note: the millisecond component is treated like the decimal part of the seconds
// so ms == 2 is always printed as "002", but ms == 200 can be either "2" or "200"
- result.append(m_data->longLongToString(time.msec(), -1, 10, 3, QLocaleData::ZeroPadded));
+ result.append(m_data->longLongToString(time.msec(), -1, 10, 3,
+ QLocaleData::ZeroPadded));
if (repeat == 1) {
if (result.endsWith(zero()))
result.chop(1);
@@ -3187,20 +3217,16 @@ QString QLocalePrivate::dateTimeToString(QStringView format, const QDateTime &da
used = true;
repeat = 1;
// If we have a QDateTime use the time spec otherwise use the current system tzname
- if (formatDate) {
- result.append(datetime.timeZoneAbbreviation());
- } else {
- result.append(QDateTime::currentDateTime().timeZoneAbbreviation());
- }
+ result.append(formatDate ? datetime.timeZoneAbbreviation()
+ : QDateTime::currentDateTime().timeZoneAbbreviation());
break;
default:
break;
}
}
- if (!used) {
+ if (!used)
result.append(QString(repeat, c));
- }
i += repeat;
}
@@ -3216,7 +3242,8 @@ QString QLocaleData::doubleToString(double d, int precision, DoubleForm form,
QString QLocaleData::doubleToString(const QChar _zero, const QChar plus, const QChar minus,
const QChar exponential, const QChar group, const QChar decimal,
- double d, int precision, DoubleForm form, int width, unsigned flags)
+ double d, int precision, DoubleForm form, int width,
+ unsigned flags)
{
if (precision != QLocale::FloatingPointShortest && precision < 0)
precision = 6;
@@ -3589,11 +3616,14 @@ bool QLocaleData::numberToCLocale(QStringView s, QLocale::NumberOptions number_o
return false;
// check distance from the last separator or from the beginning of the digits
- // ### FIXME: Some locales allow other groupings! See https://en.wikipedia.org/wiki/Thousands_separator
+ // ### FIXME: Some locales allow other groupings!
+ // See https://en.wikipedia.org/wiki/Thousands_separator
if (last_separator_idx != -1 && idx - last_separator_idx != 4)
return false;
- if (last_separator_idx == -1 && (start_of_digits_idx == -1 || idx - start_of_digits_idx > 3))
+ if (last_separator_idx == -1
+ && (start_of_digits_idx == -1 || idx - start_of_digits_idx > 3)) {
return false;
+ }
last_separator_idx = idx;
++group_cnt;
@@ -3603,7 +3633,8 @@ bool QLocaleData::numberToCLocale(QStringView s, QLocale::NumberOptions number_o
continue;
} else if (out == '.' || out == 'e' || out == 'E') {
// check distance from the last separator
- // ### FIXME: Some locales allow other groupings! See https://en.wikipedia.org/wiki/Thousands_separator
+ // ### FIXME: Some locales allow other groupings!
+ // See https://en.wikipedia.org/wiki/Thousands_separator
if (last_separator_idx != -1 && idx - last_separator_idx != 4)
return false;
@@ -3663,9 +3694,10 @@ bool QLocaleData::validateChars(QStringView str, NumberMode numMode, QByteArray
// The only non-digit character after the 'e' can be '+' or '-'.
// If a zero is directly after that, then the exponent is zero-padded.
- if ((number_options & QLocale::RejectLeadingZeroInExponent) && c == '0' && eCnt > 0 &&
- !lastWasDigit)
+ if ((number_options & QLocale::RejectLeadingZeroInExponent)
+ && c == '0' && eCnt > 0 && !lastWasDigit) {
return false;
+ }
lastWasDigit = true;
} else {
@@ -3917,7 +3949,8 @@ QString QLocale::toCurrencyString(qlonglong value, const QString &symbol) const
#ifndef QT_NO_SYSTEMLOCALE
if (d->m_data == systemData()) {
QSystemLocale::CurrencyToStringArgument arg(value, symbol);
- QVariant res = systemLocale()->query(QSystemLocale::CurrencyToString, QVariant::fromValue(arg));
+ QVariant res =
+ systemLocale()->query(QSystemLocale::CurrencyToString, QVariant::fromValue(arg));
if (!res.isNull())
return res.toString();
}
@@ -3947,7 +3980,8 @@ QString QLocale::toCurrencyString(qulonglong value, const QString &symbol) const
#ifndef QT_NO_SYSTEMLOCALE
if (d->m_data == systemData()) {
QSystemLocale::CurrencyToStringArgument arg(value, symbol);
- QVariant res = systemLocale()->query(QSystemLocale::CurrencyToString, QVariant::fromValue(arg));
+ QVariant res =
+ systemLocale()->query(QSystemLocale::CurrencyToString, QVariant::fromValue(arg));
if (!res.isNull())
return res.toString();
}
@@ -3989,7 +4023,8 @@ QString QLocale::toCurrencyString(double value, const QString &symbol, int preci
#ifndef QT_NO_SYSTEMLOCALE
if (d->m_data == systemData()) {
QSystemLocale::CurrencyToStringArgument arg(value, symbol);
- QVariant res = systemLocale()->query(QSystemLocale::CurrencyToString, QVariant::fromValue(arg));
+ QVariant res =
+ systemLocale()->query(QSystemLocale::CurrencyToString, QVariant::fromValue(arg));
if (!res.isNull())
return res.toString();
}
@@ -4126,7 +4161,8 @@ QStringList QLocale::uiLanguages() const
}
}
#endif
- QLocaleId id = QLocaleId::fromIds(d->m_data->m_language_id, d->m_data->m_script_id, d->m_data->m_country_id);
+ QLocaleId id = QLocaleId::fromIds(d->m_data->m_language_id, d->m_data->m_script_id,
+ d->m_data->m_country_id);
const QLocaleId max = id.withLikelySubtagsAdded();
const QLocaleId min = max.withLikelySubtagsRemoved();
@@ -4182,7 +4218,8 @@ QString QLocale::nativeLanguageName() const
return res.toString();
}
#endif
- return getLocaleData(endonyms_data + d->m_data->m_language_endonym_idx, d->m_data->m_language_endonym_size);
+ return getLocaleData(endonyms_data + d->m_data->m_language_endonym_idx,
+ d->m_data->m_language_endonym_size);
}
/*!
@@ -4202,7 +4239,8 @@ QString QLocale::nativeCountryName() const
return res.toString();
}
#endif
- return getLocaleData(endonyms_data + d->m_data->m_country_endonym_idx, d->m_data->m_country_endonym_size);
+ return getLocaleData(endonyms_data + d->m_data->m_country_endonym_idx,
+ d->m_data->m_country_endonym_size);
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/corelib/tools/qlocale.h b/src/corelib/text/qlocale.h
index 09de830ca3..09de830ca3 100644
--- a/src/corelib/tools/qlocale.h
+++ b/src/corelib/text/qlocale.h
diff --git a/src/corelib/tools/qlocale.qdoc b/src/corelib/text/qlocale.qdoc
index 426cb9dbeb..426cb9dbeb 100644
--- a/src/corelib/tools/qlocale.qdoc
+++ b/src/corelib/text/qlocale.qdoc
diff --git a/src/corelib/tools/qlocale_data_p.h b/src/corelib/text/qlocale_data_p.h
index 2c351a3fb1..2c351a3fb1 100644
--- a/src/corelib/tools/qlocale_data_p.h
+++ b/src/corelib/text/qlocale_data_p.h
diff --git a/src/corelib/tools/qlocale_icu.cpp b/src/corelib/text/qlocale_icu.cpp
index afe0aae583..afe0aae583 100644
--- a/src/corelib/tools/qlocale_icu.cpp
+++ b/src/corelib/text/qlocale_icu.cpp
diff --git a/src/corelib/tools/qlocale_mac.mm b/src/corelib/text/qlocale_mac.mm
index 9719278426..9719278426 100644
--- a/src/corelib/tools/qlocale_mac.mm
+++ b/src/corelib/text/qlocale_mac.mm
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/text/qlocale_p.h
index 1e3da35a02..37afb8542b 100644
--- a/src/corelib/tools/qlocale_p.h
+++ b/src/corelib/text/qlocale_p.h
@@ -285,9 +285,9 @@ public:
quint16 m_language_id, m_script_id, m_country_id;
// FIXME QTBUG-69324: not all unicode code-points map to single-token UTF-16 :-(
- quint16 m_decimal, m_group, m_list, m_percent, m_zero, m_minus, m_plus, m_exponential;
- quint16 m_quotation_start, m_quotation_end;
- quint16 m_alternate_quotation_start, m_alternate_quotation_end;
+ char16_t m_decimal, m_group, m_list, m_percent, m_zero, m_minus, m_plus, m_exponential;
+ char16_t m_quotation_start, m_quotation_end;
+ char16_t m_alternate_quotation_start, m_alternate_quotation_end;
quint16 m_list_pattern_part_start_idx, m_list_pattern_part_start_size;
quint16 m_list_pattern_part_mid_idx, m_list_pattern_part_mid_size;
@@ -417,7 +417,7 @@ inline char QLocaleData::digitToCLocale(QChar in) const
if (in == m_group)
return ',';
- if (in == m_exponential || in == QChar::toUpper(m_exponential))
+ if (in == m_exponential || in == QChar(QChar::toUpper(m_exponential)))
return 'e';
// In several languages group() is a non-breaking space (U+00A0) or its thin
diff --git a/src/corelib/tools/qlocale_tools.cpp b/src/corelib/text/qlocale_tools.cpp
index db8c8cd12f..db8c8cd12f 100644
--- a/src/corelib/tools/qlocale_tools.cpp
+++ b/src/corelib/text/qlocale_tools.cpp
diff --git a/src/corelib/tools/qlocale_tools_p.h b/src/corelib/text/qlocale_tools_p.h
index 594331ae37..594331ae37 100644
--- a/src/corelib/tools/qlocale_tools_p.h
+++ b/src/corelib/text/qlocale_tools_p.h
diff --git a/src/corelib/tools/qlocale_unix.cpp b/src/corelib/text/qlocale_unix.cpp
index ff4274d932..ff4274d932 100644
--- a/src/corelib/tools/qlocale_unix.cpp
+++ b/src/corelib/text/qlocale_unix.cpp
diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp
index dc904ad02d..dc904ad02d 100644
--- a/src/corelib/tools/qlocale_win.cpp
+++ b/src/corelib/text/qlocale_win.cpp
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/text/qregexp.cpp
index dd38ba0360..d81826b47b 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/text/qregexp.cpp
@@ -2035,7 +2035,7 @@ bool QRegExpMatchState::matchHere()
#ifndef QT_NO_REGEXP_CCLASS
const QRegExpCharClass &cc = eng->cl.at(m ^ QRegExpEngine::CharClassBit);
if (eng->cs)
- inside = cc.in(ch);
+ inside = cc.in(QChar(ch));
else if (cc.negative())
inside = cc.in(QChar(ch).toLower()) &&
cc.in(QChar(ch).toUpper());
diff --git a/src/corelib/tools/qregexp.h b/src/corelib/text/qregexp.h
index 8f6de24c74..8f6de24c74 100644
--- a/src/corelib/tools/qregexp.h
+++ b/src/corelib/text/qregexp.h
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/text/qregularexpression.cpp
index 17acd476b2..17acd476b2 100644
--- a/src/corelib/tools/qregularexpression.cpp
+++ b/src/corelib/text/qregularexpression.cpp
diff --git a/src/corelib/tools/qregularexpression.h b/src/corelib/text/qregularexpression.h
index f799a38ae4..f799a38ae4 100644
--- a/src/corelib/tools/qregularexpression.h
+++ b/src/corelib/text/qregularexpression.h
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/text/qstring.cpp
index 47db97cdfc..375843e36e 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -49,8 +49,8 @@
#include <qtextcodec.h>
#endif
#include <private/qutfcodec_p.h>
-#include <private/qlocale_tools_p.h>
-#include "qsimd_p.h"
+#include "qlocale_tools_p.h"
+#include "private/qsimd_p.h"
#include <qnumeric.h>
#include <qdatastream.h>
#include <qlist.h>
@@ -59,7 +59,6 @@
#include "qstringbuilder.h"
#include "qstringmatcher.h"
#include "qvarlengtharray.h"
-#include "qtools_p.h"
#include "qdebug.h"
#include "qendian.h"
#include "qcollator.h"
@@ -2092,7 +2091,7 @@ int QString::toUcs4_helper(const ushort *uc, int length, uint *out)
If \a size is negative, \a unicode is assumed to point to a \\0'-terminated
array and its length is determined dynamically. The terminating
- nul-character is not considered part of the string.
+ null character is not considered part of the string.
QString makes a deep copy of the string data. The unicode data is copied as
is and the Byte Order Mark is preserved if present.
@@ -3208,7 +3207,7 @@ QString& QString::replace(QChar ch, const QString &after, Qt::CaseSensitivity cs
return remove(ch, cs);
if (after.d->size == 1)
- return replace(ch, after.d->data()[0], cs);
+ return replace(ch, after.front(), cs);
if (d->size == 0)
return *this;
@@ -5770,7 +5769,7 @@ QString QString::trimmed_helper(QString &str)
The return value is of type QCharRef, a helper class for QString.
When you get an object of type QCharRef, you can use it as if it
- were a QChar &. If you assign to it, the assignment will apply to
+ were a reference to a QChar. If you assign to it, the assignment will apply to
the character in the QString from which you got the reference.
\note Before Qt 5.14 it was possible to use this operator to access
@@ -6666,7 +6665,7 @@ static QString detachAndConvertCase(T &str, QStringIterator it)
} else if (Q_UNLIKELY(QChar::requiresSurrogates(uc))) {
// so far, case convertion never changes planes (guaranteed by the qunicodetables generator)
pp++;
- *pp++ = QChar::lowSurrogate(uc + caseDiff);
+ *pp++ = QChar(QChar::lowSurrogate(uc + caseDiff));
} else {
*pp++ = QChar(uc + caseDiff);
}
@@ -11439,7 +11438,7 @@ bool QStringRef::isRightToLeft() const
\sa QString::isRightToLeft()
*/
-bool QtPrivate::isRightToLeft(QStringView string)
+bool QtPrivate::isRightToLeft(QStringView string) noexcept
{
const ushort *p = reinterpret_cast<const ushort*>(string.data());
const ushort * const end = p + string.size();
diff --git a/src/corelib/tools/qstring.h b/src/corelib/text/qstring.h
index 6788e53057..88286b902a 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/text/qstring.h
@@ -89,6 +89,10 @@ class QTextCodec;
class QStringRef;
template <typename T> class QVector;
+namespace QtPrivate {
+template <bool...B> class BoolList;
+}
+
class QLatin1String
{
public:
@@ -231,7 +235,7 @@ QT_DEPRECATED_X("Use QLatin1String") typedef QLatin1String QLatin1Literal;
//
// QLatin1String inline implementations
//
-inline bool QtPrivate::isLatin1(QLatin1String) noexcept
+Q_DECL_CONSTEXPR bool QtPrivate::isLatin1(QLatin1String) noexcept
{ return true; }
//
@@ -333,6 +337,7 @@ public:
QChar fillChar = QLatin1Char(' ')) const;
Q_REQUIRED_RESULT QString arg(QLatin1String a, int fieldWidth = 0,
QChar fillChar = QLatin1Char(' ')) const;
+#if QT_STRINGVIEW_LEVEL < 2
Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2) const;
Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3) const;
Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3,
@@ -350,6 +355,33 @@ public:
Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3,
const QString &a4, const QString &a5, const QString &a6,
const QString &a7, const QString &a8, const QString &a9) const;
+#endif
+private:
+ template <typename T>
+ struct is_convertible_to_view_or_qstring_helper
+ : std::integral_constant<bool,
+ std::is_convertible<T, QString>::value ||
+ std::is_convertible<T, QStringView>::value ||
+ std::is_convertible<T, QLatin1String>::value> {};
+ template <typename T>
+ struct is_convertible_to_view_or_qstring
+ : is_convertible_to_view_or_qstring_helper<typename std::decay<T>::type> {};
+public:
+ template <typename...Args>
+ Q_REQUIRED_RESULT
+#ifdef Q_CLANG_QDOC
+ QString
+#else
+ typename std::enable_if<
+ sizeof...(Args) >= 2 && std::is_same<
+ QtPrivate::BoolList<is_convertible_to_view_or_qstring<Args>::value..., true>,
+ QtPrivate::BoolList<true, is_convertible_to_view_or_qstring<Args>::value...>
+ >::value,
+ QString
+ >::type
+#endif
+ arg(Args &&...args) const
+ { return qToStringViewIgnoringNull(*this).arg(std::forward<Args>(args)...); }
#if QT_DEPRECATED_SINCE(5, 14)
QT_DEPRECATED_X("Use vasprintf(), arg() or QTextStream instead")
@@ -1002,11 +1034,11 @@ inline QString::QString(QLatin1String aLatin1) : d(fromLatin1_helper(aLatin1.lat
inline int QString::length() const
{ return d->size; }
inline const QChar QString::at(int i) const
-{ Q_ASSERT(uint(i) < uint(size())); return d->data()[i]; }
+{ Q_ASSERT(uint(i) < uint(size())); return QChar(d->data()[i]); }
inline const QChar QString::operator[](int i) const
-{ Q_ASSERT(uint(i) < uint(size())); return d->data()[i]; }
+{ Q_ASSERT(uint(i) < uint(size())); return QChar(d->data()[i]); }
inline const QChar QString::operator[](uint i) const
-{ Q_ASSERT(i < uint(size())); return d->data()[i]; }
+{ Q_ASSERT(i < uint(size())); return QChar(d->data()[i]); }
inline bool QString::isEmpty() const
{ return d->size == 0; }
inline const QChar *QString::unicode() const
@@ -1053,6 +1085,7 @@ inline QString QString::arg(short a, int fieldWidth, int base, QChar fillChar) c
{ return arg(qlonglong(a), fieldWidth, base, fillChar); }
inline QString QString::arg(ushort a, int fieldWidth, int base, QChar fillChar) const
{ return arg(qulonglong(a), fieldWidth, base, fillChar); }
+#if QT_STRINGVIEW_LEVEL < 2
inline QString QString::arg(const QString &a1, const QString &a2) const
{ return qToStringViewIgnoringNull(*this).arg(a1, a2); }
inline QString QString::arg(const QString &a1, const QString &a2, const QString &a3) const
@@ -1078,6 +1111,7 @@ inline QString QString::arg(const QString &a1, const QString &a2, const QString
const QString &a4, const QString &a5, const QString &a6,
const QString &a7, const QString &a8, const QString &a9) const
{ return qToStringViewIgnoringNull(*this).arg(a1, a2, a3, a4, a5, a6, a7, a8, a9); }
+#endif
inline QString QString::section(QChar asep, int astart, int aend, SectionFlags aflags) const
{ return section(QString(asep), astart, aend, aflags); }
@@ -1088,7 +1122,19 @@ QT_WARNING_DISABLE_INTEL(111) // "statement is unreachable"
inline int QString::toWCharArray(wchar_t *array) const
{
- return QStringView(*this).toWCharArray(array);
+ return qToStringViewIgnoringNull(*this).toWCharArray(array);
+}
+
+int QStringView::toWCharArray(wchar_t *array) const
+{
+ if (sizeof(wchar_t) == sizeof(QChar)) {
+ if (auto src = data())
+ memcpy(array, src, sizeof(QChar) * size());
+ return size();
+ } else {
+ return QString::toUcs4_helper(reinterpret_cast<const ushort *>(data()), int(size()),
+ reinterpret_cast<uint *>(array));
+ }
}
QT_WARNING_POP
@@ -1118,11 +1164,11 @@ public:
{
using namespace QtPrivate::DeprecatedRefClassBehavior;
if (Q_LIKELY(i < s.d->size))
- return s.d->data()[i];
+ return QChar(s.d->data()[i]);
#ifdef QT_DEBUG
warn(WarningType::OutOfRange, EmittingClass::QCharRef);
#endif
- return 0;
+ return QChar();
}
inline QCharRef &operator=(QChar c)
{
@@ -2014,6 +2060,7 @@ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString argToQStringDispatch(StringView patter
return QtPrivate::argToQString(pattern, sizeof...(Args), argBases);
}
+ inline QStringViewArg qStringLikeToArg(const QString &s) noexcept { return QStringViewArg{qToStringViewIgnoringNull(s)}; }
Q_DECL_CONSTEXPR inline QStringViewArg qStringLikeToArg(QStringView s) noexcept { return QStringViewArg{s}; }
inline QStringViewArg qStringLikeToArg(const QChar &c) noexcept { return QStringViewArg{QStringView{&c, 1}}; }
Q_DECL_CONSTEXPR inline QLatin1StringArg qStringLikeToArg(QLatin1String s) noexcept { return QLatin1StringArg{s}; }
diff --git a/src/corelib/tools/qstring_compat.cpp b/src/corelib/text/qstring_compat.cpp
index 45bb816e4b..45bb816e4b 100644
--- a/src/corelib/tools/qstring_compat.cpp
+++ b/src/corelib/text/qstring_compat.cpp
diff --git a/src/corelib/tools/qstring_mips_dsp_asm.S b/src/corelib/text/qstring_mips_dsp_asm.S
index 202f322310..202f322310 100644
--- a/src/corelib/tools/qstring_mips_dsp_asm.S
+++ b/src/corelib/text/qstring_mips_dsp_asm.S
diff --git a/src/corelib/tools/qstringalgorithms.h b/src/corelib/text/qstringalgorithms.h
index 2b480b1e4c..d54e376aa9 100644
--- a/src/corelib/tools/qstringalgorithms.h
+++ b/src/corelib/text/qstringalgorithms.h
@@ -92,12 +92,13 @@ Q_REQUIRED_RESULT Q_CORE_EXPORT QByteArray convertToLatin1(QStringView str);
Q_REQUIRED_RESULT Q_CORE_EXPORT QByteArray convertToUtf8(QStringView str);
Q_REQUIRED_RESULT Q_CORE_EXPORT QByteArray convertToLocal8Bit(QStringView str);
Q_REQUIRED_RESULT Q_CORE_EXPORT QVector<uint> convertToUcs4(QStringView str);
-Q_REQUIRED_RESULT Q_CORE_EXPORT bool isRightToLeft(QStringView string);
-Q_REQUIRED_RESULT Q_CORE_EXPORT bool isAscii(QLatin1String s) noexcept;
-Q_REQUIRED_RESULT Q_CORE_EXPORT bool isAscii(QStringView s) noexcept;
-Q_REQUIRED_RESULT bool isLatin1(QLatin1String s) noexcept; // in qstring.h
-Q_REQUIRED_RESULT Q_CORE_EXPORT bool isLatin1(QStringView s) noexcept;
+Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isRightToLeft(QStringView string) noexcept;
+
+Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QLatin1String s) noexcept;
+Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QStringView s) noexcept;
+Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline bool isLatin1(QLatin1String s) noexcept;
+Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isLatin1(QStringView s) noexcept;
} // namespace QtPRivate
diff --git a/src/corelib/tools/qstringalgorithms_p.h b/src/corelib/text/qstringalgorithms_p.h
index 64d9f2e676..64d9f2e676 100644
--- a/src/corelib/tools/qstringalgorithms_p.h
+++ b/src/corelib/text/qstringalgorithms_p.h
diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/text/qstringbuilder.cpp
index cf443ec369..cf443ec369 100644
--- a/src/corelib/tools/qstringbuilder.cpp
+++ b/src/corelib/text/qstringbuilder.cpp
diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/text/qstringbuilder.h
index b3cf2f695e..b3cf2f695e 100644
--- a/src/corelib/tools/qstringbuilder.h
+++ b/src/corelib/text/qstringbuilder.h
diff --git a/src/corelib/tools/qstringiterator.qdoc b/src/corelib/text/qstringiterator.qdoc
index 9d7c54ce9f..9d7c54ce9f 100644
--- a/src/corelib/tools/qstringiterator.qdoc
+++ b/src/corelib/text/qstringiterator.qdoc
diff --git a/src/corelib/tools/qstringiterator_p.h b/src/corelib/text/qstringiterator_p.h
index 219589b6e4..219589b6e4 100644
--- a/src/corelib/tools/qstringiterator_p.h
+++ b/src/corelib/text/qstringiterator_p.h
diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/text/qstringlist.cpp
index 4bbe424ed2..4bbe424ed2 100644
--- a/src/corelib/tools/qstringlist.cpp
+++ b/src/corelib/text/qstringlist.cpp
diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/text/qstringlist.h
index a464d443dc..a464d443dc 100644
--- a/src/corelib/tools/qstringlist.h
+++ b/src/corelib/text/qstringlist.h
diff --git a/src/corelib/tools/qstringliteral.h b/src/corelib/text/qstringliteral.h
index 603f19c0b4..603f19c0b4 100644
--- a/src/corelib/tools/qstringliteral.h
+++ b/src/corelib/text/qstringliteral.h
diff --git a/src/corelib/tools/qstringmatcher.cpp b/src/corelib/text/qstringmatcher.cpp
index 167a467480..167a467480 100644
--- a/src/corelib/tools/qstringmatcher.cpp
+++ b/src/corelib/text/qstringmatcher.cpp
diff --git a/src/corelib/tools/qstringmatcher.h b/src/corelib/text/qstringmatcher.h
index 6de4353930..6de4353930 100644
--- a/src/corelib/tools/qstringmatcher.h
+++ b/src/corelib/text/qstringmatcher.h
diff --git a/src/corelib/tools/qstringview.cpp b/src/corelib/text/qstringview.cpp
index cc852dd042..75de827583 100644
--- a/src/corelib/tools/qstringview.cpp
+++ b/src/corelib/text/qstringview.cpp
@@ -57,9 +57,8 @@ QT_BEGIN_NAMESPACE
The UTF-16 string may be represented as an array (or an array-compatible
data-structure such as QString,
- std::basic_string, etc.) of QChar, \c ushort, \c char16_t (on compilers that
- support C++11 Unicode strings) or (on platforms, such as Windows,
- where it is a 16-bit type) \c wchar_t.
+ std::basic_string, etc.) of QChar, \c ushort, \c char16_t or
+ (on platforms, such as Windows, where it is a 16-bit type) \c wchar_t.
QStringView is designed as an interface type; its main use-case is
as a function parameter type. When QStringViews are used as automatic
@@ -115,8 +114,7 @@ QT_BEGIN_NAMESPACE
/*!
\typedef QStringView::storage_type
- Alias for \c{char16_t} for non-Windows or if Q_COMPILER_UNICODE_STRINGS
- is defined. Otherwise, alias for \c{wchar_t}.
+ Alias for \c{char16_t}.
*/
/*!
@@ -532,6 +530,7 @@ QT_BEGIN_NAMESPACE
/*!
\fn QString QStringView::arg(Args &&...args) const
\fn QString QLatin1String::arg(Args &&...args) const
+ \fn QString QString::arg(Args &&...args) const
\since 5.14
Replaces occurrences of \c{%N} in this string with the corresponding
@@ -539,8 +538,8 @@ QT_BEGIN_NAMESPACE
the \a args replaces the \c{%N} with the lowest \c{N} (all of them), the
second of the \a args the \c{%N} with the next-lowest \c{N} etc.
- \c Args can consist of anything that implicitly converts to QStringView
- or QLatin1String.
+ \c Args can consist of anything that implicitly converts to QString,
+ QStringView or QLatin1String.
In addition, the following types are also supported: QChar, QLatin1Char.
@@ -866,11 +865,12 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \fn QStringView::toWCharArray(wchar_t *array) const
\since 5.14
Transcribes this string into the given \a array.
- Caller is responsible for ensuring \a array is large enough to hold the
+ The caller is responsible for ensuring \a array is large enough to hold the
\c wchar_t encoding of this string (allocating the array with the same length
as the string is always sufficient). The array is encoded in UTF-16 on
platforms where \c wchar_t is 2 bytes wide (e.g. Windows); otherwise (Unix
@@ -884,15 +884,4 @@ QT_BEGIN_NAMESPACE
\sa QString::toWCharArray()
*/
-int QStringView::toWCharArray(wchar_t *array) const
-{
- if (sizeof(wchar_t) == sizeof(QChar)) {
- memcpy(array, data(), sizeof(QChar) * size());
- return size();
- } else {
- return QString::toUcs4_helper(reinterpret_cast<const ushort *>(data()), int(size()),
- reinterpret_cast<uint *>(array));
- }
-}
-
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qstringview.h b/src/corelib/text/qstringview.h
index b84b2995b9..0a82ac4201 100644
--- a/src/corelib/tools/qstringview.h
+++ b/src/corelib/text/qstringview.h
@@ -62,9 +62,7 @@ struct IsCompatibleCharTypeHelper
: std::integral_constant<bool,
std::is_same<Char, QChar>::value ||
std::is_same<Char, ushort>::value ||
-#if defined(Q_COMPILER_UNICODE_STRINGS)
std::is_same<Char, char16_t>::value ||
-#endif
(std::is_same<Char, wchar_t>::value && sizeof(wchar_t) == sizeof(QChar))> {};
template <typename Char>
struct IsCompatibleCharType
@@ -105,11 +103,7 @@ struct IsCompatibleStdBasicString
class QStringView
{
public:
-#if defined(Q_OS_WIN) && !defined(Q_COMPILER_UNICODE_STRINGS)
- typedef wchar_t storage_type;
-#else
typedef char16_t storage_type;
-#endif
typedef const QChar value_type;
typedef std::ptrdiff_t difference_type;
typedef qsizetype size_type;
@@ -294,7 +288,7 @@ public:
Q_REQUIRED_RESULT bool isRightToLeft() const noexcept
{ return QtPrivate::isRightToLeft(*this); }
- Q_REQUIRED_RESULT Q_CORE_EXPORT int toWCharArray(wchar_t *array) const;
+ Q_REQUIRED_RESULT inline int toWCharArray(wchar_t *array) const; // defined in qstring.h
//
// STL compatibility API:
diff --git a/src/corelib/tools/qt_attribution.json b/src/corelib/text/qt_attribution.json
index f91742d421..f91742d421 100644
--- a/src/corelib/tools/qt_attribution.json
+++ b/src/corelib/text/qt_attribution.json
diff --git a/src/corelib/tools/qtextboundaryfinder.cpp b/src/corelib/text/qtextboundaryfinder.cpp
index 67dd15377b..67dd15377b 100644
--- a/src/corelib/tools/qtextboundaryfinder.cpp
+++ b/src/corelib/text/qtextboundaryfinder.cpp
diff --git a/src/corelib/tools/qtextboundaryfinder.h b/src/corelib/text/qtextboundaryfinder.h
index b1e5008f54..b1e5008f54 100644
--- a/src/corelib/tools/qtextboundaryfinder.h
+++ b/src/corelib/text/qtextboundaryfinder.h
diff --git a/src/corelib/tools/qunicodetables.cpp b/src/corelib/text/qunicodetables.cpp
index d57b39ff1f..d57b39ff1f 100644
--- a/src/corelib/tools/qunicodetables.cpp
+++ b/src/corelib/text/qunicodetables.cpp
diff --git a/src/corelib/tools/qunicodetables_p.h b/src/corelib/text/qunicodetables_p.h
index cb7a211cb6..cb7a211cb6 100644
--- a/src/corelib/tools/qunicodetables_p.h
+++ b/src/corelib/text/qunicodetables_p.h
diff --git a/src/corelib/tools/qunicodetools.cpp b/src/corelib/text/qunicodetools.cpp
index 08e1146c59..08e1146c59 100644
--- a/src/corelib/tools/qunicodetools.cpp
+++ b/src/corelib/text/qunicodetools.cpp
diff --git a/src/corelib/tools/qunicodetools_p.h b/src/corelib/text/qunicodetools_p.h
index ed6fcb5d65..ed6fcb5d65 100644
--- a/src/corelib/tools/qunicodetools_p.h
+++ b/src/corelib/text/qunicodetools_p.h
diff --git a/src/corelib/tools/qvsnprintf.cpp b/src/corelib/text/qvsnprintf.cpp
index 43a21771a1..43a21771a1 100644
--- a/src/corelib/tools/qvsnprintf.cpp
+++ b/src/corelib/text/qvsnprintf.cpp
diff --git a/src/corelib/text/text.pri b/src/corelib/text/text.pri
new file mode 100644
index 0000000000..25e281f37a
--- /dev/null
+++ b/src/corelib/text/text.pri
@@ -0,0 +1,100 @@
+# Qt text / string / character / unicode / byte array module
+
+HEADERS += \
+ text/qbytearray.h \
+ text/qbytearray_p.h \
+ text/qbytearraylist.h \
+ text/qbytearraymatcher.h \
+ text/qbytedata_p.h \
+ text/qchar.h \
+ text/qcollator.h \
+ text/qcollator_p.h \
+ text/qdoublescanprint_p.h \
+ text/qlocale.h \
+ text/qlocale_p.h \
+ text/qlocale_tools_p.h \
+ text/qlocale_data_p.h \
+ text/qregexp.h \
+ text/qstring.h \
+ text/qstringalgorithms.h \
+ text/qstringalgorithms_p.h \
+ text/qstringbuilder.h \
+ text/qstringiterator_p.h \
+ text/qstringlist.h \
+ text/qstringliteral.h \
+ text/qstringmatcher.h \
+ text/qstringview.h \
+ text/qtextboundaryfinder.h \
+ text/qunicodetables_p.h \
+ text/qunicodetools_p.h
+
+
+SOURCES += \
+ text/qbytearray.cpp \
+ text/qbytearraylist.cpp \
+ text/qbytearraymatcher.cpp \
+ text/qcollator.cpp \
+ text/qlocale.cpp \
+ text/qlocale_tools.cpp \
+ text/qregexp.cpp \
+ text/qstring.cpp \
+ text/qstringbuilder.cpp \
+ text/qstringlist.cpp \
+ text/qstringview.cpp \
+ text/qtextboundaryfinder.cpp \
+ text/qunicodetools.cpp \
+ text/qvsnprintf.cpp
+
+NO_PCH_SOURCES += text/qstring_compat.cpp
+false: SOURCES += $$NO_PCH_SOURCES # Hack for QtCreator
+
+!nacl:macos: {
+ SOURCES += text/qlocale_mac.mm
+}
+else:unix {
+ SOURCES += text/qlocale_unix.cpp
+}
+else:win32 {
+ SOURCES += text/qlocale_win.cpp
+} else:integrity {
+ SOURCES += text/qlocale_unix.cpp
+}
+
+qtConfig(icu) {
+ QMAKE_USE_PRIVATE += icu
+
+ SOURCES += text/qlocale_icu.cpp \
+ text/qcollator_icu.cpp
+} else: win32 {
+ SOURCES += text/qcollator_win.cpp
+} else: macos {
+ SOURCES += text/qcollator_macx.cpp
+} else {
+ SOURCES += text/qcollator_posix.cpp
+}
+
+qtConfig(regularexpression) {
+ QMAKE_USE_PRIVATE += pcre2
+
+ HEADERS += \
+ text/qregularexpression.h
+ SOURCES += text/qregularexpression.cpp
+}
+
+INCLUDEPATH += ../3rdparty/harfbuzz/src
+HEADERS += ../3rdparty/harfbuzz/src/harfbuzz.h
+SOURCES += ../3rdparty/harfbuzz/src/harfbuzz-buffer.c \
+ ../3rdparty/harfbuzz/src/harfbuzz-gdef.c \
+ ../3rdparty/harfbuzz/src/harfbuzz-gsub.c \
+ ../3rdparty/harfbuzz/src/harfbuzz-gpos.c \
+ ../3rdparty/harfbuzz/src/harfbuzz-impl.c \
+ ../3rdparty/harfbuzz/src/harfbuzz-open.c \
+ ../3rdparty/harfbuzz/src/harfbuzz-stream.c \
+ ../3rdparty/harfbuzz/src/harfbuzz-shaper-all.cpp \
+ text/qharfbuzz.cpp
+HEADERS += text/qharfbuzz_p.h
+
+TR_EXCLUDE += ../3rdparty/*
+
+# MIPS DSP
+MIPS_DSP_ASM += text/qstring_mips_dsp_asm.S
diff --git a/src/corelib/thread/qmutexpool.cpp b/src/corelib/thread/qmutexpool.cpp
deleted file mode 100644
index 3ece30c01c..0000000000
--- a/src/corelib/thread/qmutexpool.cpp
+++ /dev/null
@@ -1,151 +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 "qatomic.h"
-#include "qmutexpool_p.h"
-
-QT_BEGIN_NAMESPACE
-
-Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (QMutex::Recursive))
-
-/*!
- \class QMutexPool
- \inmodule QtCore
- \brief The QMutexPool class provides a pool of QMutex objects.
-
- \internal
-
- \ingroup thread
-
- QMutexPool is a convenience class that provides access to a fixed
- number of QMutex objects.
-
- Typical use of a QMutexPool is in situations where it is not
- possible or feasible to use one QMutex for every protected object.
- The mutex pool will return a mutex based on the address of the
- object that needs protection.
-
- For example, consider this simple class:
-
- \snippet code/src_corelib_thread_qmutexpool.cpp 0
-
- Adding a QMutex member to the Number class does not make sense,
- because it is so small. However, in order to ensure that access to
- each Number is protected, you need to use a mutex. In this case, a
- QMutexPool would be ideal.
-
- Code to calculate the square of a number would then look something
- like this:
-
- \snippet code/src_corelib_thread_qmutexpool.cpp 1
-
- This function will safely calculate the square of a number, since
- it uses a mutex from a QMutexPool. The mutex is locked and
- unlocked automatically by the QMutexLocker class. See the
- QMutexLocker documentation for more details.
-*/
-
-/*!
- Constructs a QMutexPool, reserving space for \a size QMutexes. All
- mutexes in the pool are created with \a recursionMode. By default,
- all mutexes are non-recursive.
-
- The QMutexes are created when needed, and deleted when the
- QMutexPool is destructed.
-*/
-QMutexPool::QMutexPool(QMutex::RecursionMode recursionMode, int size)
- : mutexes(size), recursionMode(recursionMode)
-{
- for (int index = 0; index < mutexes.count(); ++index) {
- mutexes[index].storeRelaxed(0);
- }
-}
-
-/*!
- Destructs a QMutexPool. All QMutexes that were created by the pool
- are deleted.
-*/
-QMutexPool::~QMutexPool()
-{
- for (int index = 0; index < mutexes.count(); ++index)
- delete mutexes[index].loadAcquire();
-}
-
-/*!
- Returns the global QMutexPool instance.
-*/
-QMutexPool *QMutexPool::instance()
-{
- return globalMutexPool();
-}
-
-/*!
- \fn QMutexPool::get(const void *address)
- Returns a QMutex from the pool. QMutexPool uses the value \a address
- to determine which mutex is returned from the pool.
-*/
-
-/*!
- \internal
- create the mutex for the given index
- */
-QMutex *QMutexPool::createMutex(int index)
-{
- // mutex not created, create one
- QMutex *newMutex = new QMutex(recursionMode);
- if (!mutexes[index].testAndSetRelease(nullptr, newMutex)) {
- delete newMutex;
- return mutexes[index].loadAcquire();
- } else {
- return newMutex;
- }
-}
-
-/*!
- Returns a QMutex from the global mutex pool.
-*/
-QMutex *QMutexPool::globalInstanceGet(const void *address)
-{
- QMutexPool * const globalInstance = globalMutexPool();
- if (globalInstance == 0)
- return 0;
- return globalInstance->get(address);
-}
-
-QT_END_NAMESPACE
diff --git a/src/corelib/thread/qmutexpool_p.h b/src/corelib/thread/qmutexpool_p.h
deleted file mode 100644
index 00710199b8..0000000000
--- a/src/corelib/thread/qmutexpool_p.h
+++ /dev/null
@@ -1,88 +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 QMUTEXPOOL_P_H
-#define QMUTEXPOOL_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/private/qglobal_p.h>
-#include "QtCore/qatomic.h"
-#include "QtCore/qmutex.h"
-#include "QtCore/qvarlengtharray.h"
-
-QT_REQUIRE_CONFIG(thread);
-
-QT_BEGIN_NAMESPACE
-
-class Q_CORE_EXPORT QMutexPool
-{
-public:
- explicit QMutexPool(QMutex::RecursionMode recursionMode = QMutex::NonRecursive, int size = 131);
- ~QMutexPool();
-
- inline QMutex *get(const void *address) {
- int index = uint(quintptr(address)) % mutexes.count();
- QMutex *m = mutexes[index].loadAcquire();
- if (m)
- return m;
- else
- return createMutex(index);
- }
- static QMutexPool *instance();
- static QMutex *globalInstanceGet(const void *address);
-
-private:
- QMutex *createMutex(int index);
- QVarLengthArray<QAtomicPointer<QMutex>, 131> mutexes;
- QMutex::RecursionMode recursionMode;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMUTEXPOOL_P_H
diff --git a/src/corelib/thread/qorderedmutexlocker_p.h b/src/corelib/thread/qorderedmutexlocker_p.h
index e0a67388d4..570c526225 100644
--- a/src/corelib/thread/qorderedmutexlocker_p.h
+++ b/src/corelib/thread/qorderedmutexlocker_p.h
@@ -159,7 +159,7 @@ public:
void relock() {}
void unlock() {}
- static bool relock(QBasicMutex *, QBasicMutex *) {}
+ static bool relock(QBasicMutex *, QBasicMutex *) { return false; }
};
using QBasicMutexLocker = QMutexLocker;
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index 280c785049..9fd1dd059d 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -851,7 +851,7 @@ Qt::HANDLE QThread::currentThreadId() noexcept
QThread *QThread::currentThread()
{
- return QThreadData::current()->thread;
+ return QThreadData::current()->thread.loadAcquire();
}
int QThread::idealThreadCount() noexcept
@@ -883,11 +883,11 @@ QThreadData *QThreadData::current(bool createIfNecessary)
if (!data && createIfNecessary) {
data = new QThreadData;
data->thread = new QAdoptedThread(data);
- data->threadId.storeRelaxed(Qt::HANDLE(data->thread));
+ data->threadId.storeRelaxed(Qt::HANDLE(data->thread.loadAcquire()));
data->deref();
data->isAdopted = true;
- if (!QCoreApplicationPrivate::theMainThread)
- QCoreApplicationPrivate::theMainThread = data->thread.loadRelaxed();
+ if (!QCoreApplicationPrivate::theMainThread.loadAcquire())
+ QCoreApplicationPrivate::theMainThread.storeRelease(data->thread.loadRelaxed());
}
return data;
}
diff --git a/src/corelib/thread/thread.pri b/src/corelib/thread/thread.pri
index 22f0de0523..d11e6500ff 100644
--- a/src/corelib/thread/thread.pri
+++ b/src/corelib/thread/thread.pri
@@ -28,7 +28,6 @@ qtConfig(thread) {
thread/qbasicatomic.h \
thread/qfutex_p.h \
thread/qgenericatomic.h \
- thread/qmutexpool_p.h \
thread/qmutex_p.h \
thread/qorderedmutexlocker_p.h \
thread/qreadwritelock_p.h \
@@ -40,7 +39,6 @@ qtConfig(thread) {
SOURCES += \
thread/qatomic.cpp \
thread/qmutex.cpp \
- thread/qmutexpool.cpp \
thread/qreadwritelock.cpp \
thread/qsemaphore.cpp \
thread/qthreadpool.cpp \
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp
index 31206f779d..64943bdaaf 100644
--- a/src/corelib/time/qdatetime.cpp
+++ b/src/corelib/time/qdatetime.cpp
@@ -346,11 +346,10 @@ static constexpr int daysInUsualMonth(int month) // (February isn't usual.)
setDate(). The fromString() function returns a QDate given a string and a
date format which is used to interpret the date within the string.
- The year(), month(), and day() functions provide access to the
- year, month, and day numbers. Also, dayOfWeek() and dayOfYear()
- functions are provided. The same information is provided in
- textual format by the toString(), shortDayName(), longDayName(),
- shortMonthName(), and longMonthName() functions.
+ The year(), month(), and day() functions provide access to the year, month,
+ and day numbers. Also, dayOfWeek() and dayOfYear() functions are
+ provided. The same information is provided in textual format by
+ toString(). The day and month numbers can be mapped to names using QLocale.
QDate provides a full set of operators to compare two QDate
objects where smaller means earlier, and larger means later.
@@ -1076,11 +1075,10 @@ static QString toStringIsoDate(qint64 jd)
Returns the date as a string. The \a format parameter determines
the format of the string.
- If the \a format is Qt::TextDate, the string is formatted in
- the default way. QDate::shortDayName() and QDate::shortMonthName()
- are used to generate the string, so the day and month names will
- be localized names using the system locale, i.e. QLocale::system(). An
- example of this formatting is "Sat May 20 1995".
+ If the \a format is Qt::TextDate, the string is formatted in the default
+ way. The day and month names will be localized names using the system
+ locale, i.e. QLocale::system(). An example of this formatting
+ is "Sat May 20 1995".
If the \a format is Qt::ISODate, the string format corresponds
to the ISO 8601 extended specification for representations of
@@ -1112,7 +1110,7 @@ static QString toStringIsoDate(qint64 jd)
range 0 to 9999. This restriction may apply to locale-aware
formats as well, depending on the locale settings.
- \sa fromString(), shortDayName(), shortMonthName(), QLocale::toString()
+ \sa fromString(), QLocale::toString()
*/
QString QDate::toString(Qt::DateFormat format) const
{
@@ -1131,7 +1129,7 @@ QString QDate::toString(Qt::DateFormat format) const
case Qt::DefaultLocaleLongDate:
return QLocale().toString(*this, QLocale::LongFormat);
case Qt::RFC2822Date:
- return QLocale::c().toString(*this, QStringViewLiteral("dd MMM yyyy"));
+ return QLocale::c().toString(*this, u"dd MMM yyyy");
default:
#if QT_CONFIG(textdate)
case Qt::TextDate:
@@ -3272,10 +3270,9 @@ inline qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QT
provides functions for comparing datetimes and for manipulating a
datetime by adding a number of seconds, days, months, or years.
- QDateTime can describe datetimes with respect to
- \l{Qt::LocalTime}{local time}, to \l{Qt::UTC}{UTC}, to a specified
- \l{Qt::OffsetFromUTC}{offset from UTC} or to a specified
- \l{Qt::TimeZone}{time zone}, in conjunction
+ QDateTime can describe datetimes with respect to \l{Qt::LocalTime}{local
+ time}, to \l{Qt::UTC}{UTC}, to a specified \l{Qt::OffsetFromUTC}{offset
+ from UTC} or to a specified \l{Qt::TimeZone}{time zone}, in conjunction
with the QTimeZone class. For example, a time zone of "Europe/Berlin" will
apply the daylight-saving rules as used in Germany since 1970. In contrast,
an offset from UTC of +3600 seconds is one hour ahead of UTC (usually
@@ -4065,12 +4062,10 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC)
Returns the datetime as a string in the \a format given.
- If the \a format is Qt::TextDate, the string is formatted in
- the default way. QDate::shortDayName(), QDate::shortMonthName(),
- and QTime::toString() are used to generate the string, so the
- day and month names will be localized names using the system locale,
- i.e. QLocale::system(). An example of this formatting is
- "Wed May 20 03:40:13 1998".
+ If the \a format is Qt::TextDate, the string is formatted in the default
+ way. The day and month names will be localized names using the system
+ locale, i.e. QLocale::system(). An example of this formatting is "Wed May 20
+ 03:40:13 1998".
If the \a format is Qt::ISODate, the string format corresponds
to the ISO 8601 extended specification for representations of
@@ -4127,7 +4122,7 @@ QString QDateTime::toString(Qt::DateFormat format) const
case Qt::DefaultLocaleLongDate:
return QLocale().toString(*this, QLocale::LongFormat);
case Qt::RFC2822Date: {
- buf = QLocale::c().toString(*this, QStringViewLiteral("dd MMM yyyy hh:mm:ss "));
+ buf = QLocale::c().toString(*this, u"dd MMM yyyy hh:mm:ss ");
buf += toOffsetString(Qt::TextDate, offsetFromUtc());
return buf;
}
@@ -5239,18 +5234,14 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format)
\row \li dd \li the day as number with a leading zero (01 to 31)
\row \li ddd
\li the abbreviated localized day name (e.g. 'Mon' to 'Sun').
- Uses QDate::shortDayName().
\row \li dddd
\li the long localized day name (e.g. 'Monday' to 'Sunday').
- Uses QDate::longDayName().
\row \li M \li the month as number without a leading zero (1-12)
\row \li MM \li the month as number with a leading zero (01-12)
\row \li MMM
\li the abbreviated localized month name (e.g. 'Jan' to 'Dec').
- Uses QDate::shortMonthName().
\row \li MMMM
\li the long localized month name (e.g. 'January' to 'December').
- Uses QDate::longMonthName().
\row \li yy \li the year as two digit number (00-99)
\row \li yyyy \li the year as four digit number
\endtable
@@ -5631,7 +5622,7 @@ QDebug operator<<(QDebug dbg, const QTime &time)
QDebugStateSaver saver(dbg);
dbg.nospace() << "QTime(";
if (time.isValid())
- dbg.nospace() << time.toString(QStringViewLiteral("HH:mm:ss.zzz"));
+ dbg.nospace() << time.toString(u"HH:mm:ss.zzz");
else
dbg.nospace() << "Invalid";
dbg.nospace() << ')';
@@ -5644,7 +5635,7 @@ QDebug operator<<(QDebug dbg, const QDateTime &date)
dbg.nospace() << "QDateTime(";
if (date.isValid()) {
const Qt::TimeSpec ts = date.timeSpec();
- dbg.noquote() << date.toString(QStringViewLiteral("yyyy-MM-dd HH:mm:ss.zzz t"))
+ dbg.noquote() << date.toString(u"yyyy-MM-dd HH:mm:ss.zzz t")
<< ' ' << ts;
switch (ts) {
case Qt::UTC:
diff --git a/src/corelib/tools/qalgorithms.qdoc b/src/corelib/tools/qalgorithms.qdoc
index a73ec1e22a..c86e69f9c3 100644
--- a/src/corelib/tools/qalgorithms.qdoc
+++ b/src/corelib/tools/qalgorithms.qdoc
@@ -155,8 +155,8 @@
\section2 Porting guidelines
- Most of the times, an application using the deprecated Qt algorithmic functions
- can be easily ported to use the equivalent STL functions. You need to
+ Most of the time, an application using the deprecated Qt algorithmic functions
+ can be easily ported to use the equivalent STL functions. You need to:
\list 1
\li add the \c{#include <algorithm>} preprocessor directive;
diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h
index 0322615f91..af5173c9ad 100644
--- a/src/corelib/tools/qarraydatapointer.h
+++ b/src/corelib/tools/qarraydatapointer.h
@@ -202,22 +202,11 @@ inline bool operator!=(const QArrayDataPointer<T> &lhs, const QArrayDataPointer<
}
template <class T>
-inline void qSwap(QArrayDataPointer<T> &p1, QArrayDataPointer<T> &p2)
+inline void swap(QArrayDataPointer<T> &p1, QArrayDataPointer<T> &p2)
{
p1.swap(p2);
}
QT_END_NAMESPACE
-namespace std
-{
- template <class T>
- inline void swap(
- QT_PREPEND_NAMESPACE(QArrayDataPointer)<T> &p1,
- QT_PREPEND_NAMESPACE(QArrayDataPointer)<T> &p2)
- {
- p1.swap(p2);
- }
-}
-
#endif // include guard
diff --git a/src/corelib/tools/qcontainerfwd.h b/src/corelib/tools/qcontainerfwd.h
index 646d8908c3..532b4c95ce 100644
--- a/src/corelib/tools/qcontainerfwd.h
+++ b/src/corelib/tools/qcontainerfwd.h
@@ -47,7 +47,9 @@ QT_BEGIN_NAMESPACE
template <class Key, class T> class QCache;
template <class Key, class T> class QHash;
+#ifndef QT_NO_LINKED_LIST
template <class T> class QLinkedList;
+#endif
template <class T> class QList;
template <class Key, class T> class QMap;
template <class Key, class T> class QMultiHash;
diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp
index c807bbd2e1..8e00c46b41 100644
--- a/src/corelib/tools/qeasingcurve.cpp
+++ b/src/corelib/tools/qeasingcurve.cpp
@@ -907,6 +907,10 @@ struct TCBEase : public BezierEase
return BezierEase::value(x);
}
+ QEasingCurveFunction *copy() const override
+ {
+ return new TCBEase{*this};
+ }
};
struct ElasticEase : public QEasingCurveFunction
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 4b4cb2d5f0..236e433101 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -136,7 +136,7 @@ struct QHashDummyValue
{
};
-inline bool operator==(const QHashDummyValue & /* v1 */, const QHashDummyValue & /* v2 */)
+constexpr bool operator==(const QHashDummyValue &, const QHashDummyValue &) noexcept
{
return true;
}
@@ -957,44 +957,32 @@ Q_OUTOFLINE_TEMPLATE typename QHash<Key, T>::Node **QHash<Key, T>::findNode(cons
template <class Key, class T>
Q_OUTOFLINE_TEMPLATE bool QHash<Key, T>::operator==(const QHash &other) const
{
- if (size() != other.size())
- return false;
if (d == other.d)
return true;
+ if (size() != other.size())
+ return false;
const_iterator it = begin();
while (it != end()) {
// Build two equal ranges for i.key(); one for *this and one for other.
// For *this we can avoid a lookup via equal_range, as we know the beginning of the range.
- auto thisEqualRangeEnd = it;
- while (thisEqualRangeEnd != end() && it.key() == thisEqualRangeEnd.key())
- ++thisEqualRangeEnd;
+ auto thisEqualRangeStart = it;
+ const Key &thisEqualRangeKey = it.key();
+ size_type n = 0;
+ do {
+ ++it;
+ ++n;
+ } while (it != end() && it.key() == thisEqualRangeKey);
- const auto otherEqualRange = other.equal_range(it.key());
+ const auto otherEqualRange = other.equal_range(thisEqualRangeKey);
- if (std::distance(it, thisEqualRangeEnd) != std::distance(otherEqualRange.first, otherEqualRange.second))
+ if (n != std::distance(otherEqualRange.first, otherEqualRange.second))
return false;
// Keys in the ranges are equal by construction; this checks only the values.
- //
- // When using the 3-arg std::is_permutation, MSVC will emit warning C4996,
- // passing an unchecked iterator to a Standard Library algorithm. We don't
- // want to suppress the warning, and we can't use stdext::make_checked_array_iterator
- // because QHash::(const_)iterator does not work with size_t and thus will
- // emit more warnings. Use the 4-arg std::is_permutation instead (which
- // is supported since MSVC 2015).
- //
- // ### Qt 6: if C++14 library support is a mandated minimum, remove the ifdef for MSVC.
- if (!std::is_permutation(it, thisEqualRangeEnd, otherEqualRange.first
-#ifdef Q_CC_MSVC
- , otherEqualRange.second
-#endif
- )) {
+ if (!qt_is_permutation(thisEqualRangeStart, it, otherEqualRange.first, otherEqualRange.second))
return false;
- }
-
- it = thisEqualRangeEnd;
}
return true;
diff --git a/src/corelib/tools/qlinkedlist.cpp b/src/corelib/tools/qlinkedlist.cpp
index d239fe0ef4..3b1bc8aab1 100644
--- a/src/corelib/tools/qlinkedlist.cpp
+++ b/src/corelib/tools/qlinkedlist.cpp
@@ -37,6 +37,10 @@
**
****************************************************************************/
+#ifdef QT_NO_LINKED_LIST
+# undef QT_NO_LINKED_LIST
+#endif
+
#include "qlinkedlist.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h
index d4e5bca0ed..996a50fd1b 100644
--- a/src/corelib/tools/qlinkedlist.h
+++ b/src/corelib/tools/qlinkedlist.h
@@ -40,6 +40,10 @@
#ifndef QLINKEDLIST_H
#define QLINKEDLIST_H
+#include <QtCore/qglobal.h>
+
+#ifndef QT_NO_LINKED_LIST
+
#include <QtCore/qiterator.h>
#include <QtCore/qrefcount.h>
#include <QtCore/qcontainertools_impl.h>
@@ -581,4 +585,8 @@ inline QDataStream &operator<<(QDataStream &s, const QLinkedList<T> &l)
QT_END_NAMESPACE
+Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE(QLinkedList)
+
+#endif // QT_NO_LINKED_LIST
+
#endif // QLINKEDLIST_H
diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h
index ab54c76720..f123f8e7b9 100644
--- a/src/corelib/tools/qshareddata.h
+++ b/src/corelib/tools/qshareddata.h
@@ -297,25 +297,13 @@ template <class T> inline bool operator==(const QExplicitlySharedDataPointer<T>
}
template <class T>
-Q_INLINE_TEMPLATE void qSwap(QSharedDataPointer<T> &p1, QSharedDataPointer<T> &p2)
+Q_INLINE_TEMPLATE void swap(QSharedDataPointer<T> &p1, QSharedDataPointer<T> &p2)
{ p1.swap(p2); }
template <class T>
-Q_INLINE_TEMPLATE void qSwap(QExplicitlySharedDataPointer<T> &p1, QExplicitlySharedDataPointer<T> &p2)
+Q_INLINE_TEMPLATE void swap(QExplicitlySharedDataPointer<T> &p1, QExplicitlySharedDataPointer<T> &p2)
{ p1.swap(p2); }
-QT_END_NAMESPACE
-namespace std {
- template <class T>
- Q_INLINE_TEMPLATE void swap(QT_PREPEND_NAMESPACE(QSharedDataPointer)<T> &p1, QT_PREPEND_NAMESPACE(QSharedDataPointer)<T> &p2)
- { p1.swap(p2); }
-
- template <class T>
- Q_INLINE_TEMPLATE void swap(QT_PREPEND_NAMESPACE(QExplicitlySharedDataPointer)<T> &p1, QT_PREPEND_NAMESPACE(QExplicitlySharedDataPointer)<T> &p2)
- { p1.swap(p2); }
-}
-QT_BEGIN_NAMESPACE
-
template <class T>
Q_INLINE_TEMPLATE uint qHash(const QSharedDataPointer<T> &ptr, uint seed = 0) noexcept
{
diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp
index fa6c45aa11..0b11e7c77b 100644
--- a/src/corelib/tools/qtimeline.cpp
+++ b/src/corelib/tools/qtimeline.cpp
@@ -526,29 +526,24 @@ QTimeLine::CurveShape QTimeLine::curveShape() const
return EaseInOutCurve;
}
-void QTimeLine::setCurveShape(CurveShape shape)
+static QEasingCurve::Type convert(QTimeLine::CurveShape shape)
{
switch (shape) {
- default:
- case EaseInOutCurve:
- setEasingCurve(QEasingCurve(QEasingCurve::InOutSine));
- break;
- case EaseInCurve:
- setEasingCurve(QEasingCurve(QEasingCurve::InCurve));
- break;
- case EaseOutCurve:
- setEasingCurve(QEasingCurve(QEasingCurve::OutCurve));
- break;
- case LinearCurve:
- setEasingCurve(QEasingCurve(QEasingCurve::Linear));
- break;
- case SineCurve:
- setEasingCurve(QEasingCurve(QEasingCurve::SineCurve));
- break;
- case CosineCurve:
- setEasingCurve(QEasingCurve(QEasingCurve::CosineCurve));
- break;
+#define CASE(x, y) case QTimeLine::x: return QEasingCurve::y
+ CASE(EaseInOutCurve, InOutSine);
+ CASE(EaseInCurve, InCurve);
+ CASE(EaseOutCurve, OutCurve);
+ CASE(LinearCurve, Linear);
+ CASE(SineCurve, SineCurve);
+ CASE(CosineCurve, CosineCurve);
+#undef CASE
}
+ Q_UNREACHABLE();
+}
+
+void QTimeLine::setCurveShape(CurveShape shape)
+{
+ setEasingCurve(convert(shape));
}
/*!
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index ba65ae7ef2..2f62526076 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -112,7 +112,9 @@ public:
inline void removeLast() {
Q_ASSERT(s > 0);
- realloc(s - 1, a);
+ if (QTypeInfo<T>::isComplex)
+ ptr[s - 1].~T();
+ --s;
}
inline int size() const { return s; }
inline int count() const { return s; }
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 65a5174abf..ebe6527d89 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -424,7 +424,7 @@ template <typename T>
void QVector<T>::resize(int asize)
{
if (asize == d->size)
- return;
+ return detach();
if (asize > int(d->alloc) || !isDetached()) { // there is not enough space
QArrayData::AllocationOptions opt = asize > int(d->alloc) ? QArrayData::Grow : QArrayData::Default;
realloc(qMax(int(d->alloc), asize), opt);
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index 52eddd5d6b..a2236f90f2 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -8,19 +8,10 @@ HEADERS += \
tools/qarraydataops.h \
tools/qarraydatapointer.h \
tools/qbitarray.h \
- tools/qbytearray.h \
- tools/qbytearray_p.h \
- tools/qbytearraylist.h \
- tools/qbytearraymatcher.h \
- tools/qbytedata_p.h \
tools/qcache.h \
- tools/qchar.h \
- tools/qcollator.h \
- tools/qcollator_p.h \
tools/qcontainerfwd.h \
tools/qcontainertools_impl.h \
tools/qcryptographichash.h \
- tools/qdoublescanprint_p.h \
tools/qeasingcurve.h \
tools/qfreelist_p.h \
tools/qhash.h \
@@ -29,10 +20,6 @@ HEADERS += \
tools/qline.h \
tools/qlinkedlist.h \
tools/qlist.h \
- tools/qlocale.h \
- tools/qlocale_p.h \
- tools/qlocale_tools_p.h \
- tools/qlocale_data_p.h \
tools/qmakearray_p.h \
tools/qmap.h \
tools/qmargins.h \
@@ -43,7 +30,6 @@ HEADERS += \
tools/qpoint.h \
tools/qqueue.h \
tools/qrect.h \
- tools/qregexp.h \
tools/qringbuffer_p.h \
tools/qrefcount.h \
tools/qscopeguard.h \
@@ -57,20 +43,8 @@ HEADERS += \
tools/qsimd_p.h \
tools/qsize.h \
tools/qstack.h \
- tools/qstring.h \
- tools/qstringalgorithms.h \
- tools/qstringalgorithms_p.h \
- tools/qstringbuilder.h \
- tools/qstringiterator_p.h \
- tools/qstringlist.h \
- tools/qstringliteral.h \
- tools/qstringmatcher.h \
- tools/qstringview.h \
- tools/qtextboundaryfinder.h \
tools/qtimeline.h \
tools/qtools_p.h \
- tools/qunicodetables_p.h \
- tools/qunicodetools_p.h \
tools/qvarlengtharray.h \
tools/qvector.h \
tools/qversionnumber.h
@@ -79,10 +53,6 @@ HEADERS += \
SOURCES += \
tools/qarraydata.cpp \
tools/qbitarray.cpp \
- tools/qbytearray.cpp \
- tools/qbytearraylist.cpp \
- tools/qbytearraymatcher.cpp \
- tools/qcollator.cpp \
tools/qcryptographichash.cpp \
tools/qeasingcurve.cpp \
tools/qfreelist.cpp \
@@ -90,47 +60,24 @@ SOURCES += \
tools/qline.cpp \
tools/qlinkedlist.cpp \
tools/qlist.cpp \
- tools/qlocale.cpp \
- tools/qlocale_tools.cpp \
tools/qpoint.cpp \
tools/qmap.cpp \
tools/qmargins.cpp \
tools/qmessageauthenticationcode.cpp \
tools/qcontiguouscache.cpp \
tools/qrect.cpp \
- tools/qregexp.cpp \
tools/qrefcount.cpp \
tools/qringbuffer.cpp \
tools/qshareddata.cpp \
tools/qsharedpointer.cpp \
tools/qsimd.cpp \
tools/qsize.cpp \
- tools/qstring.cpp \
- tools/qstringbuilder.cpp \
- tools/qstringlist.cpp \
- tools/qstringview.cpp \
- tools/qtextboundaryfinder.cpp \
tools/qtimeline.cpp \
- tools/qunicodetools.cpp \
- tools/qvsnprintf.cpp \
tools/qversionnumber.cpp
-NO_PCH_SOURCES = tools/qstring_compat.cpp
msvc: NO_PCH_SOURCES += tools/qvector_msvc.cpp
false: SOURCES += $$NO_PCH_SOURCES # Hack for QtCreator
-!nacl:mac: {
- SOURCES += tools/qlocale_mac.mm
-}
-else:unix {
- SOURCES += tools/qlocale_unix.cpp
-}
-else:win32 {
- SOURCES += tools/qlocale_win.cpp
-} else:integrity {
- SOURCES += tools/qlocale_unix.cpp
-}
-
qtConfig(system-zlib) {
include($$PWD/../../3rdparty/zlib_dependency.pri)
} else {
@@ -138,27 +85,6 @@ qtConfig(system-zlib) {
include($$PWD/../../3rdparty/zlib.pri)
}
-qtConfig(icu) {
- QMAKE_USE_PRIVATE += icu
-
- SOURCES += tools/qlocale_icu.cpp \
- tools/qcollator_icu.cpp
-} else: win32 {
- SOURCES += tools/qcollator_win.cpp
-} else: macx {
- SOURCES += tools/qcollator_macx.cpp
-} else {
- SOURCES += tools/qcollator_posix.cpp
-}
-
-qtConfig(regularexpression) {
- QMAKE_USE_PRIVATE += pcre2
-
- HEADERS += \
- tools/qregularexpression.h
- SOURCES += tools/qregularexpression.cpp
-}
-
qtConfig(commandlineparser) {
HEADERS += \
tools/qcommandlineoption.h \
@@ -168,19 +94,6 @@ qtConfig(commandlineparser) {
tools/qcommandlineparser.cpp
}
-INCLUDEPATH += ../3rdparty/harfbuzz/src
-HEADERS += ../3rdparty/harfbuzz/src/harfbuzz.h
-SOURCES += ../3rdparty/harfbuzz/src/harfbuzz-buffer.c \
- ../3rdparty/harfbuzz/src/harfbuzz-gdef.c \
- ../3rdparty/harfbuzz/src/harfbuzz-gsub.c \
- ../3rdparty/harfbuzz/src/harfbuzz-gpos.c \
- ../3rdparty/harfbuzz/src/harfbuzz-impl.c \
- ../3rdparty/harfbuzz/src/harfbuzz-open.c \
- ../3rdparty/harfbuzz/src/harfbuzz-stream.c \
- ../3rdparty/harfbuzz/src/harfbuzz-shaper-all.cpp \
- tools/qharfbuzz.cpp
-HEADERS += tools/qharfbuzz_p.h
-
INCLUDEPATH += ../3rdparty/md5 \
../3rdparty/md4 \
../3rdparty/sha3
@@ -197,5 +110,4 @@ unix:!macx-icc:!vxworks:!haiku:!integrity:!wasm: LIBS_PRIVATE += -lm
TR_EXCLUDE += ../3rdparty/*
# MIPS DSP
-MIPS_DSP_ASM += tools/qstring_mips_dsp_asm.S
MIPS_DSP_HEADERS += ../gui/painting/qt_mips_asm_dsp_p.h