summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-12-30 17:39:21 +0100
committerLars Knoll <lars.knoll@qt.io>2018-01-02 09:58:44 +0100
commit0f315adf9199efcfafa44371464ab6d1fc866774 (patch)
tree35b67591255624c670aff0579e45b2973f56fd81 /src/corelib
parent2b0eb3fac319a17dd92903106d501f0f06df871f (diff)
parent52b85212a2ec8ec5bf187f6cd00b669a45bcf0bd (diff)
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts: .qmake.conf sc/corelib/io/qfsfileengine_p.h src/corelib/io/qstorageinfo_unix.cpp src/platformsupport/eglconvenience/qeglpbuffer_p.h src/platformsupport/input/libinput/qlibinputkeyboard.cpp src/platformsupport/input/libinput/qlibinputpointer.cpp src/plugins/platforms/cocoa/qcocoamenu.mm src/plugins/platforms/ios/qiosscreen.h src/plugins/platforms/ios/qioswindow.h src/plugins/platforms/ios/quiview.mm src/printsupport/dialogs/qpagesetupdialog_unix_p.h src/printsupport/dialogs/qprintpreviewdialog.cpp src/printsupport/widgets/qcupsjobwidget_p.h src/widgets/widgets/qmenu.cpp tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp Change-Id: Iecb4883122efe97ef0ed850271e6c51bab568e9c
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/animation/qabstractanimation.cpp4
-rw-r--r--src/corelib/configure.json19
-rw-r--r--src/corelib/doc/qtcore.qdocconf3
-rw-r--r--src/corelib/doc/snippets/qstring/main.cpp13
-rw-r--r--src/corelib/global/global.pri5
-rw-r--r--src/corelib/global/minimum-linux_p.h2
-rw-r--r--src/corelib/global/qconfig-bootstrapped.h5
-rw-r--r--src/corelib/global/qfloat16.cpp24
-rw-r--r--src/corelib/global/qfloat16.h4
-rw-r--r--src/corelib/global/qfloat16_f16c.c8
-rw-r--r--src/corelib/global/qfloat16_p.h4
-rw-r--r--src/corelib/global/qglobal.cpp11
-rw-r--r--src/corelib/global/qglobal.h6
-rw-r--r--src/corelib/global/qlogging.cpp10
-rw-r--r--src/corelib/global/qnamespace.h2
-rw-r--r--src/corelib/global/qoperatingsystemversion_win.cpp3
-rw-r--r--src/corelib/global/qoperatingsystemversion_win_p.h63
-rw-r--r--src/corelib/global/qrandom.cpp85
-rw-r--r--src/corelib/global/qrandom.h28
-rw-r--r--src/corelib/io/qfile.cpp3
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp78
-rwxr-xr-x[-rw-r--r--]src/corelib/io/qfilesystemengine_win.cpp64
-rw-r--r--src/corelib/io/qfilesystemmetadata_p.h4
-rw-r--r--src/corelib/io/qfsfileengine_p.h3
-rw-r--r--src/corelib/io/qloggingregistry.cpp4
-rw-r--r--src/corelib/io/qloggingregistry_p.h2
-rw-r--r--src/corelib/io/qprocess.cpp6
-rw-r--r--src/corelib/io/qresource.cpp4
-rw-r--r--src/corelib/io/qsettings.cpp2
-rw-r--r--src/corelib/io/qstandardpaths.cpp29
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp18
-rw-r--r--src/corelib/io/qtemporaryfile.cpp22
-rw-r--r--src/corelib/io/qtemporaryfile_p.h8
-rw-r--r--src/corelib/io/qurl.cpp110
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.cpp8
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.h6
-rw-r--r--src/corelib/kernel/kernel.pri2
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp6
-rw-r--r--src/corelib/kernel/qjnihelpers.cpp2
-rw-r--r--src/corelib/kernel/qobject.cpp2
-rw-r--r--src/corelib/kernel/qppsobjectprivate_p.h4
-rw-r--r--src/corelib/plugin/qlibrary_win.cpp7
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp6
-rw-r--r--src/corelib/thread/qfuturewatcher.h2
-rw-r--r--src/corelib/tools/qdatetime.cpp4
-rw-r--r--src/corelib/tools/qdatetime.h2
-rw-r--r--src/corelib/tools/qdatetimeparser.cpp48
-rw-r--r--src/corelib/tools/qdatetimeparser_p.h5
-rw-r--r--src/corelib/tools/qlocale.cpp4
-rw-r--r--src/corelib/tools/qmap.h4
-rw-r--r--src/corelib/tools/qstring.cpp86
-rw-r--r--src/corelib/tools/qstringalgorithms.h2
-rw-r--r--src/corelib/tools/qstringiterator.qdoc2
-rw-r--r--src/corelib/tools/qstringiterator_p.h2
-rw-r--r--src/corelib/tools/qstringview.cpp34
-rw-r--r--src/corelib/tools/qstringview.h41
-rw-r--r--src/corelib/tools/qunicodetables.cpp20
-rw-r--r--src/corelib/tools/qunicodetables_p.h4
-rw-r--r--src/corelib/tools/qvector.h5
-rw-r--r--src/corelib/xml/qxmlstream.cpp1
60 files changed, 691 insertions, 274 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index 2041b8816e..e445037efb 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -299,13 +299,13 @@ void QUnifiedTimer::stopAnimationDriver()
driver->stop();
}
-void QUnifiedTimer::updateAnimationTimers(qint64)
+void QUnifiedTimer::updateAnimationTimers(qint64 currentTick)
{
//setCurrentTime can get this called again while we're the for loop. At least with pauseAnimations
if(insideTick)
return;
- qint64 totalElapsed = elapsed();
+ qint64 totalElapsed = currentTick > 0 ? currentTick : elapsed();
// ignore consistentTiming in case the pause timer is active
qint64 delta = (consistentTiming && !pauseTimer.isActive()) ?
diff --git a/src/corelib/configure.json b/src/corelib/configure.json
index 8067ca70f1..8cd73d6ce4 100644
--- a/src/corelib/configure.json
+++ b/src/corelib/configure.json
@@ -178,7 +178,7 @@
"slog2": {
"label": "slog2",
"test": {
- "include": "slog2.h",
+ "include": "sys/slog2.h",
"main": "slog2_set_default_buffer((slog2_buffer_t)-1);"
},
"export": "",
@@ -349,6 +349,15 @@
"qmake": "linux: LIBS += -lpthread -lrt"
}
},
+ "linkat": {
+ "label": "linkat()",
+ "type": "compile",
+ "test": {
+ "head": "#define _ATFILE_SOURCE 1",
+ "include": [ "fcntl.h", "unistd.h" ],
+ "main": "linkat(AT_FDCWD, \"foo\", AT_FDCWD, \"bar\", AT_SYMLINK_FOLLOW);"
+ }
+ },
"ppoll": {
"label": "ppoll()",
"type": "compile",
@@ -540,6 +549,12 @@
"condition": "libs.journald",
"output": [ "privateFeature" ]
},
+ "linkat": {
+ "label": "linkat()",
+ "autoDetect": "config.linux",
+ "condition": "tests.linkat",
+ "output": [ "privateFeature" ]
+ },
"std-atomic64": {
"label": "64 bit atomic operations",
"condition": "libs.libatomic",
@@ -593,7 +608,7 @@
"label": "PPS",
"emitIf": "config.qnx",
"condition": "libs.pps",
- "output": [ "privateConfig" ]
+ "output": [ "privateFeature" ]
},
"qeventtransition": {
"label": "QEventTransition class",
diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf
index 3d64708def..5a42e21845 100644
--- a/src/corelib/doc/qtcore.qdocconf
+++ b/src/corelib/doc/qtcore.qdocconf
@@ -45,5 +45,8 @@ excludedirs += snippets
excludefiles += ../../../examples/widgets/tools/customcompleter/doc/src/customcompleter.qdoc \
../../../examples/widgets/tools/codecs/doc/src/codecs.qdoc
+manifestmeta.highlighted.names = "QtCore/JSON Save Game Example" \
+ "QtCore/Local Fortune*"
+
navigation.landingpage = "Qt Core"
navigation.cppclassespage = "Qt Core C++ Classes"
diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp
index 3d09e3618e..b936f0c057 100644
--- a/src/corelib/doc/snippets/qstring/main.cpp
+++ b/src/corelib/doc/snippets/qstring/main.cpp
@@ -750,7 +750,6 @@ void Widget::sizeFunction()
int n = str.size(); // n == 5
str.data()[0]; // returns 'W'
str.data()[4]; // returns 'd'
- str.data()[5]; // returns '\0'
//! [58]
}
@@ -810,6 +809,18 @@ void Widget::splitCaseSensitiveFunction()
QStringList list2 = str.split(',', QString::SkipEmptyParts);
// list2: [ "a", "b", "c" ]
//! [62]
+
+ //! [62-empty]
+ QString str = "abc";
+ auto parts = str.split("");
+ // parts: {"", "a", "b", "c", ""}
+ //! [62-empty]
+
+ //! [62-slashes]
+ QString str = "/a/b/c/";
+ auto parts = str.split('/');
+ // parts: {"", "a", "b", "c", ""}
+ //! [62-slashes]
}
void Widget::sprintfFunction()
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri
index a878a83bcb..2b4fd6d661 100644
--- a/src/corelib/global/global.pri
+++ b/src/corelib/global/global.pri
@@ -63,7 +63,10 @@ unset(f16c_cxx)
VERSIONTAGGING_SOURCES = global/qversiontagging.cpp
darwin: SOURCES += global/qoperatingsystemversion_darwin.mm
-win32: SOURCES += global/qoperatingsystemversion_win.cpp
+win32 {
+ SOURCES += global/qoperatingsystemversion_win.cpp
+ HEADERS += global/qoperatingsystemversion_win_p.h
+}
# qlibraryinfo.cpp includes qconfig.cpp
INCLUDEPATH += $$QT_BUILD_TREE/src/corelib/global
diff --git a/src/corelib/global/minimum-linux_p.h b/src/corelib/global/minimum-linux_p.h
index 324744b856..bad2488b4d 100644
--- a/src/corelib/global/minimum-linux_p.h
+++ b/src/corelib/global/minimum-linux_p.h
@@ -67,7 +67,7 @@ QT_BEGIN_NAMESPACE
* - inotify_init1 before 2.6.12-rc12
* - futex(2) before 2.6.12-rc12
* - FUTEX_WAKE_OP 2.6.14 FUTEX_OP
- * - linkat(2) 2.6.17 O_TMPFILE
+ * - linkat(2) 2.6.17 O_TMPFILE && QT_CONFIG(linkat)
* - FUTEX_PRIVATE_FLAG 2.6.22
* - O_CLOEXEC 2.6.23
* - eventfd 2.6.23
diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h
index eb56d2d0cd..0df593941d 100644
--- a/src/corelib/global/qconfig-bootstrapped.h
+++ b/src/corelib/global/qconfig-bootstrapped.h
@@ -87,6 +87,11 @@
#define QT_FEATURE_futimens -1
#define QT_FEATURE_futimes -1
#define QT_FEATURE_library -1
+#ifdef __linux__
+# define QT_FEATURE_linkat 1
+#else
+# define QT_FEATURE_linkat -1
+#endif
#define QT_NO_QOBJECT
#define QT_FEATURE_process -1
#define QT_FEATURE_regularexpression -1
diff --git a/src/corelib/global/qfloat16.cpp b/src/corelib/global/qfloat16.cpp
index 129ab4ded2..3046a47292 100644
--- a/src/corelib/global/qfloat16.cpp
+++ b/src/corelib/global/qfloat16.cpp
@@ -129,8 +129,8 @@ extern "C" {
# define f16cextern extern
#endif
-f16cextern void qFloatToFloat16_fast(quint16 *out, const float *in, qssize_t len) Q_DECL_NOTHROW;
-f16cextern void qFloatFromFloat16_fast(float *out, const quint16 *in, qssize_t len) Q_DECL_NOTHROW;
+f16cextern void qFloatToFloat16_fast(quint16 *out, const float *in, qsizetype len) Q_DECL_NOTHROW;
+f16cextern void qFloatFromFloat16_fast(float *out, const quint16 *in, qsizetype len) Q_DECL_NOTHROW;
#undef f16cextern
}
@@ -141,20 +141,20 @@ static inline bool hasFastF16()
return true;
}
-static void qFloatToFloat16_fast(quint16 *out, const float *in, qssize_t len) Q_DECL_NOTHROW
+static void qFloatToFloat16_fast(quint16 *out, const float *in, qsizetype len) Q_DECL_NOTHROW
{
__fp16 *out_f16 = reinterpret_cast<__fp16 *>(out);
- qssize_t i = 0;
+ qsizetype i = 0;
for (; i < len - 3; i += 4)
vst1_f16(out_f16 + i, vcvt_f16_f32(vld1q_f32(in + i)));
SIMD_EPILOGUE(i, len, 3)
out_f16[i] = __fp16(in[i]);
}
-static void qFloatFromFloat16_fast(float *out, const quint16 *in, qssize_t len) Q_DECL_NOTHROW
+static void qFloatFromFloat16_fast(float *out, const quint16 *in, qsizetype len) Q_DECL_NOTHROW
{
const __fp16 *in_f16 = reinterpret_cast<const __fp16 *>(in);
- qssize_t i = 0;
+ qsizetype i = 0;
for (; i < len - 3; i += 4)
vst1q_f32(out + i, vcvt_f32_f16(vld1_f16(in_f16 + i)));
SIMD_EPILOGUE(i, len, 3)
@@ -166,12 +166,12 @@ static inline bool hasFastF16()
return false;
}
-static void qFloatToFloat16_fast(quint16 *, const float *, qssize_t) Q_DECL_NOTHROW
+static void qFloatToFloat16_fast(quint16 *, const float *, qsizetype) Q_DECL_NOTHROW
{
Q_UNREACHABLE();
}
-static void qFloatFromFloat16_fast(float *, const quint16 *, qssize_t) Q_DECL_NOTHROW
+static void qFloatFromFloat16_fast(float *, const quint16 *, qsizetype) Q_DECL_NOTHROW
{
Q_UNREACHABLE();
}
@@ -182,12 +182,12 @@ static void qFloatFromFloat16_fast(float *, const quint16 *, qssize_t) Q_DECL_NO
Converts \a len floats from \a in to qfloat16 and stores them in \a out.
Both \a in and \a out must have \a len allocated entries.
*/
-Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *out, const float *in, qssize_t len) Q_DECL_NOTHROW
+Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *out, const float *in, qsizetype len) Q_DECL_NOTHROW
{
if (hasFastF16())
return qFloatToFloat16_fast(reinterpret_cast<quint16 *>(out), in, len);
- for (qssize_t i = 0; i < len; ++i)
+ for (qsizetype i = 0; i < len; ++i)
out[i] = qfloat16(in[i]);
}
@@ -197,12 +197,12 @@ Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *out, const float *in, qssize_t len)
Converts \a len qfloat16 from \a in to floats and stores them in \a out.
Both \a in and \a out must have \a len allocated entries.
*/
-Q_CORE_EXPORT void qFloatFromFloat16(float *out, const qfloat16 *in, qssize_t len) Q_DECL_NOTHROW
+Q_CORE_EXPORT void qFloatFromFloat16(float *out, const qfloat16 *in, qsizetype len) Q_DECL_NOTHROW
{
if (hasFastF16())
return qFloatFromFloat16_fast(out, reinterpret_cast<const quint16 *>(in), len);
- for (qssize_t i = 0; i < len; ++i)
+ for (qsizetype i = 0; i < len; ++i)
out[i] = float(in[i]);
}
diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h
index bf223bee0c..a8befd7adb 100644
--- a/src/corelib/global/qfloat16.h
+++ b/src/corelib/global/qfloat16.h
@@ -88,8 +88,8 @@ private:
Q_DECLARE_TYPEINFO(qfloat16, Q_PRIMITIVE_TYPE);
-Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *, const float *, qssize_t length) Q_DECL_NOTHROW;
-Q_CORE_EXPORT void qFloatFromFloat16(float *, const qfloat16 *, qssize_t length) Q_DECL_NOTHROW;
+Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *, const float *, qsizetype length) Q_DECL_NOTHROW;
+Q_CORE_EXPORT void qFloatFromFloat16(float *, const qfloat16 *, qsizetype length) Q_DECL_NOTHROW;
Q_REQUIRED_RESULT Q_CORE_EXPORT bool qIsInf(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h
Q_REQUIRED_RESULT Q_CORE_EXPORT bool qIsNaN(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h
diff --git a/src/corelib/global/qfloat16_f16c.c b/src/corelib/global/qfloat16_f16c.c
index c88dbb6944..31dff0b154 100644
--- a/src/corelib/global/qfloat16_f16c.c
+++ b/src/corelib/global/qfloat16_f16c.c
@@ -54,9 +54,9 @@ extern "C" {
#endif
QT_FUNCTION_TARGET(F16C)
-void qFloatToFloat16_fast(quint16 *out, const float *in, qssize_t len) Q_DECL_NOTHROW
+void qFloatToFloat16_fast(quint16 *out, const float *in, qsizetype len) Q_DECL_NOTHROW
{
- qssize_t i = 0;
+ qsizetype i = 0;
for (; i < len - 7; i += 8)
_mm_storeu_si128((__m128i *)(out + i), _mm256_cvtps_ph(_mm256_loadu_ps(in + i), 0));
if (i < len - 3) {
@@ -69,9 +69,9 @@ void qFloatToFloat16_fast(quint16 *out, const float *in, qssize_t len) Q_DECL_NO
}
QT_FUNCTION_TARGET(F16C)
-void qFloatFromFloat16_fast(float *out, const quint16 *in, qssize_t len) Q_DECL_NOTHROW
+void qFloatFromFloat16_fast(float *out, const quint16 *in, qsizetype len) Q_DECL_NOTHROW
{
- qssize_t i = 0;
+ qsizetype i = 0;
for (; i < len - 7; i += 8)
_mm256_storeu_ps(out + i, _mm256_cvtph_ps(_mm_loadu_si128((const __m128i *)(in + i))));
if (i < len - 3) {
diff --git a/src/corelib/global/qfloat16_p.h b/src/corelib/global/qfloat16_p.h
index ae52e64435..f3fc96e119 100644
--- a/src/corelib/global/qfloat16_p.h
+++ b/src/corelib/global/qfloat16_p.h
@@ -61,9 +61,9 @@ static inline bool qt_is_inf(qfloat16 d) Q_DECL_NOTHROW
bool is_inf;
uchar *ch = (uchar *)&d;
if (QSysInfo::ByteOrder == QSysInfo::BigEndian)
- is_inf = (ch[0] & 0x7c) == 0x7c;
+ is_inf = (ch[0] & 0x7c) == 0x7c && (ch[0] & 0x02) == 0;
else
- is_inf = (ch[1] & 0x7c) == 0x7c;
+ is_inf = (ch[1] & 0x7c) == 0x7c && (ch[1] & 0x02) == 0;
return is_inf;
}
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index c3b074c59f..a8fa7654ba 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -46,6 +46,9 @@
#include "qdatetime.h"
#include "qoperatingsystemversion.h"
#include "qoperatingsystemversion_p.h"
+#if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) || defined(Q_OS_WINRT)
+#include "qoperatingsystemversion_win_p.h"
+#endif
#include <private/qlocale_tools_p.h>
#include <qmutex.h>
@@ -164,8 +167,8 @@ Q_STATIC_ASSERT_X(std::numeric_limits<float>::radix == 2,
// not required by the definition of size_t, but we depend on this
Q_STATIC_ASSERT_X(sizeof(size_t) == sizeof(void *), "size_t and a pointer don't have the same size");
-Q_STATIC_ASSERT(sizeof(size_t) == sizeof(qssize_t)); // implied by the definition
-Q_STATIC_ASSERT((std::is_same<qssize_t, qptrdiff>::value));
+Q_STATIC_ASSERT(sizeof(size_t) == sizeof(qsizetype)); // implied by the definition
+Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
/*!
\class QFlag
@@ -827,7 +830,7 @@ Q_STATIC_ASSERT((std::is_same<qssize_t, qptrdiff>::value));
*/
/*!
- \typedef qssize_t
+ \typedef qsizetype
\relates <QtGlobal>
\since 5.10
@@ -836,7 +839,7 @@ Q_STATIC_ASSERT((std::is_same<qssize_t, qptrdiff>::value));
This type is guaranteed to be the same size as a \c size_t on all
platforms supported by Qt.
- Note that qssize_t is signed. Use \c size_t for unsigned values.
+ Note that qsizetype is signed. Use \c size_t for unsigned values.
\sa qptrdiff
*/
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index d439085dbc..7873ab2b43 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -250,7 +250,7 @@ typedef quint64 qulonglong;
// In C++ mode, we define below using QIntegerForSize template
Q_STATIC_ASSERT_X(sizeof(ptrdiff_t) == sizeof(size_t), "Weird ptrdiff_t and size_t definitions");
typedef ptrdiff_t qptrdiff;
-typedef ptrdiff_t qssize_t;
+typedef ptrdiff_t qsizetype;
typedef ptrdiff_t qintptr;
typedef size_t quintptr;
#endif
@@ -475,7 +475,7 @@ namespace QtPrivate {
sizeof(void *) == sizeof(quintptr)
&& sizeof(void *) == sizeof(qptrdiff)
- size_t and qssize_t are not guaranteed to be the same size as a pointer, but
+ size_t and qsizetype are not guaranteed to be the same size as a pointer, but
they usually are.
*/
template <int> struct QIntegerForSize;
@@ -492,7 +492,7 @@ typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Unsigned qregisteruint;
typedef QIntegerForSizeof<void*>::Unsigned quintptr;
typedef QIntegerForSizeof<void*>::Signed qptrdiff;
typedef qptrdiff qintptr;
-using qssize_t = QIntegerForSizeof<std::size_t>::Signed;
+using qsizetype = QIntegerForSizeof<std::size_t>::Signed;
/* moc compats (signals/slots) */
#ifndef QT_MOC_COMPAT
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 6602d53b08..0861763492 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -61,7 +61,10 @@
#include <qt_windows.h>
#endif
#if QT_CONFIG(slog2)
-#include <slog2.h>
+#include <sys/slog2.h>
+#endif
+#if QT_HAS_INCLUDE(<paths.h>)
+#include <paths.h>
#endif
#ifdef Q_OS_ANDROID
@@ -215,8 +218,11 @@ static bool willLogToConsole()
# ifdef Q_OS_WIN
return GetConsoleWindow();
# elif defined(Q_OS_UNIX)
+# ifndef _PATH_TTY
+# define _PATH_TTY "/dev/tty"
+# endif
// if /dev/tty exists, we can only open it if we have a controlling TTY
- int devtty = qt_safe_open("/dev/tty", O_RDONLY);
+ int devtty = qt_safe_open(_PATH_TTY, O_RDONLY);
if (devtty == -1 && (errno == ENOENT || errno == EPERM || errno == ENXIO)) {
// no /dev/tty, fall back to isatty on stderr
return isatty(STDERR_FILENO);
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 38f194afb5..2773992b47 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -477,6 +477,8 @@ public:
WA_TabletTracking = 129,
+ WA_ContentsMarginsRespectsSafeArea = 130,
+
// Add new attributes before this line
WA_AttributeCount
};
diff --git a/src/corelib/global/qoperatingsystemversion_win.cpp b/src/corelib/global/qoperatingsystemversion_win.cpp
index 060ca2f7da..f3662ae1f9 100644
--- a/src/corelib/global/qoperatingsystemversion_win.cpp
+++ b/src/corelib/global/qoperatingsystemversion_win.cpp
@@ -37,7 +37,10 @@
**
****************************************************************************/
+#include "qoperatingsystemversion_win_p.h"
+
#include "qoperatingsystemversion_p.h"
+
#include <qt_windows.h>
#include <qbytearray.h>
diff --git a/src/corelib/global/qoperatingsystemversion_win_p.h b/src/corelib/global/qoperatingsystemversion_win_p.h
new file mode 100644
index 0000000000..446bd286fc
--- /dev/null
+++ b/src/corelib/global/qoperatingsystemversion_win_p.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 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 QOPERATINGSYSTEMVERSION_WIN_P_H
+#define QOPERATINGSYSTEMVERSION_WIN_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/qglobal.h>
+#include <qt_windows.h>
+
+QT_BEGIN_NAMESPACE
+
+OSVERSIONINFOEX qWindowsVersionInfo();
+
+QT_END_NAMESPACE
+
+#endif // QOPERATINGSYSTEMVERSION_WIN_P_H
diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp
index 7da86188bb..f5c01aeaa6 100644
--- a/src/corelib/global/qrandom.cpp
+++ b/src/corelib/global/qrandom.cpp
@@ -93,7 +93,7 @@ DECLSPEC_IMPORT BOOLEAN WINAPI SystemFunction036(PVOID RandomBuffer, ULONG Rando
QT_BEGIN_NAMESPACE
#if defined(Q_PROCESSOR_X86) && QT_COMPILER_SUPPORTS_HERE(RDRND)
-static qssize_t qt_random_cpu(void *buffer, qssize_t count) Q_DECL_NOTHROW;
+static qsizetype qt_random_cpu(void *buffer, qsizetype count) Q_DECL_NOTHROW;
# ifdef Q_PROCESSOR_X86_64
# define _rdrandXX_step _rdrand64_step
@@ -101,7 +101,7 @@ static qssize_t qt_random_cpu(void *buffer, qssize_t count) Q_DECL_NOTHROW;
# define _rdrandXX_step _rdrand32_step
# endif
-static QT_FUNCTION_TARGET(RDRND) qssize_t qt_random_cpu(void *buffer, qssize_t count) Q_DECL_NOTHROW
+static QT_FUNCTION_TARGET(RDRND) qsizetype qt_random_cpu(void *buffer, qsizetype count) Q_DECL_NOTHROW
{
unsigned *ptr = reinterpret_cast<unsigned *>(buffer);
unsigned *end = ptr + count;
@@ -122,7 +122,7 @@ out:
return ptr - reinterpret_cast<unsigned *>(buffer);
}
#else
-static qssize_t qt_random_cpu(void *, qssize_t)
+static qsizetype qt_random_cpu(void *, qsizetype)
{
return 0;
}
@@ -136,10 +136,10 @@ enum {
struct QRandomGenerator::SystemGenerator
{
#if QT_CONFIG(getentropy)
- static qssize_t fillBuffer(void *buffer, qssize_t count) Q_DECL_NOTHROW
+ static qsizetype fillBuffer(void *buffer, qsizetype count) Q_DECL_NOTHROW
{
// getentropy can read at most 256 bytes, so break the reading
- qssize_t read = 0;
+ qsizetype read = 0;
while (count - read > 256) {
// getentropy can't fail under normal circumstances
int ret = getentropy(reinterpret_cast<uchar *>(buffer) + read, 256);
@@ -195,24 +195,24 @@ struct QRandomGenerator::SystemGenerator
Q_DECL_CONSTEXPR SystemGenerator() : fdp1 Q_BASIC_ATOMIC_INITIALIZER(0) {}
- qssize_t fillBuffer(void *buffer, qssize_t count)
+ qsizetype fillBuffer(void *buffer, qsizetype count)
{
int fd = openDevice();
if (Q_UNLIKELY(fd < 0))
return 0;
qint64 n = qt_safe_read(fd, buffer, count);
- return qMax<qssize_t>(n, 0); // ignore any errors
+ return qMax<qsizetype>(n, 0); // ignore any errors
}
#elif defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
- qssize_t fillBuffer(void *buffer, qssize_t count) Q_DECL_NOTHROW
+ qsizetype fillBuffer(void *buffer, qsizetype count) Q_DECL_NOTHROW
{
auto RtlGenRandom = SystemFunction036;
return RtlGenRandom(buffer, ULONG(count)) ? count: 0;
}
#elif defined(Q_OS_WINRT)
- qssize_t fillBuffer(void *, qssize_t) Q_DECL_NOTHROW
+ qsizetype fillBuffer(void *, qsizetype) Q_DECL_NOTHROW
{
// always use the fallback
return 0;
@@ -243,7 +243,7 @@ struct QRandomGenerator::SystemGenerator
#if defined(Q_OS_WIN)
static void fallback_update_seed(unsigned) {}
-static void fallback_fill(quint32 *ptr, qssize_t left) Q_DECL_NOTHROW
+static void fallback_fill(quint32 *ptr, qsizetype left) Q_DECL_NOTHROW
{
// on Windows, rand_s is a high-quality random number generator
// and it requires no seeding
@@ -255,14 +255,14 @@ static void fallback_fill(quint32 *ptr, qssize_t left) Q_DECL_NOTHROW
}
#elif QT_CONFIG(getentropy)
static void fallback_update_seed(unsigned) {}
-static void fallback_fill(quint32 *, qssize_t) Q_DECL_NOTHROW
+static void fallback_fill(quint32 *, qsizetype) Q_DECL_NOTHROW
{
// no fallback necessary, getentropy cannot fail under normal circumstances
Q_UNREACHABLE();
}
#elif defined(Q_OS_BSD4)
static void fallback_update_seed(unsigned) {}
-static void fallback_fill(quint32 *ptr, qssize_t left) Q_DECL_NOTHROW
+static void fallback_fill(quint32 *ptr, qsizetype left) Q_DECL_NOTHROW
{
// BSDs have arc4random(4) and these work even in chroot(2)
arc4random_buf(ptr, left * sizeof(*ptr));
@@ -281,7 +281,7 @@ Q_NEVER_INLINE
#ifdef Q_CC_GNU
__attribute__((cold)) // this function is pretty big, so optimize for size
#endif
-static void fallback_fill(quint32 *ptr, qssize_t left) Q_DECL_NOTHROW
+static void fallback_fill(quint32 *ptr, qsizetype left) Q_DECL_NOTHROW
{
quint32 scratch[12]; // see element count below
quint32 *end = scratch;
@@ -358,7 +358,7 @@ Q_NEVER_INLINE void QRandomGenerator::SystemGenerator::generate(quint32 *begin,
Q_DECL_NOEXCEPT_EXPR(FillBufferNoexcept)
{
quint32 *buffer = begin;
- qssize_t count = end - begin;
+ qsizetype count = end - begin;
if (Q_UNLIKELY(uint(qt_randomdevice_control) & SetRandomData)) {
uint value = uint(qt_randomdevice_control) & RandomDataMask;
@@ -366,14 +366,14 @@ Q_NEVER_INLINE void QRandomGenerator::SystemGenerator::generate(quint32 *begin,
return;
}
- qssize_t filled = 0;
+ qsizetype filled = 0;
if (qt_has_hwrng() && (uint(qt_randomdevice_control) & SkipHWRNG) == 0)
filled += qt_random_cpu(buffer, count);
if (filled != count && (uint(qt_randomdevice_control) & SkipSystemRNG) == 0) {
- qssize_t bytesFilled =
- fillBuffer(buffer + filled, (count - filled) * qssize_t(sizeof(*buffer)));
- filled += bytesFilled / qssize_t(sizeof(*buffer));
+ qsizetype bytesFilled =
+ fillBuffer(buffer + filled, (count - filled) * qsizetype(sizeof(*buffer)));
+ filled += bytesFilled / qsizetype(sizeof(*buffer));
}
if (filled)
fallback_update_seed(*buffer);
@@ -656,6 +656,11 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel
*/
/*!
+ \enum QRandomGenerator::System
+ \internal
+*/
+
+/*!
\fn QRandomGenerator::QRandomGenerator(quint32 seedValue)
Initializes this QRandomGenerator object with the value \a seedValue as
@@ -677,7 +682,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel
*/
/*!
- \fn QRandomGenerator::QRandomGenerator(const quint32 *seedBuffer, qssize_t len)
+ \fn QRandomGenerator::QRandomGenerator(const quint32 *seedBuffer, qsizetype len)
\overload
Initializes this QRandomGenerator object with \a len values found in
@@ -694,7 +699,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel
*/
/*!
- \fn QRandomGenerator::QRandomGenerator(const quint32 *begin, const quin32 *end)
+ \fn QRandomGenerator::QRandomGenerator(const quint32 *begin, const quint32 *end)
\overload
Initializes this QRandomGenerator object with the values found in the range
@@ -762,7 +767,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel
A typedef to the type that operator()() returns. That is, quint32.
- \sa operator()()
+ \sa {QRandomGenerator::operator()}{operator()()}
*/
/*!
@@ -774,6 +779,22 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel
*/
/*!
+ \fn quint32 QRandomGenerator::generate()
+
+ Generates a 32-bit random quantity and returns it.
+
+ \sa {QRandomGenerator::operator()}{operator()()}, generate64()
+ */
+
+/*!
+ \fn quint64 QRandomGenerator::generate64()
+
+ Generates a 64-bit random quantity and returns it.
+
+ \sa {QRandomGenerator::operator()}{operator()()}, generate()
+ */
+
+/*!
\fn result_type QRandomGenerator::min()
Returns the minimum value that QRandomGenerator may ever generate. That is, 0.
@@ -800,7 +821,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel
\fn void QRandomGenerator::seed(std::seed_seq &seed)
\overload
- Reseeds this object using the seed sequence \a sseq as the seed.
+ Reseeds this object using the seed sequence \a seed as the seed.
*/
/*!
@@ -826,7 +847,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel
\endcode
This function complies with the requirements for the function
- \c{\l{http://en.cppreference.com/w/cpp/numeric/random/seed_seq/generate}{std::seed_seq::generate}},
+ \l{http://en.cppreference.com/w/cpp/numeric/random/seed_seq/generate}{\c std::seed_seq::generate},
which requires unsigned 32-bit integer values.
Note that if the [begin, end) range refers to an area that can store more
@@ -853,7 +874,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel
*/
/*!
- \fn void QRandomGenerator::fillRange(UInt *buffer, qssize_t count)
+ \fn void QRandomGenerator::fillRange(UInt *buffer, qsizetype count)
Generates \a count 32- or 64-bit quantities (depending on the type \c UInt)
and stores them in the buffer pointed by \a buffer. This is the most
@@ -906,16 +927,16 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel
\endcode
The same may also be obtained by using
- \c{\l{http://en.cppreference.com/w/cpp/numeric/random/uniform_real_distribution}{std::uniform_real_distribution}}
+ \l{http://en.cppreference.com/w/cpp/numeric/random/uniform_real_distribution}{\c std::uniform_real_distribution}
with parameters 0 and 1.
\sa generate(), generate64(), bounded()
*/
/*!
- \fn qreal QRandomGenerator::bounded(qreal highest)
+ \fn double QRandomGenerator::bounded(double highest)
- Generates one random qreal in the range between 0 (inclusive) and \a
+ Generates one random double in the range between 0 (inclusive) and \a
highest (exclusive). This function is equivalent to and is implemented as:
\code
@@ -931,7 +952,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel
Generates one random 32-bit quantity in the range between 0 (inclusive) and
\a highest (exclusive). The same result may also be obtained by using
- \c{\l{http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution}{std::uniform_int_distribution}}
+ \l{http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution}{\c std::uniform_int_distribution}
with parameters 0 and \c{highest - 1}. That class can also be used to obtain
quantities larger than 32 bits.
@@ -969,7 +990,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel
Generates one random 32-bit quantity in the range between \a lowest (inclusive)
and \a highest (exclusive). The same result may also be obtained by using
- \c{\l{http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution}{std::uniform_int_distribution}}
+ \l{http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution}{\c std::uniform_int_distribution}
with parameters \a lowest and \c{\a highest - 1}. That class can also be used to
obtain quantities larger than 32 bits.
@@ -1098,7 +1119,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel
A typedef to the type that operator()() returns. That is, quint64.
- \sa operator()()
+ \sa {QRandomGenerator64::operator()}{operator()()}
*/
/*!
@@ -1169,7 +1190,9 @@ QRandomGenerator64 QRandomGenerator64::securelySeeded()
return result;
}
-/// \internal
+/*!
+ \internal
+*/
inline QRandomGenerator::QRandomGenerator(System)
: type(SystemRNG)
{
diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h
index bde64646a4..46d3e0e152 100644
--- a/src/corelib/global/qrandom.h
+++ b/src/corelib/global/qrandom.h
@@ -44,6 +44,13 @@
#include <algorithm> // for std::generate
#include <random> // for std::mt19937
+#ifdef min
+# undef min
+#endif
+#ifdef max
+# undef max
+#endif
+
QT_BEGIN_NAMESPACE
class QRandomGenerator
@@ -55,10 +62,10 @@ public:
QRandomGenerator(quint32 seedValue = 1)
: QRandomGenerator(&seedValue, 1)
{}
- template <qssize_t N> QRandomGenerator(const quint32 (&seedBuffer)[N])
+ template <qsizetype N> QRandomGenerator(const quint32 (&seedBuffer)[N])
: QRandomGenerator(seedBuffer, seedBuffer + N)
{}
- QRandomGenerator(const quint32 *seedBuffer, qssize_t len)
+ QRandomGenerator(const quint32 *seedBuffer, qsizetype len)
: QRandomGenerator(seedBuffer, seedBuffer + len)
{}
Q_CORE_EXPORT QRandomGenerator(std::seed_seq &sseq) Q_DECL_NOTHROW;
@@ -131,7 +138,7 @@ public:
}
template <typename UInt, IfValidUInt<UInt> = true>
- void fillRange(UInt *buffer, qssize_t count)
+ void fillRange(UInt *buffer, qsizetype count)
{
_fillRange(buffer, buffer + count);
}
@@ -160,8 +167,8 @@ public:
void seed(quint32 s = 1) { *this = { s }; }
void seed(std::seed_seq &sseq) Q_DECL_NOTHROW { *this = { sseq }; }
Q_CORE_EXPORT void discard(unsigned long long z);
- static Q_DECL_CONSTEXPR result_type min() { return (std::numeric_limits<result_type>::min)(); }
- static Q_DECL_CONSTEXPR result_type max() { return (std::numeric_limits<result_type>::max)(); }
+ static Q_DECL_CONSTEXPR result_type min() { return std::numeric_limits<result_type>::min(); }
+ static Q_DECL_CONSTEXPR result_type max() { return std::numeric_limits<result_type>::max(); }
static inline Q_DECL_CONST_FUNCTION QRandomGenerator *system();
static inline Q_DECL_CONST_FUNCTION QRandomGenerator *global();
@@ -177,7 +184,8 @@ private:
friend class QRandomGenerator64;
struct SystemGenerator;
struct SystemAndGlobalGenerators;
- typedef std::mt19937 RandomEngine;
+ using RandomEngine = std::mersenne_twister_engine<quint32,
+ 32,624,397,31,0x9908b0df,11,0xffffffff,7,0x9d2c5680,15,0xefc60000,18,1812433253>;
union Storage {
uint dummy;
@@ -214,10 +222,10 @@ public:
QRandomGenerator64(quint32 seedValue = 1)
: QRandomGenerator(seedValue)
{}
- template <qssize_t N> QRandomGenerator64(const quint32 (&seedBuffer)[N])
+ template <qsizetype N> QRandomGenerator64(const quint32 (&seedBuffer)[N])
: QRandomGenerator(seedBuffer)
{}
- QRandomGenerator64(const quint32 *seedBuffer, qssize_t len)
+ QRandomGenerator64(const quint32 *seedBuffer, qsizetype len)
: QRandomGenerator(seedBuffer, len)
{}
QRandomGenerator64(std::seed_seq &sseq) Q_DECL_NOTHROW
@@ -235,8 +243,8 @@ public:
QRandomGenerator::discard(z * 2);
}
- static Q_DECL_CONSTEXPR result_type min() { return (std::numeric_limits<result_type>::min)(); }
- static Q_DECL_CONSTEXPR result_type max() { return (std::numeric_limits<result_type>::max)(); }
+ static Q_DECL_CONSTEXPR result_type min() { return std::numeric_limits<result_type>::min(); }
+ static Q_DECL_CONSTEXPR result_type max() { return std::numeric_limits<result_type>::max(); }
static Q_DECL_CONST_FUNCTION Q_CORE_EXPORT QRandomGenerator64 *system();
static Q_DECL_CONST_FUNCTION Q_CORE_EXPORT QRandomGenerator64 *global();
static Q_CORE_EXPORT QRandomGenerator64 securelySeeded();
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index bac995ff25..e4888e9523 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -503,7 +503,8 @@ bool
QFile::remove()
{
Q_D(QFile);
- if (d->fileName.isEmpty()) {
+ if (d->fileName.isEmpty() &&
+ !static_cast<QFSFileEngine *>(d->engine())->isUnnamedFile()) {
qWarning("QFile::remove: Empty or null file name");
return false;
}
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index d77cdc123c..b974af80dc 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -55,6 +55,13 @@
#include <stdio.h>
#include <errno.h>
+#if QT_HAS_INCLUDE(<paths.h>)
+# include <paths.h>
+#endif
+#ifndef _PATH_TMP // from <paths.h>
+# define _PATH_TMP "/tmp"
+#endif
+
#if defined(Q_OS_MAC)
# include <QtCore/private/qcore_mac_p.h>
# include <CoreFoundation/CFBundle.h>
@@ -102,8 +109,22 @@ static int statx(int dirfd, const char *pathname, int flag, unsigned mask, struc
# endif
#endif
+#ifndef STATX_BASIC_STATS
+struct statx { mode_t stx_mode; };
+#endif
+
QT_BEGIN_NAMESPACE
+enum {
+#ifdef Q_OS_ANDROID
+ // On Android, the link(2) system call has been observed to always fail
+ // with EACCES, regardless of whether there are permission problems or not.
+ SupportsHardlinking = false
+#else
+ SupportsHardlinking = true
+#endif
+};
+
#define emptyFileEntryWarning() emptyFileEntryWarning_(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC)
static void emptyFileEntryWarning_(const char *file, int line, const char *function)
{
@@ -202,6 +223,8 @@ static inline typename QtPrivate::QEnableIf<(&T::st_atimespec, &T::st_mtimespec,
modification->tv_usec = p->st_mtimespec.tv_nsec / 1000;
}
+# ifndef st_atimensec
+// if "st_atimensec" is defined, this would expand to invalid C++
template <typename T>
static inline typename QtPrivate::QEnableIf<(&T::st_atimensec, &T::st_mtimensec, true)>::Type get(const T *p, struct timeval *access, struct timeval *modification)
{
@@ -211,6 +234,7 @@ static inline typename QtPrivate::QEnableIf<(&T::st_atimensec, &T::st_mtimensec,
modification->tv_sec = p->st_mtime;
modification->tv_usec = p->st_mtimensec / 1000;
}
+# endif
#endif
qint64 timespecToMSecs(const timespec &spec)
@@ -268,6 +292,7 @@ mtime(const T &statBuffer, int)
{ return timespecToMSecs(statBuffer.st_mtimespec); }
#endif
+#ifndef st_mtimensec
// Xtimensec
template <typename T>
Q_DECL_UNUSED static typename std::enable_if<(&T::st_atimensec, true), qint64>::type
@@ -288,8 +313,9 @@ template <typename T>
Q_DECL_UNUSED static typename std::enable_if<(&T::st_mtimensec, true), qint64>::type
mtime(const T &statBuffer, int)
{ return statBuffer.st_mtime * Q_INT64_C(1000) + statBuffer.st_mtimensec / 1000000; }
-}
-}
+#endif
+} // namespace GetFileTimes
+} // unnamed namespace
#ifdef STATX_BASIC_STATS
static int qt_real_statx(int fd, const char *pathname, int flags, struct statx *statxBuffer)
@@ -385,7 +411,6 @@ inline void QFileSystemMetaData::fillFromStatxBuf(const struct statx &statxBuffe
groupId_ = statxBuffer.stx_gid;
}
#else
-struct statx { mode_t stx_mode; };
static int qt_statx(const char *, struct statx *)
{ return -ENOSYS; }
@@ -918,7 +943,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
data.entryFlags &= ~what;
const QByteArray nativeFilePath = entry.nativeFilePath();
- bool entryExists = true; // innocent until proven otherwise
+ int entryErrno = 0; // innocent until proven otherwise
// first, we may try lstat(2). Possible outcomes:
// - success and is a symlink: filesystem entry exists, but we need stat(2)
@@ -968,7 +993,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
}
} else {
// it doesn't exist
- entryExists = false;
+ entryErrno = errno;
data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute;
}
@@ -976,8 +1001,8 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
}
// second, we try a regular stat(2)
- if (statResult != 0 && (what & QFileSystemMetaData::PosixStatFlags)) {
- if (entryExists && statResult == -1) {
+ if (statResult == -1 && (what & QFileSystemMetaData::PosixStatFlags)) {
+ if (entryErrno == 0 && statResult == -1) {
data.entryFlags &= ~QFileSystemMetaData::PosixStatFlags;
statResult = qt_statx(nativeFilePath, &statxBuffer);
if (statResult == -ENOSYS) {
@@ -991,7 +1016,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
}
if (statResult != 0) {
- entryExists = false;
+ entryErrno = errno;
data.birthTime_ = 0;
data.metadataChangeTime_ = 0;
data.modificationTime_ = 0;
@@ -1010,13 +1035,13 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
if (what & (QFileSystemMetaData::UserPermissions | QFileSystemMetaData::ExistsAttribute)) {
// calculate user permissions
auto checkAccess = [&](QFileSystemMetaData::MetaDataFlag flag, int mode) {
- if (!entryExists || (what & flag) == 0)
+ if (entryErrno != 0 || (what & flag) == 0)
return;
if (QT_ACCESS(nativeFilePath, mode) == 0) {
// access ok (and file exists)
data.entryFlags |= flag | QFileSystemMetaData::ExistsAttribute;
} else if (errno != EACCES && errno != EROFS) {
- entryExists = false;
+ entryErrno = errno;
}
};
@@ -1025,9 +1050,10 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
checkAccess(QFileSystemMetaData::UserExecutePermission, X_OK);
// if we still haven't found out if the file exists, try F_OK
- if (entryExists && (data.entryFlags & QFileSystemMetaData::ExistsAttribute) == 0) {
- entryExists = QT_ACCESS(nativeFilePath, F_OK) == 0;
- if (entryExists)
+ if (entryErrno == 0 && (data.entryFlags & QFileSystemMetaData::ExistsAttribute) == 0) {
+ if (QT_ACCESS(nativeFilePath, F_OK) == -1)
+ entryErrno = errno;
+ else
data.entryFlags |= QFileSystemMetaData::ExistsAttribute;
}
@@ -1037,13 +1063,13 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
#if defined(Q_OS_DARWIN)
if (what & QFileSystemMetaData::AliasType) {
- if (entryExists && hasResourcePropertyFlag(data, entry, kCFURLIsAliasFileKey))
+ if (entryErrno == 0 && hasResourcePropertyFlag(data, entry, kCFURLIsAliasFileKey))
data.entryFlags |= QFileSystemMetaData::AliasType;
data.knownFlagsMask |= QFileSystemMetaData::AliasType;
}
if (what & QFileSystemMetaData::BundleType) {
- if (entryExists && isPackage(data, entry))
+ if (entryErrno == 0 && isPackage(data, entry))
data.entryFlags |= QFileSystemMetaData::BundleType;
data.knownFlagsMask |= QFileSystemMetaData::BundleType;
@@ -1055,19 +1081,19 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
QString fileName = entry.fileName();
if ((fileName.size() > 0 && fileName.at(0) == QLatin1Char('.'))
#if defined(Q_OS_DARWIN)
- || (entryExists && hasResourcePropertyFlag(data, entry, kCFURLIsHiddenKey))
+ || (entryErrno == 0 && hasResourcePropertyFlag(data, entry, kCFURLIsHiddenKey))
#endif
)
data.entryFlags |= QFileSystemMetaData::HiddenAttribute;
data.knownFlagsMask |= QFileSystemMetaData::HiddenAttribute;
}
- if (!entryExists) {
+ if (entryErrno != 0) {
what &= ~QFileSystemMetaData::LinkType; // don't clear link: could be broken symlink
data.clearFlags(what);
return false;
}
- return data.hasFlags(what);
+ return true;
}
// static
@@ -1278,7 +1304,7 @@ bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSy
}
#endif
- if (::link(srcPath, tgtPath) == 0) {
+ if (SupportsHardlinking && ::link(srcPath, tgtPath) == 0) {
if (::unlink(srcPath) == 0)
return true;
@@ -1292,6 +1318,11 @@ bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSy
error = QSystemError(savedErrno, QSystemError::StandardLibraryError);
return false;
+ } else if (!SupportsHardlinking) {
+ // man 2 link on Linux has:
+ // EPERM The filesystem containing oldpath and newpath does not
+ // support the creation of hard links.
+ errno = EPERM;
}
switch (errno) {
@@ -1483,14 +1514,13 @@ QString QFileSystemEngine::tempPath()
#else
QString temp = QFile::decodeName(qgetenv("TMPDIR"));
if (temp.isEmpty()) {
+ if (false) {
#if defined(Q_OS_DARWIN) && !defined(QT_BOOTSTRAPPED)
- if (NSString *nsPath = NSTemporaryDirectory()) {
+ } else if (NSString *nsPath = NSTemporaryDirectory()) {
temp = QString::fromCFString((CFStringRef)nsPath);
- } else {
-#else
- {
#endif
- temp = QLatin1String("/tmp");
+ } else {
+ temp = QLatin1String(_PATH_TMP);
}
}
return QDir::cleanPath(temp);
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 944ca232ee..fadc058110 100644..100755
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -160,6 +160,7 @@ static TRUSTEE_W currentUserTrusteeW;
static TRUSTEE_W worldTrusteeW;
static PSID currentUserSID = 0;
static PSID worldSID = 0;
+static HANDLE currentUserImpersonatedToken = nullptr;
QT_BEGIN_NAMESPACE
@@ -180,6 +181,11 @@ GlobalSid::~GlobalSid()
::FreeSid(worldSID);
worldSID = 0;
}
+
+ if (currentUserImpersonatedToken) {
+ ::CloseHandle(currentUserImpersonatedToken);
+ currentUserImpersonatedToken = nullptr;
+ }
}
GlobalSid::GlobalSid()
@@ -210,6 +216,12 @@ GlobalSid::GlobalSid()
::CloseHandle(token);
}
+ token = nullptr;
+ if (::OpenProcessToken(hnd, TOKEN_IMPERSONATE | TOKEN_QUERY | TOKEN_DUPLICATE | STANDARD_RIGHTS_READ, &token)) {
+ ::DuplicateToken(token, SecurityImpersonation, &currentUserImpersonatedToken);
+ ::CloseHandle(token);
+ }
+
{
// Create TRUSTEE for Everyone (World)
SID_IDENTIFIER_AUTHORITY worldAuth = { SECURITY_WORLD_SID_AUTHORITY };
@@ -724,15 +736,49 @@ bool QFileSystemEngine::fillPermissions(const QFileSystemEntry &entry, QFileSyst
ACCESS_MASK access_mask;
TRUSTEE_W trustee;
if (what & QFileSystemMetaData::UserPermissions) { // user
- data.knownFlagsMask |= QFileSystemMetaData::UserPermissions;
- if (GetEffectiveRightsFromAcl(pDacl, &currentUserTrusteeW, &access_mask) != ERROR_SUCCESS)
- access_mask = (ACCESS_MASK)-1;
- if(access_mask & ReadMask)
- data.entryFlags |= QFileSystemMetaData::UserReadPermission;
- if(access_mask & WriteMask)
- data.entryFlags|= QFileSystemMetaData::UserWritePermission;
- if(access_mask & ExecMask)
- data.entryFlags|= QFileSystemMetaData::UserExecutePermission;
+ // Using AccessCheck because GetEffectiveRightsFromAcl doesn't account for elevation
+ if (currentUserImpersonatedToken) {
+ GENERIC_MAPPING mapping = {FILE_GENERIC_READ, FILE_GENERIC_WRITE, FILE_GENERIC_EXECUTE, FILE_ALL_ACCESS};
+ PRIVILEGE_SET privileges;
+ DWORD grantedAccess;
+ BOOL result;
+
+ data.knownFlagsMask |= QFileSystemMetaData::UserPermissions;
+ DWORD genericAccessRights = GENERIC_READ;
+ ::MapGenericMask(&genericAccessRights, &mapping);
+
+ DWORD privilegesLength = sizeof(privileges);
+ if (::AccessCheck(pSD, currentUserImpersonatedToken, genericAccessRights,
+ &mapping, &privileges, &privilegesLength, &grantedAccess, &result) && result) {
+ data.entryFlags |= QFileSystemMetaData::UserReadPermission;
+ }
+
+ privilegesLength = sizeof(privileges);
+ genericAccessRights = GENERIC_WRITE;
+ ::MapGenericMask(&genericAccessRights, &mapping);
+ if (::AccessCheck(pSD, currentUserImpersonatedToken, genericAccessRights,
+ &mapping, &privileges, &privilegesLength, &grantedAccess, &result) && result) {
+ data.entryFlags |= QFileSystemMetaData::UserWritePermission;
+ }
+
+ privilegesLength = sizeof(privileges);
+ genericAccessRights = GENERIC_EXECUTE;
+ ::MapGenericMask(&genericAccessRights, &mapping);
+ if (::AccessCheck(pSD, currentUserImpersonatedToken, genericAccessRights,
+ &mapping, &privileges, &privilegesLength, &grantedAccess, &result) && result) {
+ data.entryFlags |= QFileSystemMetaData::UserExecutePermission;
+ }
+ } else { // fallback to GetEffectiveRightsFromAcl
+ data.knownFlagsMask |= QFileSystemMetaData::UserPermissions;
+ if (GetEffectiveRightsFromAclW(pDacl, &currentUserTrusteeW, &access_mask) != ERROR_SUCCESS)
+ access_mask = ACCESS_MASK(-1);
+ if (access_mask & ReadMask)
+ data.entryFlags |= QFileSystemMetaData::UserReadPermission;
+ if (access_mask & WriteMask)
+ data.entryFlags|= QFileSystemMetaData::UserWritePermission;
+ if (access_mask & ExecMask)
+ data.entryFlags|= QFileSystemMetaData::UserExecutePermission;
+ }
}
if (what & QFileSystemMetaData::OwnerPermissions) { // owner
data.knownFlagsMask |= QFileSystemMetaData::OwnerPermissions;
diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h
index 55e44d52c7..4d2a5acb9b 100644
--- a/src/corelib/io/qfilesystemmetadata_p.h
+++ b/src/corelib/io/qfilesystemmetadata_p.h
@@ -64,6 +64,10 @@
# endif
#endif
+#ifdef Q_OS_UNIX
+struct statx;
+#endif
+
QT_BEGIN_NAMESPACE
class QFileSystemEngine;
diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h
index bf90995fdd..16ba161b75 100644
--- a/src/corelib/io/qfsfileengine_p.h
+++ b/src/corelib/io/qfsfileengine_p.h
@@ -112,6 +112,9 @@ public:
qint64 write(const char *data, qint64 len) override;
bool cloneTo(QAbstractFileEngine *target) override;
+ virtual bool isUnnamedFile() const
+ { return false; }
+
bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0) override;
bool supportsExtension(Extension extension) const override;
diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp
index 1bf61017f6..b5f8e30b80 100644
--- a/src/corelib/io/qloggingregistry.cpp
+++ b/src/corelib/io/qloggingregistry.cpp
@@ -255,7 +255,7 @@ void QLoggingSettingsParser::parseNextLine(QStringRef line)
QLoggingRegistry::QLoggingRegistry()
: categoryFilter(defaultCategoryFilter)
{
- initalizeRules(); // Init on first use
+ initializeRules(); // Init on first use
}
static bool qtLoggingDebug()
@@ -284,7 +284,7 @@ static QVector<QLoggingRule> loadRulesFromFile(const QString &filePath)
Initializes the rules database by loading
$QT_LOGGING_CONF, $QT_LOGGING_RULES, and .config/QtProject/qtlogging.ini.
*/
-void QLoggingRegistry::initalizeRules()
+void QLoggingRegistry::initializeRules()
{
QVector<QLoggingRule> er, qr, cr;
// get rules from environment
diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h
index a3857d3588..12a1f166b3 100644
--- a/src/corelib/io/qloggingregistry_p.h
+++ b/src/corelib/io/qloggingregistry_p.h
@@ -113,7 +113,7 @@ class Q_AUTOTEST_EXPORT QLoggingRegistry
public:
QLoggingRegistry();
- void initalizeRules();
+ void initializeRules();
void registerCategory(QLoggingCategory *category, QtMsgType enableForLevel);
void unregisterCategory(QLoggingCategory *category);
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 41f4b2aa83..2ee680a7c6 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -99,6 +99,10 @@ QT_END_NAMESPACE
#include <private/qcore_unix_p.h>
#endif
+#if QT_HAS_INCLUDE(<paths.h>)
+#include <paths.h>
+#endif
+
QT_BEGIN_NAMESPACE
/*!
@@ -2637,6 +2641,8 @@ QString QProcess::nullDevice()
{
#ifdef Q_OS_WIN
return QStringLiteral("\\\\.\\NUL");
+#elif defined(_PATH_DEVNULL)
+ return QStringLiteral(_PATH_DEVNULL);
#else
return QStringLiteral("/dev/null");
#endif
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index 9a63374e6f..35a0de4fb7 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -86,8 +86,8 @@ public:
}
const QChar *m_data;
- qssize_t m_len;
- qssize_t m_pos = 0;
+ qsizetype m_len;
+ qsizetype m_pos = 0;
QChar m_splitChar = QLatin1Char('/');
};
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index d0cbc82c56..bbc66120b5 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -1451,7 +1451,7 @@ void QConfFileSettingsPrivate::syncConfFile(QConfFile *confFile)
Files that we can't read (because of permissions or
because they don't exist) are treated as empty files.
*/
- if (file.isReadable() && fileInfo.size() != 0) {
+ if (file.isReadable() && file.size() != 0) {
bool ok = false;
#ifdef Q_OS_MAC
if (format == QSettings::NativeFormat) {
diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp
index c3d45caf0e..b3a5bd797a 100644
--- a/src/corelib/io/qstandardpaths.cpp
+++ b/src/corelib/io/qstandardpaths.cpp
@@ -48,6 +48,14 @@
#include <qcoreapplication.h>
#endif
+#if QT_HAS_INCLUDE(<paths.h>)
+#include <paths.h>
+#endif
+
+#ifdef Q_OS_UNIX
+#include <unistd.h>
+#endif
+
#ifndef QT_NO_STANDARDPATHS
QT_BEGIN_NAMESPACE
@@ -509,6 +517,27 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr
QStringList searchPaths = paths;
if (paths.isEmpty()) {
QByteArray pEnv = qgetenv("PATH");
+ if (Q_UNLIKELY(pEnv.isNull())) {
+ // Get a default path. POSIX.1 does not actually require this, but
+ // most Unix libc fall back to confstr(_CS_PATH) if the PATH
+ // environment variable isn't set. Let's try to do the same.
+#if defined(_PATH_DEFPATH)
+ // BSD API.
+ pEnv = _PATH_DEFPATH;
+#elif defined(_CS_PATH)
+ // POSIX API.
+ size_t n = confstr(_CS_PATH, nullptr, 0);
+ if (n) {
+ pEnv.resize(n);
+ // size()+1 is ok because QByteArray always has an extra NUL-terminator
+ confstr(_CS_PATH, pEnv.data(), pEnv.size() + 1);
+ }
+#else
+ // Windows SDK's execvpe() does not have a fallback, so we won't
+ // apply one either.
+#endif
+ }
+
// Remove trailing slashes, which occur on Windows.
const QStringList rawPaths = QString::fromLocal8Bit(pEnv.constData()).split(QDir::listSeparator(), QString::SkipEmptyParts);
searchPaths.reserve(rawPaths.size());
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp
index 6d8b6ee1a0..7664b77d81 100644
--- a/src/corelib/io/qstorageinfo_unix.cpp
+++ b/src/corelib/io/qstorageinfo_unix.cpp
@@ -108,6 +108,13 @@
# endif // QT_LARGEFILE_SUPPORT
#endif // Q_OS_BSD4
+#if QT_HAS_INCLUDE(<paths.h>)
+# include <paths.h>
+#endif
+#ifndef _PATH_MOUNTED
+# define _PATH_MOUNTED "/etc/mnttab"
+#endif
+
QT_BEGIN_NAMESPACE
class QStorageIterator
@@ -274,11 +281,9 @@ inline QByteArray QStorageIterator::subvolume() const
}
#elif defined(Q_OS_SOLARIS)
-static const char pathMounted[] = "/etc/mnttab";
-
inline QStorageIterator::QStorageIterator()
{
- const int fd = qt_safe_open(pathMounted, O_RDONLY);
+ const int fd = qt_safe_open(_PATH_MOUNTED, O_RDONLY);
fp = ::fdopen(fd, "r");
}
@@ -319,11 +324,9 @@ inline QByteArray QStorageIterator::subvolume() const
}
#elif defined(Q_OS_ANDROID)
-static const QLatin1String pathMounted("/proc/mounts");
-
inline QStorageIterator::QStorageIterator()
{
- file.setFileName(pathMounted);
+ file.setFileName(_PATH_MOUNTED);
file.open(QIODevice::ReadOnly | QIODevice::Text);
}
@@ -380,7 +383,6 @@ inline QByteArray QStorageIterator::subvolume() const
}
#elif defined(Q_OS_LINUX) || defined(Q_OS_HURD)
-static const char pathMounted[] = "/etc/mtab";
static const int bufferSize = 1024; // 2 paths (mount point+device) and metainfo;
// should be enough
@@ -397,7 +399,7 @@ inline QStorageIterator::QStorageIterator() :
usingMountinfo = true;
} else {
usingMountinfo = false;
- fp = ::setmntent(pathMounted, "r");
+ fp = ::setmntent(_PATH_MOUNTED, "r");
}
}
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index b8d3e859cf..35699d52df 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -393,7 +393,9 @@ bool QTemporaryFileEngine::remove()
// we must explicitly call QFSFileEngine::close() before we remove it.
d->unmapAll();
QFSFileEngine::close();
- if (isUnnamedFile() || QFSFileEngine::remove()) {
+ if (isUnnamedFile())
+ return true;
+ if (!filePathIsTemplate && QFSFileEngine::remove()) {
d->fileEntry.clear();
// If a QTemporaryFile is constructed using a template file path, the path
// is generated in QTemporaryFileEngine::open() and then filePathIsTemplate
@@ -511,7 +513,10 @@ bool QTemporaryFileEngine::materializeUnnamedFile(const QString &newName, QTempo
bool QTemporaryFileEngine::isUnnamedFile() const
{
#ifdef LINUX_UNNAMED_TMPFILE
- Q_ASSERT(unnamedFile == d_func()->fileEntry.isEmpty());
+ if (unnamedFile) {
+ Q_ASSERT(d_func()->fileEntry.isEmpty());
+ Q_ASSERT(filePathIsTemplate);
+ }
return unnamedFile;
#else
return false;
@@ -749,10 +754,21 @@ bool QTemporaryFile::autoRemove() const
}
/*!
- Sets the QTemporaryFile into auto-remove mode if \a b is true.
+ Sets the QTemporaryFile into auto-remove mode if \a b is \c true.
Auto-remove is on by default.
+ If you set this property to \c false, ensure the application provides a way
+ to remove the file once it is no longer needed, including passing the
+ responsibility on to another process. Always use the fileName() function to
+ obtain the name and never try to guess the name that QTemporaryFile has
+ generated.
+
+ On some systems, if fileName() is not called before closing the file, the
+ temporary file may be removed regardless of the state of this property.
+ This behavior should not be relied upon, so application code should either
+ call fileName() or leave the auto removal functionality enabled.
+
\sa autoRemove(), remove()
*/
void QTemporaryFile::setAutoRemove(bool b)
diff --git a/src/corelib/io/qtemporaryfile_p.h b/src/corelib/io/qtemporaryfile_p.h
index 46a0d7aba3..fb8887af53 100644
--- a/src/corelib/io/qtemporaryfile_p.h
+++ b/src/corelib/io/qtemporaryfile_p.h
@@ -58,7 +58,7 @@
#include "private/qfile_p.h"
#include "qtemporaryfile.h"
-#ifdef Q_OS_LINUX
+#if defined(Q_OS_LINUX) && QT_CONFIG(linkat)
# include <fcntl.h>
# ifdef O_TMPFILE
// some early libc support had the wrong values for O_TMPFILE
@@ -74,8 +74,8 @@ QT_BEGIN_NAMESPACE
struct QTemporaryFileName
{
QFileSystemEntry::NativePath path;
- qssize_t pos;
- qssize_t length;
+ qsizetype pos;
+ qsizetype length;
QTemporaryFileName(const QString &templateName);
QFileSystemEntry::NativePath generateNext();
@@ -140,7 +140,7 @@ public:
enum MaterializationMode { Overwrite, DontOverwrite, NameIsTemplate };
bool materializeUnnamedFile(const QString &newName, MaterializationMode mode);
- bool isUnnamedFile() const;
+ bool isUnnamedFile() const override final;
const QString &templateName;
quint32 fileMode;
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index cf7ed130ba..4587b9fcd6 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -90,11 +90,6 @@
fromPercentEncoding() and toPercentEncoding() which deal with
percent encoding and decoding of QString objects.
- Calling isRelative() will tell whether or not the URL is
- relative. A relative URL can be resolved by passing it as argument
- to resolved(), which returns an absolute URL. isParentOf() is used
- for determining whether one URL is a parent of another.
-
fromLocalFile() constructs a QUrl by parsing a local
file path. toLocalFile() converts a URL to a local file path.
@@ -116,6 +111,37 @@
from freedesktop.org, provided that the locale encodes file names using
UTF-8 (required by IDN).
+ \section2 Relative URLs vs Relative Paths
+
+ Calling isRelative() will return whether or not the URL is relative.
+ A relative URL has no \l {scheme}. For example:
+
+ \code
+ qDebug() << QUrl("main.qml").isRelative(); // true: no scheme
+ qDebug() << QUrl("qml/main.qml").isRelative(); // true: no scheme
+ qDebug() << QUrl("file:main.qml").isRelative(); // false: has "file" scheme
+ qDebug() << QUrl("file:qml/main.qml").isRelative(); // false: has "file" scheme
+ \endcode
+
+ Notice that a URL can be absolute while containing a relative path, and
+ vice versa:
+
+ \code
+ // Absolute URL, relative path
+ QUrl url("file:file.txt");
+ qDebug() << url.isRelative(); // false: has "file" scheme
+ qDebug() << QDir::isAbsolutePath(url.path()); // false: relative path
+
+ // Relative URL, absolute path
+ url = QUrl("/home/user/file.txt");
+ qDebug() << url.isRelative(); // true: has no scheme
+ qDebug() << QDir::isAbsolutePath(url.path()); // true: absolute path
+ \endcode
+
+ A relative URL can be resolved by passing it as an argument to resolved(),
+ which returns an absolute URL. isParentOf() is used for determining whether
+ one URL is a parent of another.
+
\section2 Error checking
QUrl is capable of detecting many errors in URLs while parsing it or when
@@ -2539,6 +2565,12 @@ void QUrl::setPath(const QString &path, ParsingMode mode)
/*!
Returns the path of the URL.
+ \code
+ qDebug() << QUrl("file:file.txt").path(); // "file.txt"
+ qDebug() << QUrl("/home/user/file.txt").path(); // "/home/user/file.txt"
+ qDebug() << QUrl("http://www.example.com/test/123").path(); // "/test/123"
+ \endcode
+
The \a options argument controls how to format the path component. All
values produce an unambiguous result. With QUrl::FullyDecoded, all
percent-encoded sequences are decoded; otherwise, the returned value may
@@ -2549,6 +2581,31 @@ void QUrl::setPath(const QString &path, ParsingMode mode)
sequences are present. It is recommended to use that value when the result
will be used in a non-URL context, such as sending to an FTP server.
+ An example of data loss is when you have non-Unicode percent-encoded sequences
+ and use FullyDecoded (the default):
+
+ \code
+ qDebug() << QUrl("/foo%FFbar").path();
+ \endcode
+
+ In this example, there will be some level of data loss because the \c %FF cannot
+ be converted.
+
+ Data loss can also occur when the path contains sub-delimiters (such as \c +):
+
+ \code
+ qDebug() << QUrl("/foo+bar%2B").path(); // "/foo+bar+"
+ \endcode
+
+ Other decoding examples:
+
+ \code
+ const QUrl url("/tmp/Mambo %235%3F.mp3");
+ qDebug() << url.path(QUrl::FullyDecoded); // "/tmp/Mambo #5?.mp3"
+ qDebug() << url.path(QUrl::PrettyDecoded); // "/tmp/Mambo #5?.mp3"
+ qDebug() << url.path(QUrl::FullyEncoded); // "/tmp/Mambo%20%235%3F.mp3"
+ \endcode
+
\sa setPath()
*/
QString QUrl::path(ComponentFormattingOptions options) const
@@ -3257,6 +3314,8 @@ QUrl QUrl::resolved(const QUrl &relative) const
equivalent to calling scheme().isEmpty().
Relative references are defined in RFC 3986 section 4.2.
+
+ \sa {Relative URLs vs Relative Paths}
*/
bool QUrl::isRelative() const
{
@@ -3796,6 +3855,41 @@ bool QUrl::isDetached() const
An empty \a localFile leads to an empty URL (since Qt 5.4).
+ \code
+ qDebug() << QUrl::fromLocalFile("file.txt"); // QUrl("file:file.txt")
+ qDebug() << QUrl::fromLocalFile("/home/user/file.txt"); // QUrl("file:///home/user/file.txt")
+ qDebug() << QUrl::fromLocalFile("file:file.txt"); // doesn't make sense; expects path, not url with scheme
+ \endcode
+
+ In the first line in snippet above, a file URL is constructed from a
+ local, relative path. A file URL with a relative path only makes sense
+ if there is a base URL to resolve it against. For example:
+
+ \code
+ QUrl url = QUrl::fromLocalFile("file.txt");
+ QUrl baseUrl = QUrl("file:/home/user/");
+ // wrong: prints QUrl("file:file.txt"), as url already has a scheme
+ qDebug() << baseUrl.resolved(url);
+ \endcode
+
+ To resolve such a URL, it's necessary to remove the scheme beforehand:
+
+ \code
+ // correct: prints QUrl("file:///home/user/file.txt")
+ url.setScheme(QString());
+ qDebug() << baseUrl.resolved(url);
+ \endcode
+
+ For this reason, it is better to use a relative URL (that is, no scheme)
+ for relative file paths:
+
+ \code
+ QUrl url = QUrl("file.txt");
+ QUrl baseUrl = QUrl("file:/home/user/");
+ // prints QUrl("file:///home/user/file.txt")
+ qDebug() << baseUrl.resolved(url);
+ \endcode
+
\sa toLocalFile(), isLocalFile(), QDir::toNativeSeparators()
*/
QUrl QUrl::fromLocalFile(const QString &localFile)
@@ -3840,6 +3934,12 @@ QUrl QUrl::fromLocalFile(const QString &localFile)
returned value in the form found on SMB networks (for example,
"//servername/path/to/file.txt").
+ \code
+ qDebug() << QUrl("file:file.txt").toLocalFile(); // "file:file.txt"
+ qDebug() << QUrl("file:/home/user/file.txt").toLocalFile(); // "file:///home/user/file.txt"
+ qDebug() << QUrl("file.txt").toLocalFile(); // ""; wasn't a local file as it had no scheme
+ \endcode
+
Note: if the path component of this URL contains a non-UTF-8 binary
sequence (such as %80), the behaviour of this function is undefined.
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
index b4ba1a2823..c70fbaf63b 100644
--- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
@@ -2660,8 +2660,8 @@ void QSortFilterProxyModel::setFilterRole(int role)
}
/*!
- \since 5.9
- \property QSortFilterProxyModel::recursiveFiltering
+ \since 5.10
+ \property QSortFilterProxyModel::recursiveFilteringEnabled
\brief whether the filter to be applied recursively on children, and for
any matching child, its parents will be visible as well.
@@ -2669,13 +2669,13 @@ void QSortFilterProxyModel::setFilterRole(int role)
\sa filterAcceptsRow()
*/
-bool QSortFilterProxyModel::recursiveFiltering() const
+bool QSortFilterProxyModel::isRecursiveFilteringEnabled() const
{
Q_D(const QSortFilterProxyModel);
return d->filter_recursive;
}
-void QSortFilterProxyModel::setRecursiveFiltering(bool recursive)
+void QSortFilterProxyModel::setRecursiveFilteringEnabled(bool recursive)
{
Q_D(QSortFilterProxyModel);
if (d->filter_recursive == recursive)
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.h b/src/corelib/itemmodels/qsortfilterproxymodel.h
index 2f93836544..6c620f4812 100644
--- a/src/corelib/itemmodels/qsortfilterproxymodel.h
+++ b/src/corelib/itemmodels/qsortfilterproxymodel.h
@@ -67,7 +67,7 @@ class Q_CORE_EXPORT QSortFilterProxyModel : public QAbstractProxyModel
Q_PROPERTY(bool isSortLocaleAware READ isSortLocaleAware WRITE setSortLocaleAware)
Q_PROPERTY(int sortRole READ sortRole WRITE setSortRole)
Q_PROPERTY(int filterRole READ filterRole WRITE setFilterRole)
- Q_PROPERTY(bool recursiveFiltering READ recursiveFiltering WRITE setRecursiveFiltering)
+ Q_PROPERTY(bool recursiveFilteringEnabled READ isRecursiveFilteringEnabled WRITE setRecursiveFilteringEnabled)
public:
explicit QSortFilterProxyModel(QObject *parent = nullptr);
@@ -108,8 +108,8 @@ public:
int filterRole() const;
void setFilterRole(int role);
- bool recursiveFiltering() const;
- void setRecursiveFiltering(bool recursive);
+ bool isRecursiveFilteringEnabled() const;
+ void setRecursiveFilteringEnabled(bool recursive);
public Q_SLOTS:
void setFilterRegExp(const QString &pattern);
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index 8abe9b2b44..2336278b17 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -188,7 +188,7 @@ vxworks {
kernel/qfunctions_vxworks.h
}
-qqnx_pps {
+qnx:qtConfig(qqnx_pps) {
QMAKE_USE_PRIVATE += pps
SOURCES += \
kernel/qppsattribute.cpp \
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 0ba841bd30..38bcba275f 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -2202,11 +2202,11 @@ QString QCoreApplication::applicationFilePath()
QCoreApplicationPrivate *d = self->d_func();
if (d->argc) {
- static const char *procName = d->argv[0];
- if (qstrcmp(procName, d->argv[0]) != 0) {
+ static QByteArray procName = QByteArray(d->argv[0]);
+ if (procName != d->argv[0]) {
// clear the cache if the procname changes, so we reprocess it.
QCoreApplicationPrivate::clearApplicationFilePath();
- procName = d->argv[0];
+ procName = QByteArray(d->argv[0]);
}
}
diff --git a/src/corelib/kernel/qjnihelpers.cpp b/src/corelib/kernel/qjnihelpers.cpp
index c7109a6506..04c9a9bcba 100644
--- a/src/corelib/kernel/qjnihelpers.cpp
+++ b/src/corelib/kernel/qjnihelpers.cpp
@@ -592,7 +592,7 @@ void QtAndroidPrivate::setOnBindListener(QtAndroidPrivate::OnBindListener *liste
{
QMutexLocker lock(g_onBindListenerMutex);
*g_onBindListener = listener;
- if (!(*g_serviceSetupLockers)--)
+ if (!g_serviceSetupLockers->deref())
g_waitForServiceSetupSemaphore->release();
}
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 650523d01c..30cae20359 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -4796,7 +4796,7 @@ QMetaObject::Connection QObjectPrivate::connectImpl(const QObject *sender, int s
QtPrivate::QSlotObjectBase *slotObj, Qt::ConnectionType type,
const int *types, const QMetaObject *senderMetaObject)
{
- if (!sender || !slotObj || !senderMetaObject) {
+ if (!sender || !receiver || !slotObj || !senderMetaObject) {
qWarning("QObject::connect: invalid null parameter");
if (slotObj)
slotObj->destroyIfLastRef();
diff --git a/src/corelib/kernel/qppsobjectprivate_p.h b/src/corelib/kernel/qppsobjectprivate_p.h
index e1d54e58de..dae44e3609 100644
--- a/src/corelib/kernel/qppsobjectprivate_p.h
+++ b/src/corelib/kernel/qppsobjectprivate_p.h
@@ -57,13 +57,15 @@
#include <QDebug>
#include <sys/pps.h>
+#include <private/qobject_p.h>
QT_BEGIN_NAMESPACE
class QSocketNotifier;
-class QPpsObjectPrivate
+class QPpsObjectPrivate : public QObjectPrivate
{
+ Q_DECLARE_PUBLIC(QPpsObject)
public:
explicit QPpsObjectPrivate(const QString &path);
diff --git a/src/corelib/plugin/qlibrary_win.cpp b/src/corelib/plugin/qlibrary_win.cpp
index a4d3f67c27..9368e53b3f 100644
--- a/src/corelib/plugin/qlibrary_win.cpp
+++ b/src/corelib/plugin/qlibrary_win.cpp
@@ -116,7 +116,7 @@ bool QLibraryPrivate::load_sys()
#endif
if (!pHnd) {
errorString = QLibrary::tr("Cannot load library %1: %2").arg(
- QDir::toNativeSeparators(fileName)).arg(qt_error_string());
+ QDir::toNativeSeparators(fileName), qt_error_string());
} else {
// Query the actual name of the library that was loaded
errorString.clear();
@@ -152,7 +152,7 @@ bool QLibraryPrivate::unload_sys()
{
if (!FreeLibrary(pHnd)) {
errorString = QLibrary::tr("Cannot unload library %1: %2").arg(
- QDir::toNativeSeparators(fileName)).arg(qt_error_string());
+ QDir::toNativeSeparators(fileName), qt_error_string());
return false;
}
errorString.clear();
@@ -164,8 +164,7 @@ QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol)
FARPROC address = GetProcAddress(pHnd, symbol);
if (!address) {
errorString = QLibrary::tr("Cannot resolve symbol \"%1\" in %2: %3").arg(
- QString::fromLatin1(symbol)).arg(
- QDir::toNativeSeparators(fileName)).arg(qt_error_string());
+ QString::fromLatin1(symbol), QDir::toNativeSeparators(fileName), qt_error_string());
} else {
errorString.clear();
}
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index e58ddaff44..24734f99ac 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -3096,10 +3096,12 @@ int QSignalEventGenerator::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
void QSignalEventGenerator::execute(void **_a)
{
+ auto machinePrivate = QStateMachinePrivate::get(qobject_cast<QStateMachine*>(parent()));
+ if (machinePrivate->state != QStateMachinePrivate::Running)
+ return;
int signalIndex = senderSignalIndex();
Q_ASSERT(signalIndex != -1);
- QStateMachine *machine = qobject_cast<QStateMachine*>(parent());
- QStateMachinePrivate::get(machine)->handleTransitionSignal(sender(), signalIndex, _a);
+ machinePrivate->handleTransitionSignal(sender(), signalIndex, _a);
}
QSignalEventGenerator::QSignalEventGenerator(QStateMachine *parent)
diff --git a/src/corelib/thread/qfuturewatcher.h b/src/corelib/thread/qfuturewatcher.h
index 1d984a3205..fb7dd30499 100644
--- a/src/corelib/thread/qfuturewatcher.h
+++ b/src/corelib/thread/qfuturewatcher.h
@@ -114,7 +114,7 @@ template <typename T>
class QFutureWatcher : public QFutureWatcherBase
{
public:
- explicit QFutureWatcher(QObject *_parent = 0)
+ explicit QFutureWatcher(QObject *_parent = nullptr)
: QFutureWatcherBase(_parent)
{ }
~QFutureWatcher()
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index f6fc672486..050f37dcd2 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -2227,7 +2227,7 @@ static QString qt_tzname(QDateTimePrivate::DaylightStatus daylightStatus)
#endif // Q_OS_WIN
}
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(datetimeparser) && QT_CONFIG(timezone)
/*
\internal
Implemented here to share qt_tzname()
@@ -2245,7 +2245,7 @@ int QDateTimeParser::startsWithLocalTimeZone(const QStringRef name)
}
return 0;
}
-#endif // QT_BOOTSTRAPPED
+#endif // datetimeparser && timezone
// Calls the platform variant of mktime for the given date, time and daylightStatus,
// and updates the date, time, daylightStatus and abbreviation with the returned values
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index a390bce95f..5a7b75db62 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -81,7 +81,7 @@ public:
int daysInYear() const;
int weekNumber(int *yearNum = nullptr) const;
-#if QT_DEPRECATED_SINCE(5, 11) && !defined QT_NO_TEXTDATE
+#if QT_DEPRECATED_SINCE(5, 10) && !defined QT_NO_TEXTDATE
QT_DEPRECATED_X("Use QLocale::monthName or QLocale::standaloneMonthName")
static QString shortMonthName(int month, MonthNameType type = DateFormat);
QT_DEPRECATED_X("Use QLocale::dayName or QLocale::standaloneDayName")
diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp
index f0c8b5a799..551e01e076 100644
--- a/src/corelib/tools/qdatetimeparser.cpp
+++ b/src/corelib/tools/qdatetimeparser.cpp
@@ -195,9 +195,11 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const
return false;
// Preserve zone:
- v = (tspec == Qt::TimeZone
- ? QDateTime(newDate, newTime, v.timeZone())
- : QDateTime(newDate, newTime, tspec, offset));
+ v =
+#if QT_CONFIG(timezone)
+ tspec == Qt::TimeZone ? QDateTime(newDate, newTime, v.timeZone()) :
+#endif
+ QDateTime(newDate, newTime, tspec, offset);
return true;
}
@@ -213,7 +215,9 @@ int QDateTimeParser::absoluteMax(int s, const QDateTime &cur) const
{
const SectionNode &sn = sectionNode(s);
switch (sn.type) {
+#if QT_CONFIG(timezone)
case TimeZoneSection: return QTimeZone::MaxUtcOffsetSecs;
+#endif
case Hour24Section:
case Hour12Section: return 23; // this is special-cased in
// parseSection. We want it to be
@@ -248,7 +252,9 @@ int QDateTimeParser::absoluteMin(int s) const
{
const SectionNode &sn = sectionNode(s);
switch (sn.type) {
+#if QT_CONFIG(timezone)
case TimeZoneSection: return QTimeZone::MinUtcOffsetSecs;
+#endif
case Hour24Section:
case Hour12Section:
case MinuteSection:
@@ -766,9 +772,11 @@ QDateTimeParser::parseSection(const QDateTime &currentValue, int sectionIndex,
text->replace(offset, used, sectiontext.constData(), used);
break; }
case TimeZoneSection:
+#if QT_CONFIG(timezone)
result = findTimeZone(sectionTextRef, currentValue,
absoluteMax(sectionIndex),
absoluteMin(sectionIndex));
+#endif
break;
case MonthSection:
case DayOfWeekSectionShort:
@@ -1091,17 +1099,21 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
int dayofweek = defaultDate.dayOfWeek();
Qt::TimeSpec tspec = defaultValue.timeSpec();
int zoneOffset = 0; // In seconds; local - UTC
+#if QT_CONFIG(timezone)
QTimeZone timeZone;
+#endif
switch (tspec) {
case Qt::OffsetFromUTC: // timeZone is ignored
zoneOffset = defaultValue.offsetFromUtc();
break;
+#if QT_CONFIG(timezone)
case Qt::TimeZone:
timeZone = defaultValue.timeZone();
if (timeZone.isValid())
zoneOffset = timeZone.offsetFromUtc(defaultValue);
// else: is there anything we can do about this ?
break;
+#endif
default: // zoneOffset and timeZone are ignored
break;
}
@@ -1126,9 +1138,11 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
{
const QDate date = actualDate(isSet, year, year2digits, month, day, dayofweek);
const QTime time = actualTime(isSet, hour, hour12, ampm, minute, second, msec);
- sect = parseSection(tspec == Qt::TimeZone
- ? QDateTime(date, time, timeZone)
- : QDateTime(date, time, tspec, zoneOffset),
+ sect = parseSection(
+#if QT_CONFIG(timezone)
+ tspec == Qt::TimeZone ? QDateTime(date, time, timeZone) :
+#endif
+ QDateTime(date, time, tspec, zoneOffset),
index, pos, input);
}
@@ -1154,16 +1168,20 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
case TimeZoneSection:
current = &zoneOffset;
if (sect.used > 0) {
- // Synchronize with what findTimeZone() found:
+#if QT_CONFIG(timezone) // Synchronize with what findTimeZone() found:
QStringRef zoneName = input->midRef(pos, sect.used);
Q_ASSERT(!zoneName.isEmpty()); // sect.used > 0
- const QByteArray latinZone(zoneName.toLatin1());
+ const QByteArray latinZone(zoneName == QLatin1String("Z")
+ ? QByteArray("UTC") : zoneName.toLatin1());
timeZone = QTimeZone(latinZone);
tspec = timeZone.isValid()
? (QTimeZone::isTimeZoneIdAvailable(latinZone)
? Qt::TimeZone
: Qt::OffsetFromUTC)
: (Q_ASSERT(startsWithLocalTimeZone(zoneName)), Qt::LocalTime);
+#else
+ tspec = Qt::LocalTime;
+#endif
}
break;
case Hour24Section: current = &hour; break;
@@ -1321,9 +1339,11 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
const QDate date(year, month, day);
const QTime time(hour, minute, second, msec);
- return StateNode(tspec == Qt::TimeZone
- ? QDateTime(date, time, timeZone)
- : QDateTime(date, time, tspec, zoneOffset),
+ return StateNode(
+#if QT_CONFIG(timezone)
+ tspec == Qt::TimeZone ? QDateTime(date, time, timeZone) :
+#endif
+ QDateTime(date, time, tspec, zoneOffset),
state, padding, conflicts);
}
@@ -1571,6 +1591,7 @@ QDateTimeParser::ParsedSection
QDateTimeParser::findTimeZone(QStringRef str, const QDateTime &when,
int maxVal, int minVal) const
{
+#if QT_CONFIG(timezone)
int index = startsWithLocalTimeZone(str);
int offset;
@@ -1597,6 +1618,10 @@ QDateTimeParser::findTimeZone(QStringRef str, const QDateTime &when,
while (index > 0) {
str.truncate(index);
+ if (str == QLatin1String("Z")) {
+ offset = 0; // "Zulu" time - a.k.a. UTC
+ break;
+ }
QTimeZone zone(str.toLatin1());
if (zone.isValid()) {
offset = zone.offsetFromUtc(when);
@@ -1609,6 +1634,7 @@ QDateTimeParser::findTimeZone(QStringRef str, const QDateTime &when,
if (index > 0 && maxVal >= offset && offset >= minVal)
return ParsedSection(Acceptable, offset, index);
+#endif // timezone
return ParsedSection();
}
diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h
index c4afef0193..c9e63fe307 100644
--- a/src/corelib/tools/qdatetimeparser_p.h
+++ b/src/corelib/tools/qdatetimeparser_p.h
@@ -223,7 +223,10 @@ private:
QString *dayName = 0, int *used = 0) const;
ParsedSection findTimeZone(QStringRef str, const QDateTime &when,
int maxVal, int minVal) const;
- static int startsWithLocalTimeZone(const QStringRef name); // implemented in qdatetime.cpp
+#if QT_CONFIG(timezone)
+ // Implemented in qdatetime.cpp:
+ static int startsWithLocalTimeZone(const QStringRef name);
+#endif
enum AmPmFinder {
Neither = -1,
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index c785a5882a..5598dfe237 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -580,7 +580,7 @@ int qt_repeatCount(QStringView s)
if (s.isEmpty())
return 0;
const QChar c = s.front();
- qssize_t j = 1;
+ qsizetype j = 1;
while (j < s.size() && s.at(j) == c)
++j;
return int(j);
@@ -3459,7 +3459,7 @@ bool QLocaleData::validateChars(QStringView str, NumberMode numMode, QByteArray
bool dec = false;
int decDigitCnt = 0;
- for (qssize_t i = 0; i < str.size(); ++i) {
+ for (qsizetype i = 0; i < str.size(); ++i) {
char c = digitToCLocale(str.at(i));
if (c >= '0' && c <= '9') {
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index fc72c6e32c..a5b9096835 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -115,9 +115,9 @@ struct QMapNode : public QMapNodeBase
inline QMapNode *leftNode() const { return static_cast<QMapNode *>(left); }
inline QMapNode *rightNode() const { return static_cast<QMapNode *>(right); }
- inline const QMapNode *nextNode() const { return static_cast<const QMapNode *>(QMapNodeBase::nextNode()); }
+ inline const QMapNode *nextNode() const { return reinterpret_cast<const QMapNode *>(QMapNodeBase::nextNode()); }
inline const QMapNode *previousNode() const { return static_cast<const QMapNode *>(QMapNodeBase::previousNode()); }
- inline QMapNode *nextNode() { return static_cast<QMapNode *>(QMapNodeBase::nextNode()); }
+ inline QMapNode *nextNode() { return reinterpret_cast<QMapNode *>(QMapNodeBase::nextNode()); }
inline QMapNode *previousNode() { return static_cast<QMapNode *>(QMapNodeBase::previousNode()); }
QMapNode<Key, T> *copy(QMapData<Key, T> *d) const;
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 78b7e69d9c..8093a26f7d 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -160,9 +160,9 @@ static inline bool qt_ends_with(QStringView haystack, QStringView needle, Qt::Ca
static inline bool qt_ends_with(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs);
static inline bool qt_ends_with(QStringView haystack, QChar needle, Qt::CaseSensitivity cs);
-qssize_t QtPrivate::qustrlen(const ushort *str) Q_DECL_NOTHROW
+qsizetype QtPrivate::qustrlen(const ushort *str) Q_DECL_NOTHROW
{
- qssize_t result = 0;
+ qsizetype result = 0;
#ifdef __SSE2__
// find the 16-byte alignment immediately prior or equal to str
@@ -769,8 +769,6 @@ static int qt_compare_strings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSens
Case-sensitive comparison is based exclusively on the numeric Unicode values
of the characters and is very fast, but is not what a human would expect.
Consider sorting user-visible strings with QString::localeAwareCompare().
-
- \snippet qstring/main.cpp qCompareStrings-QSV-QSV
*/
int QtPrivate::compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
{
@@ -4837,7 +4835,7 @@ static QByteArray qt_convert_to_local_8bit(QStringView string);
locale, the returned byte array is undefined. Those characters may be
suppressed or replaced by another.
- \sa fromLocal8Bit(), toLatin1(), toUtf8(), QTextCodec, qConvertToLocal8Bit()
+ \sa fromLocal8Bit(), toLatin1(), toUtf8(), QTextCodec
*/
QByteArray QString::toLocal8Bit_helper(const QChar *data, int size)
@@ -4871,8 +4869,7 @@ static QByteArray qt_convert_to_local_8bit(QStringView string)
The behavior is undefined if \a string contains characters not
supported by the locale's 8-bit encoding.
- \sa QString::toLocal8Bit(), QStringView::toLocal8Bit(), QtPrivate::vonvertToLatin1(),
- QtPrivate::convertToUtf8(), QtPrivate::convertToUcs4()
+ \sa QString::toLocal8Bit(), QStringView::toLocal8Bit()
*/
QByteArray QtPrivate::convertToLocal8Bit(QStringView string)
{
@@ -4915,8 +4912,7 @@ static QByteArray qt_convert_to_utf8(QStringView str)
UTF-8 is a Unicode codec and can represent all characters in a Unicode
string like QStringView.
- \sa QString::toUtf8(), QStringView::toUtf8(), QtPrivate::convertToLatin1(),
- QtPrivate::convertToLocal8Bit(), QtPrivate::convertToUcs4()
+ \sa QString::toUtf8(), QStringView::toUtf8()
*/
QByteArray QtPrivate::convertToUtf8(QStringView string)
{
@@ -5279,8 +5275,8 @@ namespace {
}
/*!
- \fn QStringView qTrimmed(QStringView s)
- \fn QLatin1String qTrimmed(QLatin1String s)
+ \fn QStringView QtPrivate::trimmed(QStringView s)
+ \fn QLatin1String QtPrivate::trimmed(QLatin1String s)
\internal
\relates QStringView
\since 5.10
@@ -5521,14 +5517,9 @@ QString& QString::fill(QChar ch, int size)
Returns the number of characters in this string.
- The last character in the string is at position size() - 1. In
- addition, QString ensures that the character at position size()
- is always '\\0', so that you can use the return value of data()
- and constData() as arguments to functions that expect
- '\\0'-terminated strings.
+ The last character in the string is at position size() - 1.
Example:
-
\snippet qstring/main.cpp 58
\sa isEmpty(), resize()
@@ -6046,10 +6037,13 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1,
/*!
\fn const QChar *QString::unicode() const
- Returns a '\\0'-terminated Unicode representation of the string.
+ Returns a Unicode representation of the string.
The result remains valid until the string is modified.
- \sa utf16()
+ \note The returned string may not be '\\0'-terminated.
+ Use size() to determine the length of the array.
+
+ \sa utf16(), fromRawData()
*/
/*!
@@ -7250,6 +7244,16 @@ static ResultList splitString(const StringSource &source, const QChar *sep,
\snippet qstring/main.cpp 62
+ If \a sep is empty, split() returns an empty string, followed
+ by each of the string's characters, followed by another empty string:
+
+ \snippet qstring/main.cpp 62-empty
+
+ To understand this behavior, recall that the empty string matches
+ everywhere, so the above is qualitatively the same as:
+
+ \snippet qstring/main.cpp 62-slashes
+
\sa QStringList::join(), section()
*/
QStringList QString::split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
@@ -7259,15 +7263,10 @@ QStringList QString::split(const QString &sep, SplitBehavior behavior, Qt::CaseS
/*!
Splits the string into substring references wherever \a sep occurs, and
- returns the list of those strings. If \a sep does not match
- anywhere in the string, splitRef() returns a single-element vector
- containing this string reference.
+ returns the list of those strings.
- \a cs specifies whether \a sep should be matched case
- sensitively or case insensitively.
-
- If \a behavior is QString::SkipEmptyParts, empty entries don't
- appear in the result. By default, empty entries are kept.
+ See QString::split() for how \a sep, \a behavior and \a cs interact to form
+ the result.
\note All references are valid as long this string is alive. Destroying this
string will cause all references be dangling pointers.
@@ -7298,15 +7297,10 @@ QVector<QStringRef> QString::splitRef(QChar sep, SplitBehavior behavior, Qt::Cas
/*!
Splits the string into substrings references wherever \a sep occurs, and
- returns the list of those strings. If \a sep does not match
- anywhere in the string, split() returns a single-element vector
- containing this string reference.
+ returns the list of those strings.
- \a cs specifies whether \a sep should be matched case
- sensitively or case insensitively.
-
- If \a behavior is QString::SkipEmptyParts, empty entries don't
- appear in the result. By default, empty entries are kept.
+ See QString::split() for how \a sep, \a behavior and \a cs interact to form
+ the result.
\note All references are valid as long this string is alive. Destroying this
string will cause all references be dangling pointers.
@@ -8519,7 +8513,10 @@ bool QString::isRightToLeft() const
Returns a pointer to the data stored in the QString. The pointer
can be used to access and modify the characters that compose the
- string. For convenience, the data is '\\0'-terminated.
+ string.
+
+ Unlike constData() and unicode(), the returned data is always
+ '\\0'-terminated.
Example:
@@ -8535,18 +8532,25 @@ bool QString::isRightToLeft() const
/*! \fn const QChar *QString::data() const
\overload
+
+ \note The returned string may not be '\\0'-terminated.
+ Use size() to determine the length of the array.
+
+ \sa fromRawData()
*/
/*! \fn const QChar *QString::constData() const
Returns a pointer to the data stored in the QString. The pointer
- can be used to access the characters that compose the string. For
- convenience, the data is '\\0'-terminated.
+ can be used to access the characters that compose the string.
Note that the pointer remains valid only as long as the string is
not modified.
- \sa data(), operator[]()
+ \note The returned string may not be '\\0'-terminated.
+ Use size() to determine the length of the array.
+
+ \sa data(), operator[](), fromRawData()
*/
/*! \fn void QString::push_front(const QString &other)
@@ -8996,7 +9000,7 @@ QString &QString::setRawData(const QChar *unicode, int size)
If \a cs is Qt::CaseSensitive (the default), the search is case-sensitive;
otherwise the search is case-insensitive.
- \sa endsWith(), qStartsWith()
+ \sa endsWith()
*/
/*!
@@ -9016,7 +9020,7 @@ QString &QString::setRawData(const QChar *unicode, int size)
If \a cs is Qt::CaseSensitive (the default), the search is case-sensitive;
otherwise the search is case-insensitive.
- \sa startsWith(), qEndsWith()
+ \sa startsWith()
*/
/*!
diff --git a/src/corelib/tools/qstringalgorithms.h b/src/corelib/tools/qstringalgorithms.h
index 336da87468..aaa702301e 100644
--- a/src/corelib/tools/qstringalgorithms.h
+++ b/src/corelib/tools/qstringalgorithms.h
@@ -55,7 +55,7 @@ template <typename T> class QVector;
namespace QtPrivate {
-Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qssize_t qustrlen(const ushort *str) Q_DECL_NOTHROW;
+Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype qustrlen(const ushort *str) Q_DECL_NOTHROW;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW;
diff --git a/src/corelib/tools/qstringiterator.qdoc b/src/corelib/tools/qstringiterator.qdoc
index 95c2247bc1..caec8803f3 100644
--- a/src/corelib/tools/qstringiterator.qdoc
+++ b/src/corelib/tools/qstringiterator.qdoc
@@ -120,7 +120,7 @@
*/
/*!
- \fn QStringIterator::QStringIterator(QStringView string, qssize_t idx)
+ \fn QStringIterator::QStringIterator(QStringView string, qsizetype idx)
Constructs an iterator over the contents of \a string. The iterator will point
before position \a idx in the string.
diff --git a/src/corelib/tools/qstringiterator_p.h b/src/corelib/tools/qstringiterator_p.h
index 8b1a6a1cd3..219589b6e4 100644
--- a/src/corelib/tools/qstringiterator_p.h
+++ b/src/corelib/tools/qstringiterator_p.h
@@ -62,7 +62,7 @@ class QStringIterator
QString::const_iterator i, pos, e;
Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
public:
- explicit QStringIterator(QStringView string, qssize_t idx = 0)
+ explicit QStringIterator(QStringView string, qsizetype idx = 0)
: i(string.begin()),
pos(i + idx),
e(string.end())
diff --git a/src/corelib/tools/qstringview.cpp b/src/corelib/tools/qstringview.cpp
index 8eefc6d814..6321427a2d 100644
--- a/src/corelib/tools/qstringview.cpp
+++ b/src/corelib/tools/qstringview.cpp
@@ -131,9 +131,9 @@ QT_BEGIN_NAMESPACE
/*!
\typedef QStringView::size_type
- Alias for qssize_t. Provided for compatibility with the STL.
+ Alias for qsizetype. Provided for compatibility with the STL.
- Unlike other Qt classes, QStringView uses qssize_t as its \c size_type, to allow
+ Unlike other Qt classes, QStringView uses qsizetype as its \c size_type, to allow
accepting data from \c{std::basic_string} without truncation. The Qt API functions,
for example length(), return \c int, while the STL-compatible functions, for example
size(), return \c size_type.
@@ -224,7 +224,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QStringView::QStringView(const Char *str, qssize_t len)
+ \fn QStringView::QStringView(const Char *str, qsizetype len)
Constructs a string view on \a str with length \a len.
@@ -486,7 +486,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn qssize_t QStringView::size() const
+ \fn qsizetype QStringView::size() const
Returns the size of this string view, in UTF-16 code points (that is,
surrogate pairs count as two for the purposes of this function, the same
@@ -510,7 +510,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QChar QStringView::operator[](qssize_t n) const
+ \fn QChar QStringView::operator[](qsizetype n) const
Returns the character at position \a n in this string view.
@@ -520,7 +520,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QChar QStringView::at(qssize_t n) const
+ \fn QChar QStringView::at(qsizetype n) const
Returns the character at position \a n in this string view.
@@ -582,7 +582,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QStringView QStringView::mid(qssize_t start) const
+ \fn QStringView QStringView::mid(qsizetype start) const
Returns the substring starting at position \a start in this object,
and extending to the end of the string.
@@ -593,7 +593,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QStringView QStringView::mid(qssize_t start, qssize_t length) const
+ \fn QStringView QStringView::mid(qsizetype start, qsizetype length) const
\overload
Returns the substring of length \a length starting at position
@@ -606,7 +606,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QStringView QStringView::left(qssize_t length) const
+ \fn QStringView QStringView::left(qsizetype length) const
Returns the substring of length \a length starting at position
0 in this object.
@@ -617,7 +617,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QStringView QStringView::right(qssize_t length) const
+ \fn QStringView QStringView::right(qsizetype length) const
Returns the substring of length \a length starting at position
size() - \a length in this object.
@@ -628,7 +628,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QStringView QStringView::chopped(qssize_t length) const
+ \fn QStringView QStringView::chopped(qsizetype length) const
Returns the substring of length size() - \a length starting at the
beginning of this object.
@@ -641,7 +641,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn void QStringView::truncate(qssize_t length)
+ \fn void QStringView::truncate(qsizetype length)
Truncates this string view to length \a length.
@@ -653,7 +653,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn void QStringView::chop(qssize_t length)
+ \fn void QStringView::chop(qsizetype length)
Truncates this string view by \a length characters.
@@ -672,8 +672,6 @@ QT_BEGIN_NAMESPACE
Whitespace means any character for which QChar::isSpace() returns
\c true. This includes the ASCII characters '\\t', '\\n', '\\v',
'\\f', '\\r', and ' '.
-
- \sa qTrimmed()
*/
/*!
@@ -689,7 +687,7 @@ QT_BEGIN_NAMESPACE
If \a cs is Qt::CaseSensitive (the default), the search is case-sensitive;
otherwise the search is case-insensitive.
- \sa endsWith(), qStartsWith()
+ \sa endsWith()
*/
/*!
@@ -705,7 +703,7 @@ QT_BEGIN_NAMESPACE
If \a cs is Qt::CaseSensitive (the default), the search is case-sensitive;
otherwise the search is case-insensitive.
- \sa startsWith(), qEndsWith()
+ \sa startsWith()
*/
/*!
@@ -730,7 +728,7 @@ QT_BEGIN_NAMESPACE
The behavior is undefined if the string contains characters not
supported by the locale's 8-bit encoding.
- \sa toLatin1(), toUtf8(), QTextCodec, qConvertToLocal8Bit()
+ \sa toLatin1(), toUtf8(), QTextCodec
*/
/*!
diff --git a/src/corelib/tools/qstringview.h b/src/corelib/tools/qstringview.h
index 14405f325d..ef442e5b65 100644
--- a/src/corelib/tools/qstringview.h
+++ b/src/corelib/tools/qstringview.h
@@ -111,7 +111,7 @@ public:
#endif
typedef const QChar value_type;
typedef std::ptrdiff_t difference_type;
- typedef qssize_t size_type;
+ typedef qsizetype size_type;
typedef value_type &reference;
typedef value_type &const_reference;
typedef value_type *pointer;
@@ -139,24 +139,25 @@ private:
using if_compatible_qstring_like = typename std::enable_if<std::is_same<T, QString>::value || std::is_same<T, QStringRef>::value, bool>::type;
template <typename Char, size_t N>
- static Q_DECL_CONSTEXPR qssize_t lengthHelperArray(const Char (&)[N]) Q_DECL_NOTHROW
+ static Q_DECL_CONSTEXPR qsizetype lengthHelperArray(const Char (&)[N]) Q_DECL_NOTHROW
{
- return qssize_t(N - 1);
+ return qsizetype(N - 1);
}
template <typename Char>
- static qssize_t lengthHelperPointer(const Char *str) Q_DECL_NOTHROW
+ static qsizetype lengthHelperPointer(const Char *str) Q_DECL_NOTHROW
{
#if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
if (__builtin_constant_p(*str)) {
- qssize_t result = 0;
+ qsizetype result = 0;
while (*str++)
++result;
+ return result;
}
#endif
return QtPrivate::qustrlen(reinterpret_cast<const ushort *>(str));
}
- static qssize_t lengthHelperPointer(const QChar *str) Q_DECL_NOTHROW
+ static qsizetype lengthHelperPointer(const QChar *str) Q_DECL_NOTHROW
{
return QtPrivate::qustrlen(reinterpret_cast<const ushort *>(str));
}
@@ -174,7 +175,7 @@ public:
: QStringView() {}
template <typename Char, if_compatible_char<Char> = true>
- Q_DECL_CONSTEXPR QStringView(const Char *str, qssize_t len)
+ Q_DECL_CONSTEXPR QStringView(const Char *str, qsizetype len)
: m_size((Q_ASSERT(len >= 0), Q_ASSERT(str || !len), len)),
m_data(castHelper(str)) {}
@@ -204,20 +205,20 @@ public:
#else
template <typename String, if_compatible_qstring_like<String> = true>
QStringView(const String &str) Q_DECL_NOTHROW
- : QStringView(str.isNull() ? nullptr : str.data(), qssize_t(str.size())) {}
+ : QStringView(str.isNull() ? nullptr : str.data(), qsizetype(str.size())) {}
#endif
template <typename StdBasicString, if_compatible_string<StdBasicString> = true>
QStringView(const StdBasicString &str) Q_DECL_NOTHROW
- : QStringView(str.data(), qssize_t(str.size())) {}
+ : QStringView(str.data(), qsizetype(str.size())) {}
Q_REQUIRED_RESULT inline QString toString() const; // defined in qstring.h
- Q_REQUIRED_RESULT Q_DECL_CONSTEXPR qssize_t size() const Q_DECL_NOTHROW { return m_size; }
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR qsizetype size() const Q_DECL_NOTHROW { return m_size; }
Q_REQUIRED_RESULT const_pointer data() const Q_DECL_NOTHROW { return reinterpret_cast<const_pointer>(m_data); }
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR const storage_type *utf16() const Q_DECL_NOTHROW { return m_data; }
- Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar operator[](qssize_t n) const
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar operator[](qsizetype n) const
{ return Q_ASSERT(n >= 0), Q_ASSERT(n < size()), QChar(m_data[n]); }
//
@@ -229,22 +230,22 @@ public:
Q_REQUIRED_RESULT QByteArray toLocal8Bit() const { return QtPrivate::convertToLocal8Bit(*this); }
Q_REQUIRED_RESULT inline QVector<uint> toUcs4() const; // defined in qvector.h
- Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar at(qssize_t n) const { return (*this)[n]; }
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar at(qsizetype n) const { return (*this)[n]; }
- Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView mid(qssize_t pos) const
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView mid(qsizetype pos) const
{ return Q_ASSERT(pos >= 0), Q_ASSERT(pos <= size()), QStringView(m_data + pos, m_size - pos); }
- Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView mid(qssize_t pos, qssize_t n) const
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView mid(qsizetype pos, qsizetype n) const
{ return Q_ASSERT(pos >= 0), Q_ASSERT(n >= 0), Q_ASSERT(pos + n <= size()), QStringView(m_data + pos, n); }
- Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView left(qssize_t n) const
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView left(qsizetype n) const
{ return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QStringView(m_data, n); }
- Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView right(qssize_t n) const
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView right(qsizetype n) const
{ return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QStringView(m_data + m_size - n, n); }
- Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView chopped(qssize_t n) const
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView chopped(qsizetype n) const
{ return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QStringView(m_data, m_size - n); }
- Q_DECL_RELAXED_CONSTEXPR void truncate(qssize_t n)
+ Q_DECL_RELAXED_CONSTEXPR void truncate(qsizetype n)
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size = n; }
- Q_DECL_RELAXED_CONSTEXPR void chop(qssize_t n)
+ Q_DECL_RELAXED_CONSTEXPR void chop(qsizetype n)
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size -= n; }
Q_REQUIRED_RESULT QStringView trimmed() const Q_DECL_NOTHROW { return QtPrivate::trimmed(*this); }
@@ -291,7 +292,7 @@ public:
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar first() const { return front(); }
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar last() const { return back(); }
private:
- qssize_t m_size;
+ qsizetype m_size;
const storage_type *m_data;
};
Q_DECLARE_TYPEINFO(QStringView, Q_PRIMITIVE_TYPE);
diff --git a/src/corelib/tools/qunicodetables.cpp b/src/corelib/tools/qunicodetables.cpp
index ecab750833..01fa8b2102 100644
--- a/src/corelib/tools/qunicodetables.cpp
+++ b/src/corelib/tools/qunicodetables.cpp
@@ -6083,9 +6083,9 @@ static const Properties uc_properties[] = {
{ 18, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 7, 8, 13, 7 },
{ 25, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 8, 8, 12, 7 },
{ 25, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 12, 0, 12, 7 },
- { 10, 5, 0, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 3, 4, 4, 12, 8 },
- { 10, 5, 0, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 3, 4, 4, 12, 8 },
- { 10, 5, 0, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 3, 4, 4, 12, 2 },
+ { 10, 5, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 3, 4, 4, 12, 8 },
+ { 10, 5, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 3, 4, 4, 12, 8 },
+ { 10, 5, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 3, 4, 4, 12, 2 },
{ 26, 10, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 12, 8 },
{ 26, 13, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 12, 8 },
{ 25, 4, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 10, 8 },
@@ -6146,7 +6146,7 @@ static const Properties uc_properties[] = {
{ 18, 13, 0, 3, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 8, 8, 12, 8 },
{ 25, 13, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 12, 6, 8 },
{ 0, 17, 230, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 4, 4, 4, 21, 8 },
- { 10, 5, 0, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 4, 4, 12, 2 },
+ { 10, 5, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 4, 4, 12, 2 },
{ 29, 10, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 12, 8 },
{ 0, 17, 220, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 4, 4, 4, 21, 8 },
{ 17, 13, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 8, 8, 12, 8 },
@@ -6749,7 +6749,7 @@ static const Properties uc_properties[] = {
{ 25, 10, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 12, 6, 33 },
{ 25, 10, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 12, 33 },
{ 0, 17, 0, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 4, 4, 4, 21, 33 },
- { 10, 18, 0, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 3, 4, 4, 4, 33 },
+ { 10, 18, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 3, 4, 4, 4, 33 },
{ 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 14, 9, 11, 33 },
{ 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 14, 9, 11, 33 },
{ 3, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 14, 9, 11, 33 },
@@ -7058,7 +7058,7 @@ static const Properties uc_properties[] = {
{ 6, 9, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 80, 0, 0, 5, 17, 2 },
{ 6, 9, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 80, 0, 0, 5, 4, 2 },
{ 10, 18, 0, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 0, 4, 20, 2 },
- { 10, 18, 0, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 4, 4, 4, 21, 1 },
+ { 10, 18, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 4, 4, 4, 21, 1 },
{ 10, 18, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 4, 4, 4, 21, 1 },
{ 10, 0, 0, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 4, 4, 21, 2 },
{ 10, 1, 0, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 4, 4, 21, 2 },
@@ -7108,10 +7108,10 @@ static const Properties uc_properties[] = {
{ 10, 18, 0, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 3, 4, 4, 12, 2 },
{ 10, 18, 0, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 3, 4, 4, 12, 2 },
{ 13, 18, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 12, 0 },
- { 10, 19, 0, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 3, 4, 4, 21, 2 },
- { 10, 20, 0, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 3, 4, 4, 21, 2 },
- { 10, 21, 0, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 3, 4, 4, 21, 2 },
- { 10, 22, 0, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 3, 4, 4, 21, 2 },
+ { 10, 19, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 3, 4, 4, 21, 2 },
+ { 10, 20, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 3, 4, 4, 21, 2 },
+ { 10, 21, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 3, 4, 4, 21, 2 },
+ { 10, 22, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 3, 4, 4, 21, 2 },
{ 10, 18, 0, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 4, 4, 21, 2 },
{ 5, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 80, 0, 0, 0, 12, 2 },
{ 17, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 80, 0, 8, 6, 12, 3 },
diff --git a/src/corelib/tools/qunicodetables_p.h b/src/corelib/tools/qunicodetables_p.h
index 5a422ea4eb..be2f44f0c3 100644
--- a/src/corelib/tools/qunicodetables_p.h
+++ b/src/corelib/tools/qunicodetables_p.h
@@ -50,11 +50,11 @@
// We mean it.
//
-#include <QtCore/private/qglobal_p.h>
-
#ifndef QUNICODETABLES_P_H
#define QUNICODETABLES_P_H
+#include <QtCore/private/qglobal_p.h>
+
#include <QtCore/qchar.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 6825782131..ce6e657be0 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -162,9 +162,10 @@ public:
const const_iterator ce = this->cend(), cit = std::find(this->cbegin(), ce, t);
if (cit == ce)
return 0;
- // next operation detaches, so ce, cit may become invalidated:
+ // next operation detaches, so ce, cit, t may become invalidated:
+ const T tCopy = t;
const int firstFoundIdx = std::distance(this->cbegin(), cit);
- const iterator e = end(), it = std::remove(begin() + firstFoundIdx, e, t);
+ const iterator e = end(), it = std::remove(begin() + firstFoundIdx, e, tCopy);
const int result = std::distance(it, e);
erase(it, e);
return result;
diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp
index c1ed410de7..9b5295a17e 100644
--- a/src/corelib/xml/qxmlstream.cpp
+++ b/src/corelib/xml/qxmlstream.cpp
@@ -3741,7 +3741,6 @@ void QXmlStreamWriter::writeEntityReference(const QString &name)
void QXmlStreamWriter::writeNamespace(const QString &namespaceUri, const QString &prefix)
{
Q_D(QXmlStreamWriter);
- Q_ASSERT(!namespaceUri.isEmpty());
Q_ASSERT(prefix != QLatin1String("xmlns"));
if (prefix.isEmpty()) {
d->findNamespace(namespaceUri, d->inStartElement);