From eaf4438b3511c8380b9b691b656a87a60e342e29 Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Tue, 11 Dec 2018 11:42:34 +0200 Subject: Make url normalization closer to common browser behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Firefox, Chrome and various http libraries normalize /./ and /../ from urls, but retain multiple adjacent slashes as is. Qt removes duplicated slashes which makes it impossible to access some web resources that rely on those. Fixes: QTBUG-71973 Change-Id: Ie18ae6ad3264acb252fcd87a754726a8c546e5ec Reviewed-by: Edward Welbourne Reviewed-by: Mårten Nordheim Reviewed-by: Thiago Macieira --- src/corelib/io/qdir.cpp | 64 +++++++++++++++++++++++++++++++++++++++++-------- src/corelib/io/qdir_p.h | 12 ++++++++++ src/corelib/io/qurl.cpp | 8 +++---- 3 files changed, 70 insertions(+), 14 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 7df461ddce..405718aba8 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -2161,9 +2161,10 @@ bool QDir::match(const QString &filter, const QString &fileName) This method is shared with QUrl, so it doesn't deal with QDir::separator(), nor does it remove the trailing slash, if any. */ -Q_AUTOTEST_EXPORT QString qt_normalizePathSegments(const QString &name, bool allowUncPaths, - bool *ok = nullptr) +QString qt_normalizePathSegments(const QString &name, QDirPrivate::PathNormalizations flags, bool *ok) { + const bool allowUncPaths = QDirPrivate::AllowUncPaths & flags; + const bool isRemote = QDirPrivate::RemotePath & flags; const int len = name.length(); if (ok) @@ -2185,14 +2186,30 @@ Q_AUTOTEST_EXPORT QString qt_normalizePathSegments(const QString &name, bool all i -= prefixLength; // replicate trailing slash (i > 0 checks for emptiness of input string p) - if (i > 0 && p[i] == '/') { + // except for remote paths because there can be /../ or /./ ending + if (i > 0 && p[i] == '/' && !isRemote) { out[--used] = '/'; --i; } + auto isDot = [](const ushort *p, int i) { + return i > 1 && p[i - 1] == '.' && p[i - 2] == '/'; + }; + auto isDotDot = [](const ushort *p, int i) { + return i > 2 && p[i - 1] == '.' && p[i - 2] == '.' && p[i - 3] == '/'; + }; + while (i >= 0) { - // remove trailing slashes + // copy trailing slashes for remote urls if (p[i] == '/') { + if (isRemote && !up) { + if (isDot(p, i)) { + i -= 2; + continue; + } + out[--used] = p[i]; + } + --i; continue; } @@ -2204,10 +2221,17 @@ Q_AUTOTEST_EXPORT QString qt_normalizePathSegments(const QString &name, bool all } // detect up dir - if (i >= 1 && p[i] == '.' && p[i-1] == '.' - && (i == 1 || (i >= 2 && p[i-2] == '/'))) { + if (i >= 1 && p[i] == '.' && p[i-1] == '.' && (i < 2 || p[i - 2] == '/')) { ++up; - i -= 2; + i -= i >= 2 ? 3 : 2; + + if (isRemote) { + // moving up should consider empty path segments too (/path//../ -> /path/) + while (i > 0 && up && p[i] == '/') { + --up; + --i; + } + } continue; } @@ -2217,7 +2241,27 @@ Q_AUTOTEST_EXPORT QString qt_normalizePathSegments(const QString &name, bool all // skip or copy while (i >= 0) { - if (p[i] == '/') { // do not copy slashes + if (p[i] == '/') { + // copy all slashes as is for remote urls if they are not part of /./ or /../ + if (isRemote && !up) { + while (i > 0 && p[i] == '/' && !isDotDot(p, i)) { + + if (isDot(p, i)) { + i -= 2; + continue; + } + + out[--used] = p[i]; + --i; + } + + // in case of /./, jump over + if (isDot(p, i)) + i -= 2; + + break; + } + --i; break; } @@ -2238,7 +2282,7 @@ Q_AUTOTEST_EXPORT QString qt_normalizePathSegments(const QString &name, bool all *ok = prefixLength == 0 || up == 0; // add remaining '..' - while (up) { + while (up && !isRemote) { if (used != len && out[used] != '/') // is not empty and there isn't already a '/' out[--used] = '/'; out[--used] = '.'; @@ -2284,7 +2328,7 @@ static QString qt_cleanPath(const QString &path, bool *ok) if (dir_separator != QLatin1Char('/')) name.replace(dir_separator, QLatin1Char('/')); - QString ret = qt_normalizePathSegments(name, OSSupportsUncPaths, ok); + QString ret = qt_normalizePathSegments(name, OSSupportsUncPaths ? QDirPrivate::AllowUncPaths : QDirPrivate::DefaultNormalization, ok); // Strip away last slash except for root directories if (ret.length() > 1 && ret.endsWith(QLatin1Char('/'))) { diff --git a/src/corelib/io/qdir_p.h b/src/corelib/io/qdir_p.h index 85d915223c..0f3ab7f899 100644 --- a/src/corelib/io/qdir_p.h +++ b/src/corelib/io/qdir_p.h @@ -59,6 +59,14 @@ QT_BEGIN_NAMESPACE class QDirPrivate : public QSharedData { public: + enum PathNormalization { + DefaultNormalization = 0x00, + AllowUncPaths = 0x01, + RemotePath = 0x02 + }; + Q_DECLARE_FLAGS(PathNormalizations, PathNormalization) + Q_FLAGS(PathNormalizations) + explicit QDirPrivate(const QString &path, const QStringList &nameFilters_ = QStringList(), QDir::SortFlags sort_ = QDir::SortFlags(QDir::Name | QDir::IgnoreCase), QDir::Filters filters_ = QDir::AllEntries); @@ -97,6 +105,10 @@ public: mutable QFileSystemMetaData metaData; }; +Q_DECLARE_OPERATORS_FOR_FLAGS(QDirPrivate::PathNormalizations) + +Q_AUTOTEST_EXPORT QString qt_normalizePathSegments(const QString &name, QDirPrivate::PathNormalizations flags, bool *ok = nullptr); + QT_END_NAMESPACE #endif diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index b324df53b2..6d82981fd6 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -253,7 +253,8 @@ and contains no query or fragment, a local file path is returned. \value StripTrailingSlash The trailing slash is removed from the path, if one is present. \value NormalizePathSegments Modifies the path to remove redundant directory separators, - and to resolve "."s and ".."s (as far as possible). + and to resolve "."s and ".."s (as far as possible). For non-local paths, adjacent + slashes are preserved. Note that the case folding rules in \l{RFC 3491}{Nameprep}, which QUrl conforms to, require host names to always be converted to lower case, @@ -419,10 +420,9 @@ #endif #include "private/qipaddress_p.h" #include "qurlquery.h" +#include "private/qdir_p.h" QT_BEGIN_NAMESPACE -extern QString qt_normalizePathSegments(const QString &name, bool allowUncPaths, - bool *ok = nullptr); // qdir.cpp inline static bool isHex(char c) { @@ -930,7 +930,7 @@ inline void QUrlPrivate::appendPath(QString &appendTo, QUrl::FormattingOptions o { QString thePath = path; if (options & QUrl::NormalizePathSegments) { - thePath = qt_normalizePathSegments(path, false); + thePath = qt_normalizePathSegments(path, isLocalFile() ? QDirPrivate::DefaultNormalization : QDirPrivate::RemotePath); } QStringRef thePathRef(&thePath); -- cgit v1.2.3 From 9ce4260d232d94a9c902333e4b894fc0514d9e6d Mon Sep 17 00:00:00 2001 From: David Schulz Date: Wed, 12 Dec 2018 08:00:55 +0100 Subject: QWindowsLocalCodec::convertToUnicode(): Fix remaining char conversion Prevent passing a zero argument to the cbMultiByte parameter of MultiByteToWideChar. According to the documentation this will always fail. This is triggered when calling convertToUnicode with a state having remainingChars of one and a length of one. The remaining chars will be completed and the length will be reduced to zero before the actual convert. Adding an early return after the completion to prevent calling MultiByteToWideChar with the invalid zero argument. Fixes: QTCREATORBUG-21622 Change-Id: Ic6a433dd929e97b1681583cb1b9a347afaa9a09f Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira --- src/corelib/codecs/qwindowscodec.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/codecs/qwindowscodec.cpp b/src/corelib/codecs/qwindowscodec.cpp index 813d3c8153..37e1183fb6 100644 --- a/src/corelib/codecs/qwindowscodec.cpp +++ b/src/corelib/codecs/qwindowscodec.cpp @@ -83,8 +83,12 @@ QString QWindowsLocalCodec::convertToUnicode(const char *chars, int length, Conv len = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, prev, 2, wc.data(), wc.length()); if (len) { - prepend = true; sp.append(QChar(wc[0])); + if (mblen == 1) { + state->remainingChars = 0; + return sp; + } + prepend = true; mb++; mblen--; wc[0] = 0; -- cgit v1.2.3 From 193d19d86e2c5408c3691b47f2bc89df124112a5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 12 Dec 2018 21:56:28 -0800 Subject: Add "Mojave" to QSysInfo::prettyProductName() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-72489 Change-Id: I4ac1156702324f0fb814fffd156fcecfa95a1a2d Reviewed-by: Timur Pocheptsov Reviewed-by: Tor Arne Vestbø --- src/corelib/global/qglobal.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 88d4877be5..b17125d4ab 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2025,6 +2025,8 @@ static const char *osVer_helper(QOperatingSystemVersion version = QOperatingSyst return "Sierra"; case 13: return "High Sierra"; + case 14: + return "Mojave"; } } // unknown, future version -- cgit v1.2.3 From e3d1f8d0753cc0f7486378bdc41fad9bde4b6d5c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 10 Dec 2018 18:55:09 -0800 Subject: Fix build in INTEGRITY: __mulh is not defined MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 6b875f0625acc6c6a4f8899b829176baaf7d8502 created a macro for it, but in the multiple updates to find the best solution, we forgot to use it. Fixes: QTBUG-72429 Change-Id: I4ac1156702324f0fb814fffd156f27c1789d1409 Reviewed-by: Thomas Miller Reviewed-by: Janne Koskinen Reviewed-by: Mårten Nordheim --- src/corelib/global/qnumeric_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index 5326d9485b..dd59f97f8b 100644 --- a/src/corelib/global/qnumeric_p.h +++ b/src/corelib/global/qnumeric_p.h @@ -348,7 +348,7 @@ template <> inline bool mul_overflow(qint64 v1, qint64 v2, qint64 *r) // as signed for the low bits and use a signed right shift to verify that // 'high' is nothing but sign bits that match the sign of 'low'. - qint64 high = __mulh(v1, v2); + qint64 high = Q_SMULH(v1, v2); *r = qint64(quint64(v1) * quint64(v2)); return (*r >> 63) != high; } -- cgit v1.2.3 From 3b03150aa2af76b13424c988c6c7892d19cce6c5 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Wed, 12 Dec 2018 12:36:39 +0100 Subject: Doc: Restore documentation for QTest functions in other modules Qt Test library sources specific to Core, GUI and Widgets modules were moved around in commit 88867e39b. The new source locations must be referenced in Qt Test documentation configuration. The same sources are excluded in their original doc projects, and the related snippet file is moved over to qttestlib. The commit also fixes the remaining documentation issues for Qt Test. Change-Id: Ibe011aa83639e574d647f12bc9e53e618781bce6 Reviewed-by: Martin Smith --- src/corelib/doc/qtcore.qdocconf | 3 ++ .../code/src_corelib_kernel_qtestsupport_core.cpp | 52 ---------------------- src/corelib/kernel/qtestsupport_core.cpp | 6 +-- 3 files changed, 5 insertions(+), 56 deletions(-) delete mode 100644 src/corelib/doc/snippets/code/src_corelib_kernel_qtestsupport_core.cpp (limited to 'src/corelib') diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf index 5a42e21845..85dcde4607 100644 --- a/src/corelib/doc/qtcore.qdocconf +++ b/src/corelib/doc/qtcore.qdocconf @@ -45,6 +45,9 @@ excludedirs += snippets excludefiles += ../../../examples/widgets/tools/customcompleter/doc/src/customcompleter.qdoc \ ../../../examples/widgets/tools/codecs/doc/src/codecs.qdoc +# Included in qttestlib.qdocconf instead +excludefiles += ../kernel/qtestsupport_core.cpp + manifestmeta.highlighted.names = "QtCore/JSON Save Game Example" \ "QtCore/Local Fortune*" diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qtestsupport_core.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qtestsupport_core.cpp deleted file mode 100644 index ed3e9bd0c0..0000000000 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qtestsupport_core.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtTest 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$ -** -****************************************************************************/ - -//! [0] - MyObject obj; - obj.startup(); - QTest::qWaitFor([&]() { - return obj.isReady(); - }, 3000); -//! [0] - -//! [1] - int i = 0; - while (myNetworkServerNotResponding() && i++ < 50) - QTest::qWait(250); -//! [1] diff --git a/src/corelib/kernel/qtestsupport_core.cpp b/src/corelib/kernel/qtestsupport_core.cpp index d69551a227..aba2a136a1 100644 --- a/src/corelib/kernel/qtestsupport_core.cpp +++ b/src/corelib/kernel/qtestsupport_core.cpp @@ -59,8 +59,7 @@ Q_CORE_EXPORT void QTestPrivate::qSleep(int ms) #endif } -/*! \fn template bool qWaitFor(Functor predicate, int timeout) - \relates QTest +/*! \fn template bool QTest::qWaitFor(Functor predicate, int timeout) Waits for \a timeout milliseconds or until the \a predicate returns true. @@ -77,8 +76,7 @@ Q_CORE_EXPORT void QTestPrivate::qSleep(int ms) */ -/*! \fn void qWait(int ms) - \relates QTest +/*! \fn void QTest::qWait(int ms) Waits for \a ms milliseconds. While waiting, events will be processed and your test will stay responsive to user interface events or network communication. -- cgit v1.2.3 From dd5e7f1a52c51061ad54e870df7f8e04c0f06fbe Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 5 Nov 2018 16:55:08 +0100 Subject: Use a more robust test for absolute paths in QDir Its filePath() and absoluteFilePath() don't trust its own isAbsolute(), due to some infelicities on MS-Win; and kludged round a consequent problem with resource paths; but other virtual file systems weren't catered for. Replace the convoluted test there with a static bool function (so that future kludges in this area shall only need to edit one place; and can document why they're needed) and use a more robust test that handles all virtual file systems (by asking QFileInfo) but falls back to QFileSystemEntry to work round the known infelicities on MS-Win. Add regression test for asset library paths issue on iOS. Ammends 27f1f84c1c2. Moved a couple of local variables to after the early return, since it doesn't need them, in the process. Task-number: QTBUG-70237 Change-Id: Ib3954826df40ccf816beebe5c3751497e3bf6433 Reviewed-by: Edward Welbourne Reviewed-by: Andy Shaw --- src/corelib/io/qdir.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 4b63a38963..f7778943c9 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -748,6 +748,21 @@ static int drivePrefixLength(const QString &path) } #endif // Q_OS_WIN +static bool treatAsAbsolute(const QString &path) +{ + // ### Qt 6: be consistent about absolute paths + + // QFileInfo will use the right FS-engine for virtual file-systems + // (e.g. resource paths). Unfortunately, for real file-systems, it relies + // on QFileSystemEntry's isRelative(), which is flawed on MS-Win, ignoring + // its (correct) isAbsolute(). So only use that isAbsolute() unless there's + // a colon in the path. + // FIXME: relies on virtual file-systems having colons in their prefixes. + // The case of an MS-absolute C:/... path happens to work either way. + return (path.contains(QLatin1Char(':')) && QFileInfo(path).isAbsolute()) + || QFileSystemEntry(path).isAbsolute(); +} + /*! Returns the path name of a file in the directory. Does \e not check if the file actually exists in the directory; but see @@ -759,13 +774,10 @@ static int drivePrefixLength(const QString &path) */ QString QDir::filePath(const QString &fileName) const { - const QDirPrivate* d = d_ptr.constData(); - // Mistrust our own isAbsolutePath() for real files; Q_OS_WIN needs a drive. - if (fileName.startsWith(QLatin1Char(':')) // i.e. resource path - ? isAbsolutePath(fileName) : QFileSystemEntry(fileName).isAbsolute()) { + if (treatAsAbsolute(fileName)) return fileName; - } + const QDirPrivate* d = d_ptr.constData(); QString ret = d->dirEntry.filePath(); if (fileName.isEmpty()) return ret; @@ -793,13 +805,10 @@ QString QDir::filePath(const QString &fileName) const */ QString QDir::absoluteFilePath(const QString &fileName) const { - const QDirPrivate* d = d_ptr.constData(); - // Mistrust our own isAbsolutePath() for real files; Q_OS_WIN needs a drive. - if (fileName.startsWith(QLatin1Char(':')) // i.e. resource path - ? isAbsolutePath(fileName) : QFileSystemEntry(fileName).isAbsolute()) { + if (treatAsAbsolute(fileName)) return fileName; - } + const QDirPrivate* d = d_ptr.constData(); d->resolveAbsoluteEntry(); const QString absoluteDirPath = d->absoluteDirEntry.filePath(); if (fileName.isEmpty()) -- cgit v1.2.3 From 119487650e28073f5766cc43cb679eb629a2a0c5 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 15 Jan 2019 15:32:44 +0100 Subject: Doc: End sentence about Q_GADGET with dot Change-Id: I55380d133017670f212df331fba655e80538e412 Reviewed-by: Leena Miettinen --- src/corelib/kernel/qobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index b5d97c5538..4680742a3e 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4446,7 +4446,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) macro, it must appear in the private section of a class definition. Q_GADGETs can have Q_ENUM, Q_PROPERTY and Q_INVOKABLE, but they cannot have - signals or slots + signals or slots. Q_GADGET makes a class member, \c{staticMetaObject}, available. \c{staticMetaObject} is of type QMetaObject and provides access to the -- cgit v1.2.3 From 524a37f99d3d3115a1b371fd289044d90349a824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 20 Dec 2018 17:38:03 +0100 Subject: qfilesystemengine_win: Update LinkType whenever asked Checking the known flags prevented us from correctly setting the LinkType flag if we had previously set LinkType as a known flag since the flag is not reset between updates. Manifested itself in situations where the file info is loaded and then the LegacyLinkType flag is checked through QFileInfoPrivate::checkAttribute. Since the LegacyLinkType is not set for Windows it will update the metadata and exclude the LinkType flag. Change-Id: Iea27f42fe11f36ba2247e52fa9c82b4639666a64 Fixes: QTBUG-72644 Reviewed-by: Thiago Macieira --- src/corelib/io/qfilesystemengine_win.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index a796fd005a..3f4b46573b 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -1038,8 +1038,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM if (what & QFileSystemMetaData::Permissions) fillPermissions(fname, data, what); - if ((what & QFileSystemMetaData::LinkType) - && data.missingFlags(QFileSystemMetaData::LinkType)) { + if (what & QFileSystemMetaData::LinkType) { data.knownFlagsMask |= QFileSystemMetaData::LinkType; if (data.fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT) { WIN32_FIND_DATA findData; -- cgit v1.2.3 From 9818af7d436f7aa1bf5c635041cc5d08fec599b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 18 Jan 2019 09:31:10 +0200 Subject: qsimd: Fix compilation with trunk clang for mingw Current tip-of-tree clang (after Clang 8 was branched) added an intrinsic function __builtin_ia32_xgetbv, and added the following define that provides _xgetbv: #define _xgetbv(A) __builtin_ia32_xgetbv((long long)(A)) This fallback declaration of the _xgetbv function only is used in case the Q_OS_WIN branch of the #if/#elif below is used, if the #if (defined(Q_CC_GNU) && !defined(Q_CC_EMSCRIPTEN)) || defined(Q_CC_GHS) wasn't taken. I left out the !defined(Q_CC_EMSCRIPTEN) part as I believe Q_OS_WIN and Q_CC_EMSCRIPTEN are mutually exclusive. Change-Id: I257fc4283ff9f0845df51ab764cf58acdf285c66 Reviewed-by: Thiago Macieira --- src/corelib/tools/qsimd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp index 07a8b022bc..1b51b591f7 100644 --- a/src/corelib/tools/qsimd.cpp +++ b/src/corelib/tools/qsimd.cpp @@ -293,7 +293,7 @@ static void cpuidFeatures07_00(uint &ebx, uint &ecx, uint &edx) #endif } -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) && !(defined(Q_CC_GNU) || defined(Q_CC_GHS)) // fallback overload in case this intrinsic does not exist: unsigned __int64 _xgetbv(unsigned int); inline quint64 _xgetbv(__int64) { return 0; } #endif -- cgit v1.2.3 From 4faf011c3f5f4a739f4ddc54040b5319f7fe5d90 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 10 Jan 2019 17:38:55 +0100 Subject: Document that you shouldn't Q_ENUM() things outside the int range The meta object system stores enums as signed int, probably for performance reasons. This is good enough for about 99% of the use cases. If you try to register larger types and then access them through the metaobject system, you can get undefined behavior. Task-number: QTBUG-71947 Change-Id: I16b395547c22fad10b476c2c2a0768538db0a20e Reviewed-by: Thiago Macieira --- src/corelib/kernel/qobject.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 4680742a3e..42c39f18e3 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4338,6 +4338,12 @@ QDebug operator<<(QDebug dbg, const QObject *o) in a QVariant, you can convert them to strings. Likewise, passing them to QDebug will print out their names. + Mind that the enum values are stored as signed \c int in the meta object system. + Registering enumerations with values outside the range of values valid for \c int + will lead to overflows and potentially undefined behavior when accessing them through + the meta object system. QML, for example, does access registered enumerations through + the meta object system. + \sa {Qt's Property System} */ @@ -4389,6 +4395,12 @@ QDebug operator<<(QDebug dbg, const QObject *o) used in a QVariant, you can convert them to strings. Likewise, passing them to QDebug will print out their names. + Mind that the enum values are stored as signed \c int in the meta object system. + Registering enumerations with values outside the range of values valid for \c int + will lead to overflows and potentially undefined behavior when accessing them through + the meta object system. QML, for example, does access registered enumerations through + the meta object system. + \sa {Qt's Property System} */ -- cgit v1.2.3