From 872bff5b24ded4a5dfecad96df907f32830a980a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 31 Oct 2016 16:07:53 -0700 Subject: Enable a given SIMD feature if the compiler has enabled it Change-Id: I09100678ff4443e6be06fffd1482c08125adc0a4 Reviewed-by: Allan Sandfeld Jensen --- src/corelib/tools/qsimd_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index f6164e2297..d5d887598e 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -169,7 +169,7 @@ || (defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && (__GNUC__-0) * 100 + (__GNUC_MINOR__-0) >= 409)) \ && !defined(QT_BOOTSTRAPPED) # define QT_COMPILER_SUPPORTS_SIMD_ALWAYS -# define QT_COMPILER_SUPPORTS_HERE(x) QT_COMPILER_SUPPORTS(x) +# define QT_COMPILER_SUPPORTS_HERE(x) (__ ## x ## __) || QT_COMPILER_SUPPORTS(x) # if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) /* GCC requires attributes for a function */ # define QT_FUNCTION_TARGET(x) __attribute__((__target__(QT_FUNCTION_TARGET_STRING_ ## x))) -- cgit v1.2.3 From f497dea73080c2d8910bd5b6d74c9a6226db0c92 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 27 Mar 2017 13:19:15 +0200 Subject: Doc: Clarify the porting notes from QRegExp to QRegularExpression Add a small table to illustrate the results exactMatch() and split out the part on partial matching to a separate section since it is less common. Change-Id: Ifbd5c3cbd1d8c0ee9e8b2d58ed13f40776b03762 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Leena Miettinen --- src/corelib/tools/qregularexpression.cpp | 35 ++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index f1fac093b0..88b696f53a 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -445,19 +445,25 @@ QT_BEGIN_NAMESPACE Other differences are outlined below. - \section2 Exact matching + \section2 Porting from QRegExp::exactMatch() QRegExp::exactMatch() in Qt 4 served two purposes: it exactly matched a regular expression against a subject string, and it implemented partial - matching. In fact, if an exact match was not found, one could still find - out how much of the subject string was matched by the regular expression - by calling QRegExp::matchedLength(). If the returned length was equal - to the subject string's length, then one could desume that a partial match - was found. + matching. - QRegularExpression supports partial matching explicitly by means of the - appropriate MatchType. If instead you simply want to be sure that the - subject string matches the regular expression exactly, you can wrap the + \section3 Porting from QRegExp's Exact Matching + + Exact matching indicates whether the regular expression matches the entire + subject string. For example, the classes yield on the subject string \c{"abc123"}: + + \table + \header \li \li QRegExp::exactMatch() \li QRegularExpressionMatch::hasMatch() + \row \li \c{"\\d+"} \li \b false \li \b true + \row \li \c{"[a-z]+\\d+"} \li \b true \li \b true + \endtable + + Exact matching is not reflected in QRegularExpression. If you want to be + sure that the subject string matches the regular expression exactly, you can wrap the pattern between a couple of anchoring expressions. Simply putting the pattern between the \c{^} and the \c{$} anchors is enough in most cases: @@ -479,6 +485,17 @@ QT_BEGIN_NAMESPACE Note the usage of the non-capturing group in order to preserve the meaning of the branch operator inside the pattern. + \section3 Porting from QRegExp's Partial Matching + + When using QRegExp::exactMatch(), if an exact match was not found, one + could still find out how much of the subject string was matched by the + regular expression by calling QRegExp::matchedLength(). If the returned length + was equal to the subject string's length, then one could conclude that a partial + match was found. + + QRegularExpression supports partial matching explicitly by means of the + appropriate MatchType. + \section2 Global matching Due to limitations of the QRegExp API it was impossible to implement global -- cgit v1.2.3 From 795a54ff9688697c033fc5d522f4c50c707d5924 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 9 Mar 2017 13:54:56 +0100 Subject: QDataStream: add operator<< and >> for std::nullptr_t std::nullptr_t is nullary: it accepts only one value, nullptr. So we don't need to read or write anything. This commit simply adds the two operators that allow generic code to operate on std::nullptr_t if required. This commit also adds the actual use to QMetaType::load/save, even though there's no change in behavior. [ChangeLog][QtCore][QDataStream] Added operator<< and operator>> overloads that take std::nullptr_t, to facilitate generic code. Change-Id: Iae839f6a131a4f0784bffffd14aa37e7f62d2740 Reviewed-by: Marc Mutz Reviewed-by: Lars Knoll --- src/corelib/io/qdatastream.cpp | 20 ++++++++++++++++++++ src/corelib/io/qdatastream.h | 2 ++ src/corelib/kernel/qmetatype.cpp | 2 ++ 3 files changed, 24 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp index 2369fe4726..9a42fb4a37 100644 --- a/src/corelib/io/qdatastream.cpp +++ b/src/corelib/io/qdatastream.cpp @@ -770,6 +770,17 @@ int QDataStream::readBlock(char *data, int len) return readResult; } +/*! + \fn QDataStream &QDataStream::operator>>(std::nullptr &ptr) + \since 5.9 + \overload + + Simulates reading a \c{std::nullptr_t} from the stream into \a ptr and + returns a reference to the stream. This function does not actually read + anything from the stream, as \c{std::nullptr_t} values are stored as 0 + bytes. +*/ + /*! \fn QDataStream &QDataStream::operator>>(quint8 &i) \overload @@ -1084,6 +1095,15 @@ int QDataStream::readRawData(char *s, int len) QDataStream write functions *****************************************************************************/ +/*! + \fn QDataStream &QDataStream::operator<<(std::nullptr ptr) + \since 5.9 + \overload + + Simulates writing a \c{std::nullptr_t}, \a ptr, to the stream and returns a + reference to the stream. This function does not actually write anything to + the stream, as \c{std::nullptr_t} values are stored as 0 bytes. +*/ /*! \fn QDataStream &QDataStream::operator<<(quint8 i) diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h index db1bbfbd63..575607e147 100644 --- a/src/corelib/io/qdatastream.h +++ b/src/corelib/io/qdatastream.h @@ -152,6 +152,7 @@ public: QDataStream &operator>>(quint32 &i); QDataStream &operator>>(qint64 &i); QDataStream &operator>>(quint64 &i); + QDataStream &operator>>(std::nullptr_t &ptr) { ptr = nullptr; return *this; } QDataStream &operator>>(bool &i); QDataStream &operator>>(qfloat16 &f); @@ -167,6 +168,7 @@ public: QDataStream &operator<<(quint32 i); QDataStream &operator<<(qint64 i); QDataStream &operator<<(quint64 i); + QDataStream &operator<<(std::nullptr_t) { return *this; } QDataStream &operator<<(bool i); QDataStream &operator<<(qfloat16 f); QDataStream &operator<<(float f); diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index fc8d7dcfea..b75f2ad9dc 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -1350,6 +1350,7 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data) case QMetaType::QJsonDocument: return false; case QMetaType::Nullptr: + stream << *static_cast(data); return true; case QMetaType::Long: stream << qlonglong(*static_cast(data)); @@ -1573,6 +1574,7 @@ bool QMetaType::load(QDataStream &stream, int type, void *data) case QMetaType::QJsonDocument: return false; case QMetaType::Nullptr: + stream >> *static_cast(data); return true; case QMetaType::Long: { qlonglong l; -- cgit v1.2.3 From 23d08ce2edab09562ad283dac5d46c09efec63ca Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Feb 2017 13:58:55 -0800 Subject: Fix QDir::mkpath() when the path contains "symlink/../" It is incorrect to collapse a "symlink/.." segment because the parent directory of the symlink's target may not be the directory where the symlink itself is located. [ChangeLog][QtCore][QDir] Fixed a bug that caused QDir::mkpath() to create the wrong directory if the requested path contained a symbolic link and "../". Change-Id: Iaddbecfbba5441c8b2e4fffd14a3e367730a1e24 Reviewed-by: Oswald Buddenhagen Reviewed-by: David Faure --- src/corelib/io/qfilesystemengine_unix.cpp | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 3cb412e47c..e195afdae9 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -1,5 +1,6 @@ /**************************************************************************** ** +** Copyright (C) 2017 Intel Corporation. ** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2013 Samuel Gaist ** Contact: https://www.qt.io/licensing/ @@ -603,25 +604,7 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea if (!createParents) return false; - // we need the cleaned path in order to create the parents - // and we save errno just in case encodeName needs to load codecs - int savedErrno = errno; - bool pathChanged; - { - QString cleanName = QDir::cleanPath(dirName); - - // Check if the cleaned name is the same or not. If we were given a - // path with resolvable "../" sections, cleanPath will remove them, but - // this may change the target dir if one of those segments was a - // symlink. This operation depends on cleanPath's optimization of - // returning the original string if it didn't modify anything. - pathChanged = !dirName.isSharedWith(cleanName); - if (pathChanged) - nativeName = QFile::encodeName(cleanName); - } - - errno = savedErrno; - return createDirectoryWithParents(nativeName, pathChanged); + return createDirectoryWithParents(nativeName, false); } //static -- cgit v1.2.3 From 944bf6867f8360e7ec79f542f65b4ea556ecc4e5 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Sun, 5 Mar 2017 17:28:56 +0100 Subject: Add more information about how to get a QString from qgetenv Change-Id: Ic712654c8d4735a59bf02cf6a7e1c689ca9a886c Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 54df8b1f61..6b3cb502e5 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -3220,12 +3220,16 @@ static QBasicMutex environmentMutex; Returns the value of the environment variable with name \a varName. To get the variable string, use QByteArray::constData(). + To convert the data to a QString use QString::fromLocal8Bit(). \note qgetenv() was introduced because getenv() from the standard C library was deprecated in VC2005 (and later versions). qgetenv() uses the new replacement function in VC, and calls the standard C library's implementation on all other platforms. + \warning Don't use qgetenv on Windows if the content may contain + non-US-ASCII characters, like file paths. + \sa qputenv(), qEnvironmentVariableIsSet(), qEnvironmentVariableIsEmpty() */ QByteArray qgetenv(const char *varName) -- cgit v1.2.3 From 75cdf654bcc192ba73a8834e507583a59140e7e4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 7 Apr 2017 13:12:05 -0700 Subject: QMap: fix UB (invalid cast) in QMapData::end() The end() pointer, like in all other containers, is a sentinel value that must never be dereferenced. But unlike array-based containers, end() in QMap is not "last element plus one", but points to a base class of Node, not a full Node. Therefore, the casting from QMapNodeBase to QMapNode must not be a static_cast, reinterpret_cast is required. libstdc++-v3's red-black tree had the exact same problem: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734 Change-Id: I43f05fedf0b44314a2dafffd14b33697861ae589 Reviewed-by: Marc Mutz --- src/corelib/tools/qmap.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 3f4f034b4e..da77ba4458 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -209,8 +209,10 @@ struct QMapData : public QMapDataBase Node *root() const { return static_cast(header.left); } - const Node *end() const { return static_cast(&header); } - Node *end() { return static_cast(&header); } + // using reinterpret_cast because QMapDataBase::header is not + // actually a QMapNode. + const Node *end() const { return reinterpret_cast(&header); } + Node *end() { return reinterpret_cast(&header); } const Node *begin() const { if (root()) return static_cast(mostLeftNode); return end(); } Node *begin() { if (root()) return static_cast(mostLeftNode); return end(); } -- cgit v1.2.3 From 9d1203bf02abec8b5ab73c4c8a81eb4627336ad8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 9 Apr 2017 09:19:41 +0200 Subject: QVariant: fix docs regarding QUuid - toUuid(): QUuid is a built-in type, so use type(), not userType() - canConvert()/toUuid(): QUuid converts to and from QString Change-Id: I5262ff7ab093040cb943b6ab9cfffe95491d2b9b Reviewed-by: Thiago Macieira --- src/corelib/kernel/qvariant.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 7c9df5b46f..8ad61be8ee 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -2526,8 +2526,9 @@ QRegularExpression QVariant::toRegularExpression() const /*! \since 5.0 - Returns the variant as a QUuid if the variant has userType() \l - QUuid; otherwise returns a default constructed QUuid. + Returns the variant as a QUuid if the variant has type() + \l QMetaType::QUuid or \l QMetaType::QString; + otherwise returns a default-constructed QUuid. \sa canConvert(), convert() */ @@ -2995,7 +2996,7 @@ static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject) \l QMetaType::QDate, \l QMetaType::QDateTime, \l QMetaType::Double, \l QMetaType::QFont, \l QMetaType::Int, \l QMetaType::QKeySequence, \l QMetaType::LongLong, \l QMetaType::QStringList, \l QMetaType::QTime, - \l QMetaType::UInt, \l QMetaType::ULongLong + \l QMetaType::UInt, \l QMetaType::ULongLong, \l QMetaType::QUuid \row \li \l QMetaType::QStringList \li \l QMetaType::QVariantList, \l QMetaType::QString (if the list contains exactly one item) \row \li \l QMetaType::QTime \li \l QMetaType::QString @@ -3005,6 +3006,7 @@ static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject) \row \li \l QMetaType::ULongLong \li \l QMetaType::Bool, \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt + \row \li \l QMetaType::QUuid \li \l QMetaType::QString \endtable A QVariant containing a pointer to a type derived from QObject will also return true for this -- cgit v1.2.3 From 46c66bce5de04396292600b0c2c87c2468a02102 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 7 Feb 2017 22:29:45 +0100 Subject: Optimize QLoggingSettingsParser Factor the line parsing into a separate function, parseNextLine(), taking a QStringRef. In setContent(QTextStream&), use the new readLineInto() function to re-use the capacity of a single QString for all lines. In setContent(QString), use splitRef() to split the lines. In either function, pass each line to parseNextLine(). In order to port all the parsing to QStringRef, I needed to make some semantic changes: the old code removed all whitespace right at the beginning. This is not possible with QStringRef. It also didn't feel right, since a line like [ r u l e s ] would successfully parse as the section named "rules". I added trimmed() calls at the beginning, and around the valueStr and pattern extraction, which should be good enough. Also, when a section is found, don't store it anymore. Instead, only store whether it was the [rules] section, because that's all we'll test for. That way, we don't have to convert QStringRefs to QString just to store them across parseNextLine() calls. Replace the setSection() function with setImplicitRulesSection(), because "rules" is all that was ever passed. This is private API, we can bring back some of the dropped flexibility later, as needed. [ChangeLog][Important Behavior Changes] Logging rules can no longer contain arbitrary whitespace such as within a category identifier. Change-Id: Ic26cd23c71f5c810b37ef4b972354ac31d3408fe Reviewed-by: Kai Koehne --- src/corelib/io/qloggingregistry.cpp | 83 ++++++++++++++++++++----------------- src/corelib/io/qloggingregistry_p.h | 7 +++- 2 files changed, 51 insertions(+), 39 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index ff865dc9a1..47fb1fb6b8 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -186,9 +186,10 @@ void QLoggingRule::parse(const QStringRef &pattern) */ void QLoggingSettingsParser::setContent(const QString &content) { - QString content_ = content; - QTextStream stream(&content_, QIODevice::ReadOnly); - setContent(stream); + _rules.clear(); + const auto lines = content.splitRef(QLatin1Char('\n')); + for (const auto &line : lines) + parseNextLine(line); } /*! @@ -198,42 +199,50 @@ void QLoggingSettingsParser::setContent(const QString &content) void QLoggingSettingsParser::setContent(QTextStream &stream) { _rules.clear(); - while (!stream.atEnd()) { - QString line = stream.readLine(); - - // Remove all whitespace from line - line = line.simplified(); - line.remove(QLatin1Char(' ')); + QString line; + while (stream.readLineInto(&line)) + parseNextLine(QStringRef(&line)); +} - // comment - if (line.startsWith(QLatin1Char(';'))) - continue; +/*! + \internal + Parses one line of the configuation file +*/ - if (line.startsWith(QLatin1Char('[')) && line.endsWith(QLatin1Char(']'))) { - // new section - _section = line.mid(1, line.size() - 2); - continue; - } +void QLoggingSettingsParser::parseNextLine(QStringRef line) +{ + // Remove whitespace at start and end of line: + line = line.trimmed(); + + // comment + if (line.startsWith(QLatin1Char(';'))) + return; + + if (line.startsWith(QLatin1Char('[')) && line.endsWith(QLatin1Char(']'))) { + // new section + auto sectionName = line.mid(1, line.size() - 2).trimmed(); + m_inRulesSection = sectionName.compare(QLatin1String("rules"), Qt::CaseInsensitive) == 0; + return; + } - if (_section.compare(QLatin1String("rules"), Qt::CaseInsensitive) == 0) { - int equalPos = line.indexOf(QLatin1Char('=')); - if (equalPos != -1) { - if (line.lastIndexOf(QLatin1Char('=')) == equalPos) { - const QStringRef pattern = line.leftRef(equalPos); - const QStringRef valueStr = line.midRef(equalPos + 1); - int value = -1; - if (valueStr == QLatin1String("true")) - value = 1; - else if (valueStr == QLatin1String("false")) - value = 0; - QLoggingRule rule(pattern, (value == 1)); - if (rule.flags != 0 && (value != -1)) - _rules.append(rule); - else - warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData()); - } else { + if (m_inRulesSection) { + int equalPos = line.indexOf(QLatin1Char('=')); + if (equalPos != -1) { + if (line.lastIndexOf(QLatin1Char('=')) == equalPos) { + const auto pattern = line.left(equalPos).trimmed(); + const auto valueStr = line.mid(equalPos + 1).trimmed(); + int value = -1; + if (valueStr == QLatin1String("true")) + value = 1; + else if (valueStr == QLatin1String("false")) + value = 0; + QLoggingRule rule(pattern, (value == 1)); + if (rule.flags != 0 && (value != -1)) + _rules.append(rule); + else warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData()); - } + } else { + warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData()); } } } @@ -286,7 +295,7 @@ void QLoggingRegistry::init() if (!rulesSrc.isEmpty()) { QTextStream stream(rulesSrc); QLoggingSettingsParser parser; - parser.setSection(QStringLiteral("Rules")); + parser.setImplicitRulesSection(true); parser.setContent(stream); er += parser.rules(); } @@ -350,7 +359,7 @@ void QLoggingRegistry::unregisterCategory(QLoggingCategory *cat) void QLoggingRegistry::setApiRules(const QString &content) { QLoggingSettingsParser parser; - parser.setSection(QStringLiteral("Rules")); + parser.setImplicitRulesSection(true); parser.setContent(content); if (qtLoggingDebug()) diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h index 23740c4955..69fc6ea4ec 100644 --- a/src/corelib/io/qloggingregistry_p.h +++ b/src/corelib/io/qloggingregistry_p.h @@ -93,7 +93,7 @@ Q_DECLARE_TYPEINFO(QLoggingRule, Q_MOVABLE_TYPE); class Q_AUTOTEST_EXPORT QLoggingSettingsParser { public: - void setSection(const QString §ion) { _section = section; } + void setImplicitRulesSection(bool inRulesSection) { m_inRulesSection = inRulesSection; } void setContent(const QString &content); void setContent(QTextStream &stream); @@ -101,7 +101,10 @@ public: QVector rules() const { return _rules; } private: - QString _section; + void parseNextLine(QStringRef line); + +private: + bool m_inRulesSection = false; QVector _rules; }; -- cgit v1.2.3 From eda7f6ea7863b80985f62b28fe99c1176bc54c77 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 6 Apr 2017 11:14:26 +0300 Subject: Don't hide critical info The developer should see what's wrong even on release builds. That code hides any mistakes we do in JNI which are pretty critical for developers because they can't see what's wrong with their code. e.g. QtAndroid::activity().callMethod("wrongMethodName") *silently* fails, which is so wrong! Change-Id: I8b6a24946dfef716fcd86ab9bba82666974e3991 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/corelib/kernel/qjni.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp index 41d55c8fde..60154328c2 100644 --- a/src/corelib/kernel/qjni.cpp +++ b/src/corelib/kernel/qjni.cpp @@ -64,9 +64,7 @@ static QString qt_convertJString(jstring string) static inline bool exceptionCheckAndClear(JNIEnv *env) { if (Q_UNLIKELY(env->ExceptionCheck())) { -#ifdef QT_DEBUG env->ExceptionDescribe(); -#endif // QT_DEBUG env->ExceptionClear(); return true; } -- cgit v1.2.3 From d5f62f7bc7895815546cd2f6be9605486907018d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 10 Apr 2017 08:37:08 -0700 Subject: Ask MS runtime to reload the timezone details if they've changed POSIX documents that localtime() ensures that tzset() has been called, but the wording could be understood to mean that it only needs to do so the first time. Anyway, we're sure that the MS runtime only gets the timezone information from the Control Panel once. That means Qt-based applications will not react to a change in the timezone. Attempt to do that by moving tzset() out of the #if, to apply to all operating systems. Task-number: QTBUG-60043 Change-Id: I6ab535fb61094af19fc1fffd14b413541fe5a64c Reviewed-by: Edward Welbourne --- src/corelib/tools/qdatetime.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index a4a7aabacb..bcdbc5af2a 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2287,10 +2287,11 @@ static bool qt_localtime(qint64 msecsSinceEpoch, QDate *localDate, QTime *localT tm local; bool valid = false; -#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) // localtime() is required to work as if tzset() was called before it. // localtime_r() does not have this requirement, so make an explicit call. + // The explicit call should also request the timezone info be re-parsed. qt_tzset(); +#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) // Use the reentrant version of localtime() where available // as is thread-safe and doesn't use a shared static data area tm *res = 0; -- cgit v1.2.3 From cd5c8e78c70cbc68109e43720da6e515124bb9ab Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Tue, 11 Apr 2017 09:11:31 -0700 Subject: QProcess: fix Unix build This fixes a regression introduced in ff19ebcc Task-number: QTBUG-60046 Change-Id: I47c357433b25f07011a7a3a64d3150591785b206 Reviewed-by: Ulf Hermann --- src/corelib/io/qprocess_unix.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 795229419c..b822417ddf 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -121,6 +121,10 @@ QT_BEGIN_NAMESPACE #if !defined(Q_OS_DARWIN) +QT_BEGIN_INCLUDE_NAMESPACE +extern char **environ; +QT_END_INCLUDE_NAMESPACE + QProcessEnvironment QProcessEnvironment::systemEnvironment() { QProcessEnvironment env; -- cgit v1.2.3 From e45516ea0d41f215cddf1a51efe15998c74817a9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 11 Apr 2017 14:38:47 -0700 Subject: QSysInfo: Bring back suppression of ICC warning #1478 Turns out that different versions of ICC use different warning numbers. The Linux and Windows compilers emit 1786, but the macOS one emits 1478. Don't ask me why. Change-Id: I523b0abacd5148b2bf08fffd14b475a4c4d89ba1 Reviewed-by: Jake Petroules --- src/corelib/global/qsysinfo.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/corelib') diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h index ff0a784ace..f443ab4b93 100644 --- a/src/corelib/global/qsysinfo.h +++ b/src/corelib/global/qsysinfo.h @@ -213,6 +213,7 @@ public: QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations") +QT_WARNING_DISABLE_INTEL(1478) QT_WARNING_DISABLE_INTEL(1786) QT_WARNING_DISABLE_MSVC(4996) #if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) -- cgit v1.2.3 From cdc5f47aeba94ba083a81dc681a09a351809e528 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 5 Apr 2017 21:11:12 -0700 Subject: Restore compatibility with Qt 5.7.0 and 5.6.1 QSysInfo::productType() returned "osx" for all versions of macOS, even 10.12. Change 3e2bde35786 was incorrect. [ChangeLog][Important Behavior Changes] QSysInfo::productType() and QFileSelector behavior on macOS was restored to match what Qt used to return in version 5.7.0 and earlier. The behavior found in Qt 5.6.2, 5.7.1 and 5.8.0 is removed. [ChangeLog][Future Compatibility Notice] The identifiers that QSysInfo::productType() and QFileSelector will use to identify macOS systems will change in Qt 6.0 to match the Apple naming guidelines which will be current then. Task-number: QTBUG-59849 Change-Id: Ib0e40a7a3ebc44329f23fffd14b2b39392210c4f Reviewed-by: Jake Petroules --- src/corelib/global/qglobal.cpp | 20 ++++++++++++-------- src/corelib/io/qfileselector.cpp | 10 +++++----- 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 6b3cb502e5..9a779305d2 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2652,12 +2652,14 @@ QString QSysInfo::kernelVersion() to determine the distribution name and returns that. If determining the distribution name failed, it returns "unknown". - \b{Darwin, \macos, iOS, tvOS, and watchOS note}: this function returns - "macos" for \macos systems, "ios" for iOS systems, "tvos" for tvOS systems, - "watchos" for watchOS systems, and "darwin" in case the system could not - be determined. + \b{\macos note}: this function returns "osx" for all \macos systems, + regardless of Apple naming convention. The returned string will be updated + for Qt 6. Note that this function erroneously returned "macos" for \macos + 10.12 in Qt versions 5.6.2, 5.7.1, and 5.8.0. - \b{OS X note}: this function returns "osx" for versions of \macos prior to 10.12. + \b{Darwin, iOS, tvOS, and watchOS note}: this function returns "ios" for + iOS systems, "tvos" for tvOS systems, "watchos" for watchOS systems, and + "darwin" in case the system could not be determined. \b{FreeBSD note}: this function returns "debian" for Debian/kFreeBSD and "unknown" otherwise. @@ -2692,10 +2694,12 @@ QString QSysInfo::productType() #elif defined(Q_OS_WATCHOS) return QStringLiteral("watchos"); #elif defined(Q_OS_MACOS) - const QAppleOperatingSystemVersion version = qt_apple_os_version(); - if (version.major == 10 && version.minor < 12) - return QStringLiteral("osx"); + // ### Qt6: remove fallback +# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) return QStringLiteral("macos"); +# else + return QStringLiteral("osx"); +# endif #elif defined(Q_OS_DARWIN) return QStringLiteral("darwin"); diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp index 920281cef7..22995db07d 100644 --- a/src/corelib/io/qfileselector.cpp +++ b/src/corelib/io/qfileselector.cpp @@ -366,6 +366,7 @@ void QFileSelectorPrivate::updateSelectors() QStringList QFileSelectorPrivate::platformSelectors() { // similar, but not identical to QSysInfo::osType + // ### Qt6: remove macOS fallbacks to "mac" and the future compatibility QStringList ret; #if defined(Q_OS_WIN) // can't fall back to QSysInfo because we need both "winphone" and "winrt" for the Windows Phone case @@ -387,12 +388,11 @@ QStringList QFileSelectorPrivate::platformSelectors() # endif # endif QString productName = QSysInfo::productType(); -# ifdef Q_OS_MACOS - if (productName != QLatin1String("osx")) - ret << QStringLiteral("osx"); // compatibility -# endif if (productName != QLatin1String("unknown")) - ret << productName; // "opensuse", "fedora", "macos", "ios", "android" + ret << productName; // "opensuse", "fedora", "osx", "ios", "android" +# if defined(Q_OS_MACOS) + ret << QStringLiteral("macos"); // future compatibility +# endif #endif return ret; } -- cgit v1.2.3 From 11ed95ac9c12ee2b20b5c6f6be68d0b6387c0e70 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 30 Mar 2017 19:13:58 +0200 Subject: Improve QStringBuilder docs - Mention you can build QByteArrays, too - Nicer list of types that can be used, separate for QByteArray and QString Change-Id: Ia91445f0cb4872bab12a55f4812c283e9c38dba4 Reviewed-by: Edward Welbourne Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/tools/qstringbuilder.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp index de12de19cb..70152a9202 100644 --- a/src/corelib/tools/qstringbuilder.cpp +++ b/src/corelib/tools/qstringbuilder.cpp @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE \reentrant \since 4.6 - \brief The QStringBuilder class is a template class that provides a facility to build up QStrings from smaller chunks. + \brief The QStringBuilder class is a template class that provides a facility to build up QStrings and QByteArrays from smaller chunks. \ingroup tools \ingroup shared @@ -58,22 +58,34 @@ QT_BEGIN_NAMESPACE To build a QString by multiple concatenations, QString::operator+() - is typically used. This causes \e{n - 1} reallocations when building - a string from \e{n} chunks. + is typically used. This causes \e{n - 1} allocations when building + a string from \e{n} chunks. The same is true for QByteArray. QStringBuilder uses expression templates to collect the individual chunks, compute the total size, allocate the required amount of - memory for the final QString object, and copy the chunks into the + memory for the final string object, and copy the chunks into the allocated memory. The QStringBuilder class is not to be used explicitly in user code. Instances of the class are created as return values of the - operator%() function, acting on objects of type QString, - QLatin1String, QStringRef, QChar, QCharRef, - QLatin1Char, and \c char. + operator%() function, acting on objects of the following types: + + For building QStrings: + + \li QString, QStringRef, + \li QChar, QCharRef, QLatin1Char, + \li QLatin1String, + \li QByteArray, \c char, \c{const char[]}. + + The types in the last list point are only available when + QT_NO_CAST_FROM_ASCII is not defined. + + For building QByteArrays: + + \li QByteArray, \c char, \c{const char[]}. Concatenating strings with operator%() generally yields better - performance then using \c QString::operator+() on the same chunks + performance than using \c QString::operator+() on the same chunks if there are three or more of them, and performs equally well in other cases. -- cgit v1.2.3 From feaaca456b1b9f5f6ba84f0aa3cb7e93dfb862cf Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 12 Apr 2017 14:12:10 +0100 Subject: QLocale: do not test for Q_OS_MAC before including qglobal.h Found by clazy. Change-Id: I66b6698c309720891db83626e18c5e1baca19091 Reviewed-by: Thiago Macieira --- src/corelib/tools/qlocale.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index c183224c82..c23c84534f 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -38,13 +38,13 @@ ** ****************************************************************************/ +#include "qglobal.h" + #if !defined(QWS) && defined(Q_OS_MAC) # include "private/qcore_mac_p.h" # include #endif -#include "qglobal.h" - #include "qplatformdefs.h" #include "qdatastream.h" -- cgit v1.2.3 From e1c8451ffeeaa82f29aa2519addfa377f678ed9e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 9 Apr 2017 08:41:51 +0200 Subject: =?UTF-8?q?QVariant:=20implement=20QByteArray=20=E2=86=94=20QUuid?= =?UTF-8?q?=20conversion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Seems like an obvious omission. [ChangeLog][QtCore][QVariant] Can now convert QUuid to and from QByteArray, not just QString. Change-Id: Ib56ae86ca0c27adaf1e095b6b85e64fe64ea8d18 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qvariant.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index bca3ac9582..e636c6fe52 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -649,6 +649,9 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QVariant::Bool: *ba = QByteArray(d->data.b ? "true" : "false"); break; + case QVariant::Uuid: + *ba = v_cast(d)->toByteArray(); + break; default: #ifndef QT_NO_QOBJECT { @@ -916,6 +919,9 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QVariant::String: *static_cast(result) = QUuid(*v_cast(d)); break; + case QVariant::ByteArray: + *static_cast(result) = QUuid(*v_cast(d)); + break; default: return false; } @@ -2527,7 +2533,7 @@ QRegularExpression QVariant::toRegularExpression() const \since 5.0 Returns the variant as a QUuid if the variant has type() - \l QMetaType::QUuid or \l QMetaType::QString; + \l QMetaType::QUuid, \l QMetaType::QByteArray or \l QMetaType::QString; otherwise returns a default-constructed QUuid. \sa canConvert(), convert() @@ -2875,7 +2881,8 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = /*QStringList*/ 1 << QVariant::List | 1 << QVariant::String, /*QByteArray*/ 1 << QVariant::String | 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::Bool - | 1 << QVariant::Double | 1 << QVariant::LongLong | 1 << QVariant::ULongLong, + | 1 << QVariant::Double | 1 << QVariant::LongLong | 1 << QVariant::ULongLong + | 1 << QVariant::Uuid, /*QBitArray*/ 0, @@ -2911,7 +2918,7 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = /*QEasingCurve*/ 0, -/*QUuid*/ 1 << QVariant::String +/*QUuid*/ 1 << QVariant::String | 1 << QVariant::ByteArray, }; static const size_t qCanConvertMatrixMaximumTargetType = 8 * sizeof(*qCanConvertMatrix); @@ -2966,7 +2973,7 @@ static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject) \l QMetaType::UInt, \l QMetaType::ULongLong \row \li \l QMetaType::QByteArray \li \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, - \l QMetaType::UInt, \l QMetaType::ULongLong + \l QMetaType::UInt, \l QMetaType::ULongLong, \l QMetaType::QUuid \row \li \l QMetaType::QChar \li \l QMetaType::Bool, \l QMetaType::Int, \l QMetaType::UInt, \l QMetaType::LongLong, \l QMetaType::ULongLong \row \li \l QMetaType::QColor \li \l QMetaType::QString @@ -3006,7 +3013,7 @@ static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject) \row \li \l QMetaType::ULongLong \li \l QMetaType::Bool, \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt - \row \li \l QMetaType::QUuid \li \l QMetaType::QString + \row \li \l QMetaType::QUuid \li \l QMetaType::QByteArray, \l QMetaType::QString \endtable A QVariant containing a pointer to a type derived from QObject will also return true for this -- cgit v1.2.3 From 89c8dd30a12bbe44f4661a1b4dd5aec079e41cae Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 13 Apr 2017 15:54:15 -0700 Subject: qfloat16: Fix GCC warning about use of old-style cast _mm_cvtps_ph is usually defined as a macro: qfloat16.h:122:37: error: use of old-style cast [-Werror=old-style-cast] Change-Id: Icd0e0d4b27cb4e5eb892fffd14b516ec47826c0c Reviewed-by: Ville Voutilainen Reviewed-by: Marc Mutz --- src/corelib/global/qfloat16.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/corelib') diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index 05b88e0e92..3b54719f4f 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -115,6 +115,7 @@ inline int qIntCast(qfloat16 f) Q_DECL_NOTHROW QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wc99-extensions") +QT_WARNING_DISABLE_GCC("-Wold-style-cast") inline qfloat16::qfloat16(float f) Q_DECL_NOTHROW { #if defined(QT_COMPILER_SUPPORTS_F16C) && (defined(__F16C__) || defined(__AVX2__)) -- cgit v1.2.3 From 2814744a739dfab123448f92e2009c34a82976a3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 15 Apr 2017 15:56:47 -0700 Subject: Update the Clang usual versions for Apple's build Change-Id: Id69a70a52573241e1b6a05bd62a3fd01a8e78550 Reviewed-by: Jake Petroules --- src/corelib/global/qcompilerdetection.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index fcfe020509..3ceb4edab1 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -172,7 +172,11 @@ /* Clang also masquerades as GCC */ # if defined(__apple_build_version__) # /* http://en.wikipedia.org/wiki/Xcode#Toolchain_Versions */ -# if __apple_build_version__ >= 7000053 +# if __apple_build_version__ >= 8020041 +# define Q_CC_CLANG 309 +# elif __apple_build_version__ >= 8000038 +# define Q_CC_CLANG 308 +# elif __apple_build_version__ >= 7000053 # define Q_CC_CLANG 306 # elif __apple_build_version__ >= 6000051 # define Q_CC_CLANG 305 -- cgit v1.2.3 From 3bea9450e90a6c8db1554faa5b467186e63b31a0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 31 Oct 2016 16:07:53 -0700 Subject: Update the Clang support for SIMD code generation Clang 3.8 has support for __attribute__((target(xxx))) and its SIMD headers can be included unconditionally. Change-Id: Ic15b7ff417c8412893e5fffd14b5b42b950b48d7 Reviewed-by: Allan Sandfeld Jensen --- src/corelib/tools/qsimd_p.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index d5d887598e..28253b3ae9 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -166,10 +166,11 @@ # define __MIPS_DSPR2__ # endif #elif (defined(Q_CC_INTEL) || defined(Q_CC_MSVC) \ - || (defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && (__GNUC__-0) * 100 + (__GNUC_MINOR__-0) >= 409)) \ + || (defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && Q_CC_GNU >= 409) \ + || (defined(Q_CC_CLANG) && Q_CC_CLANG >= 308)) \ && !defined(QT_BOOTSTRAPPED) # define QT_COMPILER_SUPPORTS_SIMD_ALWAYS -# define QT_COMPILER_SUPPORTS_HERE(x) (__ ## x ## __) || QT_COMPILER_SUPPORTS(x) +# define QT_COMPILER_SUPPORTS_HERE(x) ((__ ## x ## __) || QT_COMPILER_SUPPORTS(x)) # if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) /* GCC requires attributes for a function */ # define QT_FUNCTION_TARGET(x) __attribute__((__target__(QT_FUNCTION_TARGET_STRING_ ## x))) -- cgit v1.2.3 From d1210281e41008ce2e3510aa5cfb3ebea1c57734 Mon Sep 17 00:00:00 2001 From: Ihor Dutchak Date: Mon, 17 Apr 2017 00:35:38 +0300 Subject: Fix undefined behavior in QSharedPointer::create() Initialize a deleter for a new object, created by QSharedPointer::create(), only after the object is actually constructed. [ChangeLog][QtCore][QSharedPointer] Fixed undefined behavior when creating an object with QSharedPointer::create() and its conscructor throws an exception. Task-number: QTBUG-49824 Change-Id: I07f77a78ff468d9b45b8ef133278e8cdd96a0647 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/tools/qsharedpointer_impl.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 5738413bfb..373fc3a662 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -260,6 +260,7 @@ namespace QtSharedPointer { internalSafetyCheckRemove(self); deleter(self); } + static void noDeleter(ExternalRefCountData *) { } static inline ExternalRefCountData *create(T **ptr, DestroyerFn destroy) { @@ -433,11 +434,13 @@ public: # else typename Private::DestroyerFn destroy = &Private::deleter; # endif + typename Private::DestroyerFn noDestroy = &Private::noDeleter; QSharedPointer result(Qt::Uninitialized); - result.d = Private::create(&result.value, destroy); + result.d = Private::create(&result.value, noDestroy); // now initialize the data new (result.data()) T(std::forward(arguments)...); + result.d->destroyer = destroy; result.d->setQObjectShared(result.value, true); # ifdef QT_SHAREDPOINTER_TRACK_POINTERS internalSafetyCheckAdd(result.d, result.value); -- cgit v1.2.3 From 285789781cd2893302edfc004d8fc07fc06b1148 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 16 Apr 2017 20:29:39 -0700 Subject: icc: thread_local in macOS is working since 10.7 Change-Id: I0e1a09998253489388abfffd14b611b1403a0c9f Reviewed-by: Jake Petroules --- src/corelib/global/qcompilerdetection.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 3ceb4edab1..5497b9e14a 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -632,10 +632,7 @@ # define Q_COMPILER_ALIGNAS # define Q_COMPILER_ALIGNOF # define Q_COMPILER_INHERITING_CONSTRUCTORS -# ifndef Q_OS_OSX -// C++11 thread_local is broken on OS X (Clang doesn't support it either) -# define Q_COMPILER_THREAD_LOCAL -# endif +# define Q_COMPILER_THREAD_LOCAL # define Q_COMPILER_UDL # endif # ifdef _MSC_VER -- cgit v1.2.3 From 47cc9e23a313d67a4a3107242f205d2473842021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 14 Apr 2017 15:13:28 +0200 Subject: Initialize QLoggingRegistry rules on first use, not qApp construction Allows categorized logging before QCoreApplication has been created, which otherwise would silently fail to output anything because the category would never be enabled, despite QT_LOGGING_RULES being set. Change-Id: Ia733105c5b6f28e22af511ced5271e45782da12b Reviewed-by: Thiago Macieira --- src/corelib/io/qloggingregistry.cpp | 1 + src/corelib/io/qloggingregistry_p.h | 3 +-- src/corelib/kernel/qcoreapplication.cpp | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index 47fb1fb6b8..9a5c923323 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -255,6 +255,7 @@ void QLoggingSettingsParser::parseNextLine(QStringRef line) QLoggingRegistry::QLoggingRegistry() : categoryFilter(defaultCategoryFilter) { + init(); } static bool qtLoggingDebug() diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h index 69fc6ea4ec..768f3b4a91 100644 --- a/src/corelib/io/qloggingregistry_p.h +++ b/src/corelib/io/qloggingregistry_p.h @@ -113,8 +113,6 @@ class Q_AUTOTEST_EXPORT QLoggingRegistry public: QLoggingRegistry(); - void init(); - void registerCategory(QLoggingCategory *category, QtMsgType enableForLevel); void unregisterCategory(QLoggingCategory *category); @@ -126,6 +124,7 @@ public: static QLoggingRegistry *instance(); private: + void init(); void updateRules(); static void defaultCategoryFilter(QLoggingCategory *category); diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index e4b1562b8b..0216baa6c3 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -771,8 +771,6 @@ void QCoreApplicationPrivate::init() if (!coreappdata()->applicationVersionSet) coreappdata()->applicationVersion = appVersion(); - QLoggingRegistry::instance()->init(); - #if QT_CONFIG(library) // Reset the lib paths, so that they will be recomputed, taking the availability of argv[0] // into account. If necessary, recompute right away and replay the manual changes on top of the -- cgit v1.2.3 From 924b02aecbce4843ff9d0a7d1d15f1eb154f5d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 19 Apr 2017 15:54:47 +0200 Subject: Revert "Initialize QLoggingRegistry rules on first use, not qApp construction" This reverts commit 47cc9e23a313d67a4a3107242f205d2473842021. We use QCoreApplication::applicationDirPath in the logging initialization to find a possible qtlogging.ini file. Because QCoreApplication::applicationDirPath requires a QCoreApplication instance this leads to a qWarning, which in turn leads to a recursive call to the logging initialization, and in turn to a recursive mutex deadlock. Task-number: QTCREATORBUG-18031 Change-Id: Ic75e1e8c062eb647991725378489bf87c9648cca Reviewed-by: Friedemann Kleint --- src/corelib/io/qloggingregistry.cpp | 1 - src/corelib/io/qloggingregistry_p.h | 3 ++- src/corelib/kernel/qcoreapplication.cpp | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index 9a5c923323..47fb1fb6b8 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -255,7 +255,6 @@ void QLoggingSettingsParser::parseNextLine(QStringRef line) QLoggingRegistry::QLoggingRegistry() : categoryFilter(defaultCategoryFilter) { - init(); } static bool qtLoggingDebug() diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h index 768f3b4a91..69fc6ea4ec 100644 --- a/src/corelib/io/qloggingregistry_p.h +++ b/src/corelib/io/qloggingregistry_p.h @@ -113,6 +113,8 @@ class Q_AUTOTEST_EXPORT QLoggingRegistry public: QLoggingRegistry(); + void init(); + void registerCategory(QLoggingCategory *category, QtMsgType enableForLevel); void unregisterCategory(QLoggingCategory *category); @@ -124,7 +126,6 @@ public: static QLoggingRegistry *instance(); private: - void init(); void updateRules(); static void defaultCategoryFilter(QLoggingCategory *category); diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 0216baa6c3..e4b1562b8b 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -771,6 +771,8 @@ void QCoreApplicationPrivate::init() if (!coreappdata()->applicationVersionSet) coreappdata()->applicationVersion = appVersion(); + QLoggingRegistry::instance()->init(); + #if QT_CONFIG(library) // Reset the lib paths, so that they will be recomputed, taking the availability of argv[0] // into account. If necessary, recompute right away and replay the manual changes on top of the -- cgit v1.2.3 From 870964895baadd013570d626d9e8ebc9d57fee94 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Apr 2017 15:30:44 -0700 Subject: Don't disable Q_REQUIRED_RESULT with Clang and ICC They're not affected by the GCC bug noted in the comment. Change-Id: I7814054a102a407d876ffffd14b69e8a8e2527f1 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/tools/qbytearray.h | 2 +- src/corelib/tools/qstring.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index 06a50e5990..a0e5c5478b 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -243,7 +243,7 @@ public: void chop(int n); #if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) && !defined(Q_CLANG_QDOC) -# if defined(Q_CC_GNU) +# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) // required due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61941 # pragma push_macro("Q_REQUIRED_RESULT") # undef Q_REQUIRED_RESULT diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 1bd436c387..09a3bcb521 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -383,7 +383,7 @@ public: QString rightJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const Q_REQUIRED_RESULT; #if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) && !defined(Q_CLANG_QDOC) -# if defined(Q_CC_GNU) +# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) // required due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61941 # pragma push_macro("Q_REQUIRED_RESULT") # undef Q_REQUIRED_RESULT -- cgit v1.2.3 From 3dcc075f4a5efce348a6fa00cf5a0adef97b1089 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Apr 2017 16:22:46 -0700 Subject: Move Q_REQUIRED_RESULT to its correct position That's before the return type or static, inline, constexpr or such keywords (if any). Perl Script: s/^(\s+)(.*) Q_REQUIRED_RESULT(;)?(\s*\/\/.*)?$/\1Q_REQUIRED_RESULT \2\3\4/ Change-Id: I7814054a102a407d876ffffd14b6a16182f159e2 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/global/qfloat16.h | 16 +-- src/corelib/global/qglobal.h | 18 +-- src/corelib/io/qurl.h | 4 +- src/corelib/thread/qthreadpool.h | 2 +- src/corelib/tools/qarraydata.h | 14 +-- src/corelib/tools/qarraydatapointer.h | 2 +- src/corelib/tools/qbytearray.h | 56 ++++----- src/corelib/tools/qdatetime.h | 20 ++-- src/corelib/tools/qline.h | 18 +-- src/corelib/tools/qpoint.h | 6 +- src/corelib/tools/qrect.h | 46 ++++---- src/corelib/tools/qsize.h | 26 ++--- src/corelib/tools/qstring.h | 202 ++++++++++++++++----------------- src/corelib/tools/qtimezoneprivate_p.h | 4 +- src/corelib/tools/qversionnumber.h | 28 ++--- 15 files changed, 227 insertions(+), 235 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index 3b54719f4f..b0272c51c3 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -81,18 +81,18 @@ private: Q_DECLARE_TYPEINFO(qfloat16, Q_PRIMITIVE_TYPE); -Q_CORE_EXPORT Q_REQUIRED_RESULT bool qIsInf(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h -Q_CORE_EXPORT Q_REQUIRED_RESULT bool qIsNaN(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h -Q_CORE_EXPORT Q_REQUIRED_RESULT bool qIsFinite(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h +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 +Q_REQUIRED_RESULT Q_CORE_EXPORT bool qIsFinite(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h // The remainder of these utility functions complement qglobal.h -inline Q_REQUIRED_RESULT int qRound(qfloat16 d) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline int qRound(qfloat16 d) Q_DECL_NOTHROW { return qRound(static_cast(d)); } -inline Q_REQUIRED_RESULT qint64 qRound64(qfloat16 d) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline qint64 qRound64(qfloat16 d) Q_DECL_NOTHROW { return qRound64(static_cast(d)); } -inline Q_REQUIRED_RESULT bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) Q_DECL_NOTHROW { float f1 = static_cast(p1); float f2 = static_cast(p2); @@ -105,7 +105,7 @@ inline Q_REQUIRED_RESULT bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) Q_DECL_NOT return (qAbs(f1 - f2) * 102.5f <= qMin(qAbs(f1), qAbs(f2))); } -inline Q_REQUIRED_RESULT bool qIsNull(qfloat16 f) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline bool qIsNull(qfloat16 f) Q_DECL_NOTHROW { return (f.b16 & static_cast(0x7fff)) == 0; } @@ -247,7 +247,7 @@ QT_WARNING_POP /*! \internal */ -inline Q_REQUIRED_RESULT bool qFuzzyIsNull(qfloat16 f) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline bool qFuzzyIsNull(qfloat16 f) Q_DECL_NOTHROW { return qAbs(static_cast(f)) <= 0.001f; } diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 9ac29acd16..d4d20fd54a 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -770,26 +770,22 @@ typedef void (*QFunctionPointer)(); # define Q_UNIMPLEMENTED() qWarning("Unimplemented code.") #endif -Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2) Q_REQUIRED_RESULT Q_DECL_UNUSED; -Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2) +Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyCompare(double p1, double p2) { return (qAbs(p1 - p2) * 1000000000000. <= qMin(qAbs(p1), qAbs(p2))); } -Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2) Q_REQUIRED_RESULT Q_DECL_UNUSED; -Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2) +Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyCompare(float p1, float p2) { return (qAbs(p1 - p2) * 100000.f <= qMin(qAbs(p1), qAbs(p2))); } -Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d) Q_REQUIRED_RESULT Q_DECL_UNUSED; -Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d) +Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyIsNull(double d) { return qAbs(d) <= 0.000000000001; } -Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f) Q_REQUIRED_RESULT Q_DECL_UNUSED; -Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f) +Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyIsNull(float f) { return qAbs(f) <= 0.00001f; } @@ -799,8 +795,7 @@ Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f) check whether the actual value is 0 or close to 0, but whether it is binary 0, disregarding sign. */ -static inline bool qIsNull(double d) Q_REQUIRED_RESULT Q_DECL_UNUSED; -static inline bool qIsNull(double d) +Q_REQUIRED_RESULT static inline Q_DECL_UNUSED bool qIsNull(double d) { union U { double d; @@ -816,8 +811,7 @@ static inline bool qIsNull(double d) check whether the actual value is 0 or close to 0, but whether it is binary 0, disregarding sign. */ -static inline bool qIsNull(float f) Q_REQUIRED_RESULT Q_DECL_UNUSED; -static inline bool qIsNull(float f) +Q_REQUIRED_RESULT static inline Q_DECL_UNUSED bool qIsNull(float f) { union U { float f; diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index c16825a033..0bb8707ff9 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -196,7 +196,7 @@ public: QString url(FormattingOptions options = FormattingOptions(PrettyDecoded)) const; QString toString(FormattingOptions options = FormattingOptions(PrettyDecoded)) const; QString toDisplayString(FormattingOptions options = FormattingOptions(PrettyDecoded)) const; - QUrl adjusted(FormattingOptions options) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QUrl adjusted(FormattingOptions options) const; QByteArray toEncoded(FormattingOptions options = FullyEncoded) const; static QUrl fromEncoded(const QByteArray &url, ParsingMode mode = TolerantMode); @@ -255,7 +255,7 @@ public: QString fragment(ComponentFormattingOptions options = PrettyDecoded) const; void setFragment(const QString &fragment, ParsingMode mode = TolerantMode); - QUrl resolved(const QUrl &relative) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QUrl resolved(const QUrl &relative) const; bool isRelative() const; bool isParentOf(const QUrl &url) const; diff --git a/src/corelib/thread/qthreadpool.h b/src/corelib/thread/qthreadpool.h index 74a8c28fc8..09b7f96f48 100644 --- a/src/corelib/thread/qthreadpool.h +++ b/src/corelib/thread/qthreadpool.h @@ -88,7 +88,7 @@ public: QT_DEPRECATED_X("use tryTake(), but note the different deletion rules") void cancel(QRunnable *runnable); #endif - bool tryTake(QRunnable *runnable) Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT bool tryTake(QRunnable *runnable); }; QT_END_NAMESPACE diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index bc20932cca..88f0cfb0ea 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -112,12 +112,10 @@ struct Q_CORE_EXPORT QArrayData return result; } - static QArrayData *allocate(size_t objectSize, size_t alignment, - size_t capacity, AllocationOptions options = Default) - Q_DECL_NOTHROW Q_REQUIRED_RESULT; - static QArrayData *reallocateUnaligned(QArrayData *data, size_t objectSize, - size_t newCapacity, AllocationOptions newOptions = Default) - Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT static QArrayData *allocate(size_t objectSize, size_t alignment, + size_t capacity, AllocationOptions options = Default) Q_DECL_NOTHROW; + Q_REQUIRED_RESULT static QArrayData *reallocateUnaligned(QArrayData *data, size_t objectSize, + size_t newCapacity, AllocationOptions newOptions = Default) Q_DECL_NOTHROW; static void deallocate(QArrayData *data, size_t objectSize, size_t alignment) Q_DECL_NOTHROW; @@ -217,8 +215,8 @@ struct QTypedArrayData class AlignmentDummy { QArrayData header; T data; }; - static QTypedArrayData *allocate(size_t capacity, - AllocationOptions options = Default) Q_REQUIRED_RESULT + Q_REQUIRED_RESULT static QTypedArrayData *allocate(size_t capacity, + AllocationOptions options = Default) { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); return static_cast(QArrayData::allocate(sizeof(T), diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index b97dde5a61..51cfa6e849 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -174,7 +174,7 @@ public: } private: - Data *clone(QArrayData::AllocationOptions options) const Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Data *clone(QArrayData::AllocationOptions options) const { Data *x = Data::allocate(d->detachCapacity(d->size), options); Q_CHECK_PTR(x); diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index a0e5c5478b..03bb9b5747 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -227,9 +227,9 @@ public: int count(const char *a) const; int count(const QByteArray &a) const; - QByteArray left(int len) const Q_REQUIRED_RESULT; - QByteArray right(int len) const Q_REQUIRED_RESULT; - QByteArray mid(int index, int len = -1) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QByteArray left(int len) const; + Q_REQUIRED_RESULT QByteArray right(int len) const; + Q_REQUIRED_RESULT QByteArray mid(int index, int len = -1) const; bool startsWith(const QByteArray &a) const; bool startsWith(char c) const; @@ -250,34 +250,34 @@ public: # define Q_REQUIRED_RESULT # define Q_REQUIRED_RESULT_pushed # endif - Q_ALWAYS_INLINE QByteArray toLower() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray toLower() const & { return toLower_helper(*this); } - Q_ALWAYS_INLINE QByteArray toLower() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray toLower() && { return toLower_helper(*this); } - Q_ALWAYS_INLINE QByteArray toUpper() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray toUpper() const & { return toUpper_helper(*this); } - Q_ALWAYS_INLINE QByteArray toUpper() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray toUpper() && { return toUpper_helper(*this); } - Q_ALWAYS_INLINE QByteArray trimmed() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray trimmed() const & { return trimmed_helper(*this); } - Q_ALWAYS_INLINE QByteArray trimmed() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray trimmed() && { return trimmed_helper(*this); } - Q_ALWAYS_INLINE QByteArray simplified() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray simplified() const & { return simplified_helper(*this); } - Q_ALWAYS_INLINE QByteArray simplified() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray simplified() && { return simplified_helper(*this); } # ifdef Q_REQUIRED_RESULT_pushed # pragma pop_macro("Q_REQUIRED_RESULT") # endif #else - QByteArray toLower() const Q_REQUIRED_RESULT; - QByteArray toUpper() const Q_REQUIRED_RESULT; - QByteArray trimmed() const Q_REQUIRED_RESULT; - QByteArray simplified() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QByteArray toLower() const; + Q_REQUIRED_RESULT QByteArray toUpper() const; + Q_REQUIRED_RESULT QByteArray trimmed() const; + Q_REQUIRED_RESULT QByteArray simplified() const; #endif - QByteArray leftJustified(int width, char fill = ' ', bool truncate = false) const Q_REQUIRED_RESULT; - QByteArray rightJustified(int width, char fill = ' ', bool truncate = false) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QByteArray leftJustified(int width, char fill = ' ', bool truncate = false) const; + Q_REQUIRED_RESULT QByteArray rightJustified(int width, char fill = ' ', bool truncate = false) const; QByteArray &prepend(char c); QByteArray &prepend(int count, char c); @@ -312,7 +312,7 @@ public: QList split(char sep) const; - QByteArray repeated(int times) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QByteArray repeated(int times) const; #ifndef QT_NO_CAST_TO_ASCII QT_ASCII_CAST_WARN QByteArray &append(const QString &s); @@ -362,16 +362,16 @@ public: QByteArray &setNum(double, char f = 'g', int prec = 6); QByteArray &setRawData(const char *a, uint n); // ### Qt 6: use an int - static QByteArray number(int, int base = 10) Q_REQUIRED_RESULT; - static QByteArray number(uint, int base = 10) Q_REQUIRED_RESULT; - static QByteArray number(qlonglong, int base = 10) Q_REQUIRED_RESULT; - static QByteArray number(qulonglong, int base = 10) Q_REQUIRED_RESULT; - static QByteArray number(double, char f = 'g', int prec = 6) Q_REQUIRED_RESULT; - static QByteArray fromRawData(const char *, int size) Q_REQUIRED_RESULT; - static QByteArray fromBase64(const QByteArray &base64, Base64Options options) Q_REQUIRED_RESULT; - static QByteArray fromBase64(const QByteArray &base64) Q_REQUIRED_RESULT; // ### Qt6 merge with previous - static QByteArray fromHex(const QByteArray &hexEncoded) Q_REQUIRED_RESULT; - static QByteArray fromPercentEncoding(const QByteArray &pctEncoded, char percent = '%') Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT static QByteArray number(int, int base = 10); + Q_REQUIRED_RESULT static QByteArray number(uint, int base = 10); + Q_REQUIRED_RESULT static QByteArray number(qlonglong, int base = 10); + Q_REQUIRED_RESULT static QByteArray number(qulonglong, int base = 10); + Q_REQUIRED_RESULT static QByteArray number(double, char f = 'g', int prec = 6); + Q_REQUIRED_RESULT static QByteArray fromRawData(const char *, int size); + Q_REQUIRED_RESULT static QByteArray fromBase64(const QByteArray &base64, Base64Options options); + Q_REQUIRED_RESULT static QByteArray fromBase64(const QByteArray &base64); // ### Qt6 merge with previous + Q_REQUIRED_RESULT static QByteArray fromHex(const QByteArray &hexEncoded); + Q_REQUIRED_RESULT static QByteArray fromPercentEncoding(const QByteArray &pctEncoded, char percent = '%'); #if defined(Q_OS_DARWIN) || defined(Q_QDOC) static QByteArray fromCFData(CFDataRef data); diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index c7f14ed40a..2518dc7301 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -103,9 +103,9 @@ QT_DEPRECATED inline bool setYMD(int y, int m, int d) #endif // < Qt 6 void getDate(int *year, int *month, int *day) const; - QDate addDays(qint64 days) const Q_REQUIRED_RESULT; - QDate addMonths(int months) const Q_REQUIRED_RESULT; - QDate addYears(int years) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QDate addDays(qint64 days) const; + Q_REQUIRED_RESULT QDate addMonths(int months) const; + Q_REQUIRED_RESULT QDate addYears(int years) const; qint64 daysTo(const QDate &) const; Q_DECL_CONSTEXPR bool operator==(const QDate &other) const { return jd == other.jd; } @@ -166,9 +166,9 @@ public: #endif bool setHMS(int h, int m, int s, int ms = 0); - QTime addSecs(int secs) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QTime addSecs(int secs) const; int secsTo(const QTime &) const; - QTime addMSecs(int ms) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QTime addMSecs(int ms) const; int msecsTo(const QTime &) const; Q_DECL_CONSTEXPR bool operator==(const QTime &other) const { return mds == other.mds; } @@ -297,11 +297,11 @@ public: QString toString(Qt::DateFormat f = Qt::TextDate) const; QString toString(const QString &format) const; #endif - QDateTime addDays(qint64 days) const Q_REQUIRED_RESULT; - QDateTime addMonths(int months) const Q_REQUIRED_RESULT; - QDateTime addYears(int years) const Q_REQUIRED_RESULT; - QDateTime addSecs(qint64 secs) const Q_REQUIRED_RESULT; - QDateTime addMSecs(qint64 msecs) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QDateTime addDays(qint64 days) const; + Q_REQUIRED_RESULT QDateTime addMonths(int months) const; + Q_REQUIRED_RESULT QDateTime addYears(int years) const; + Q_REQUIRED_RESULT QDateTime addSecs(qint64 secs) const; + Q_REQUIRED_RESULT QDateTime addMSecs(qint64 msecs) const; QDateTime toTimeSpec(Qt::TimeSpec spec) const; inline QDateTime toLocalTime() const { return toTimeSpec(Qt::LocalTime); } diff --git a/src/corelib/tools/qline.h b/src/corelib/tools/qline.h index 5b5ca3b4c8..6361c1af9f 100644 --- a/src/corelib/tools/qline.h +++ b/src/corelib/tools/qline.h @@ -73,10 +73,10 @@ public: inline void translate(const QPoint &p); inline void translate(int dx, int dy); - Q_DECL_CONSTEXPR inline QLine translated(const QPoint &p) const Q_REQUIRED_RESULT; - Q_DECL_CONSTEXPR inline QLine translated(int dx, int dy) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QLine translated(const QPoint &p) const; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QLine translated(int dx, int dy) const; - Q_DECL_CONSTEXPR inline QPoint center() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QPoint center() const; inline void setP1(const QPoint &p1); inline void setP2(const QPoint &p2); @@ -221,7 +221,7 @@ public: Q_DECL_CONSTEXPR inline QLineF(qreal x1, qreal y1, qreal x2, qreal y2); Q_DECL_CONSTEXPR inline QLineF(const QLine &line) : pt1(line.p1()), pt2(line.p2()) { } - static QLineF fromPolar(qreal length, qreal angle) Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT static QLineF fromPolar(qreal length, qreal angle); Q_DECL_CONSTEXPR bool isNull() const; @@ -245,8 +245,8 @@ public: qreal angleTo(const QLineF &l) const; - QLineF unitVector() const Q_REQUIRED_RESULT; - Q_DECL_CONSTEXPR inline QLineF normalVector() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QLineF unitVector() const; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QLineF normalVector() const; // ### Qt 6: rename intersects() or intersection() and rename IntersectType IntersectionType IntersectType intersect(const QLineF &l, QPointF *intersectionPoint) const; @@ -257,10 +257,10 @@ public: inline void translate(const QPointF &p); inline void translate(qreal dx, qreal dy); - Q_DECL_CONSTEXPR inline QLineF translated(const QPointF &p) const Q_REQUIRED_RESULT; - Q_DECL_CONSTEXPR inline QLineF translated(qreal dx, qreal dy) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QLineF translated(const QPointF &p) const; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QLineF translated(qreal dx, qreal dy) const; - Q_DECL_CONSTEXPR inline QPointF center() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QPointF center() const; inline void setP1(const QPointF &p1); inline void setP2(const QPointF &p2); diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h index 7b1004897a..0f3e0c3517 100644 --- a/src/corelib/tools/qpoint.h +++ b/src/corelib/tools/qpoint.h @@ -94,7 +94,7 @@ public: friend Q_DECL_CONSTEXPR inline const QPoint operator/(const QPoint &, qreal); #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - CGPoint toCGPoint() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT CGPoint toCGPoint() const Q_DECL_NOTHROW; #endif private: @@ -256,8 +256,8 @@ public: Q_DECL_CONSTEXPR QPoint toPoint() const; #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - static QPointF fromCGPoint(CGPoint point) Q_DECL_NOTHROW Q_REQUIRED_RESULT; - CGPoint toCGPoint() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT static QPointF fromCGPoint(CGPoint point) Q_DECL_NOTHROW; + Q_REQUIRED_RESULT CGPoint toCGPoint() const Q_DECL_NOTHROW; #endif private: diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h index 4030cccbd5..19ff87b420 100644 --- a/src/corelib/tools/qrect.h +++ b/src/corelib/tools/qrect.h @@ -70,7 +70,7 @@ public: Q_DECL_CONSTEXPR inline int top() const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline int right() const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline int bottom() const Q_DECL_NOTHROW; - QRect normalized() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QRect normalized() const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline int x() const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline int y() const Q_DECL_NOTHROW; @@ -104,9 +104,9 @@ public: Q_DECL_RELAXED_CONSTEXPR inline void translate(int dx, int dy) Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline void translate(const QPoint &p) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QRect translated(int dx, int dy) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - Q_DECL_CONSTEXPR inline QRect translated(const QPoint &p) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - Q_DECL_CONSTEXPR inline QRect transposed() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect translated(int dx, int dy) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect translated(const QPoint &p) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect transposed() const Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline void moveTo(int x, int t) Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline void moveTo(const QPoint &p) Q_DECL_NOTHROW; @@ -118,7 +118,7 @@ public: Q_DECL_RELAXED_CONSTEXPR inline void getCoords(int *x1, int *y1, int *x2, int *y2) const; Q_DECL_RELAXED_CONSTEXPR inline void adjust(int x1, int y1, int x2, int y2) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QRect adjusted(int x1, int y1, int x2, int y2) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect adjusted(int x1, int y1, int x2, int y2) const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline QSize size() const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline int width() const Q_DECL_NOTHROW; @@ -136,8 +136,8 @@ public: bool contains(const QPoint &p, bool proper=false) const Q_DECL_NOTHROW; inline bool contains(int x, int y) const Q_DECL_NOTHROW; inline bool contains(int x, int y, bool proper) const Q_DECL_NOTHROW; - inline QRect united(const QRect &other) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - inline QRect intersected(const QRect &other) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT inline QRect united(const QRect &other) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT inline QRect intersected(const QRect &other) const Q_DECL_NOTHROW; bool intersects(const QRect &r) const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline QRect marginsAdded(const QMargins &margins) const Q_DECL_NOTHROW; @@ -146,15 +146,15 @@ public: Q_DECL_RELAXED_CONSTEXPR inline QRect &operator-=(const QMargins &margins) Q_DECL_NOTHROW; #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED QRect unite(const QRect &r) const Q_DECL_NOTHROW Q_REQUIRED_RESULT { return united(r); } - QT_DEPRECATED QRect intersect(const QRect &r) const Q_DECL_NOTHROW Q_REQUIRED_RESULT { return intersected(r); } + Q_REQUIRED_RESULT QT_DEPRECATED QRect unite(const QRect &r) const Q_DECL_NOTHROW { return united(r); } + Q_REQUIRED_RESULT QT_DEPRECATED QRect intersect(const QRect &r) const Q_DECL_NOTHROW { return intersected(r); } #endif friend Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &) Q_DECL_NOTHROW; friend Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &) Q_DECL_NOTHROW; #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - CGRect toCGRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT CGRect toCGRect() const Q_DECL_NOTHROW; #endif private: @@ -520,7 +520,7 @@ public: Q_DECL_CONSTEXPR inline bool isNull() const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline bool isEmpty() const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline bool isValid() const Q_DECL_NOTHROW; - QRectF normalized() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QRectF normalized() const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline qreal left() const Q_DECL_NOTHROW { return xp; } Q_DECL_CONSTEXPR inline qreal top() const Q_DECL_NOTHROW { return yp; } @@ -560,10 +560,10 @@ public: Q_DECL_RELAXED_CONSTEXPR inline void translate(qreal dx, qreal dy) Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline void translate(const QPointF &p) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QRectF translated(qreal dx, qreal dy) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - Q_DECL_CONSTEXPR inline QRectF translated(const QPointF &p) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF translated(qreal dx, qreal dy) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF translated(const QPointF &p) const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QRectF transposed() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF transposed() const Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline void moveTo(qreal x, qreal y) Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline void moveTo(const QPointF &p) Q_DECL_NOTHROW; @@ -575,7 +575,7 @@ public: Q_DECL_RELAXED_CONSTEXPR inline void getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const; Q_DECL_RELAXED_CONSTEXPR inline void adjust(qreal x1, qreal y1, qreal x2, qreal y2) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline QSizeF size() const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline qreal width() const Q_DECL_NOTHROW; @@ -592,8 +592,8 @@ public: bool contains(const QRectF &r) const Q_DECL_NOTHROW; bool contains(const QPointF &p) const Q_DECL_NOTHROW; inline bool contains(qreal x, qreal y) const Q_DECL_NOTHROW; - inline QRectF united(const QRectF &other) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - inline QRectF intersected(const QRectF &other) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT inline QRectF united(const QRectF &other) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT inline QRectF intersected(const QRectF &other) const Q_DECL_NOTHROW; bool intersects(const QRectF &r) const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline QRectF marginsAdded(const QMarginsF &margins) const Q_DECL_NOTHROW; @@ -602,19 +602,19 @@ public: Q_DECL_RELAXED_CONSTEXPR inline QRectF &operator-=(const QMarginsF &margins) Q_DECL_NOTHROW; #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED QRectF unite(const QRectF &r) const Q_DECL_NOTHROW Q_REQUIRED_RESULT { return united(r); } - QT_DEPRECATED QRectF intersect(const QRectF &r) const Q_DECL_NOTHROW Q_REQUIRED_RESULT { return intersected(r); } + Q_REQUIRED_RESULT QT_DEPRECATED QRectF unite(const QRectF &r) const Q_DECL_NOTHROW { return united(r); } + Q_REQUIRED_RESULT QT_DEPRECATED QRectF intersect(const QRectF &r) const Q_DECL_NOTHROW { return intersected(r); } #endif friend Q_DECL_CONSTEXPR inline bool operator==(const QRectF &, const QRectF &) Q_DECL_NOTHROW; friend Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &, const QRectF &) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QRect toRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - QRect toAlignedRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect toRect() const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT QRect toAlignedRect() const Q_DECL_NOTHROW; #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - static QRectF fromCGRect(CGRect rect) Q_DECL_NOTHROW Q_REQUIRED_RESULT; - CGRect toCGRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT static QRectF fromCGRect(CGRect rect) Q_DECL_NOTHROW; + Q_REQUIRED_RESULT CGRect toCGRect() const Q_DECL_NOTHROW; #endif private: diff --git a/src/corelib/tools/qsize.h b/src/corelib/tools/qsize.h index cd5f8adbf5..bb29dca7c4 100644 --- a/src/corelib/tools/qsize.h +++ b/src/corelib/tools/qsize.h @@ -64,15 +64,15 @@ public: Q_DECL_RELAXED_CONSTEXPR inline void setWidth(int w) Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline void setHeight(int h) Q_DECL_NOTHROW; void transpose() Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QSize transposed() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize transposed() const Q_DECL_NOTHROW; inline void scale(int w, int h, Qt::AspectRatioMode mode) Q_DECL_NOTHROW; inline void scale(const QSize &s, Qt::AspectRatioMode mode) Q_DECL_NOTHROW; - QSize scaled(int w, int h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - QSize scaled(const QSize &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QSize scaled(int w, int h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT QSize scaled(const QSize &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QSize expandedTo(const QSize &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - Q_DECL_CONSTEXPR inline QSize boundedTo(const QSize &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize expandedTo(const QSize &) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize boundedTo(const QSize &) const Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline int &rwidth() Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline int &rheight() Q_DECL_NOTHROW; @@ -91,7 +91,7 @@ public: friend inline const QSize operator/(const QSize &, qreal); #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - CGSize toCGSize() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT CGSize toCGSize() const Q_DECL_NOTHROW; #endif private: @@ -228,15 +228,15 @@ public: Q_DECL_RELAXED_CONSTEXPR inline void setWidth(qreal w) Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline void setHeight(qreal h) Q_DECL_NOTHROW; void transpose() Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QSizeF transposed() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF transposed() const Q_DECL_NOTHROW; inline void scale(qreal w, qreal h, Qt::AspectRatioMode mode) Q_DECL_NOTHROW; inline void scale(const QSizeF &s, Qt::AspectRatioMode mode) Q_DECL_NOTHROW; - QSizeF scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - QSizeF scaled(const QSizeF &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QSizeF scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT QSizeF scaled(const QSizeF &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QSizeF expandedTo(const QSizeF &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - Q_DECL_CONSTEXPR inline QSizeF boundedTo(const QSizeF &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF expandedTo(const QSizeF &) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF boundedTo(const QSizeF &) const Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline qreal &rwidth() Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline qreal &rheight() Q_DECL_NOTHROW; @@ -257,8 +257,8 @@ public: Q_DECL_CONSTEXPR inline QSize toSize() const Q_DECL_NOTHROW; #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - static QSizeF fromCGSize(CGSize size) Q_DECL_NOTHROW Q_REQUIRED_RESULT; - CGSize toCGSize() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT static QSizeF fromCGSize(CGSize size) Q_DECL_NOTHROW; + Q_REQUIRED_RESULT CGSize toCGSize() const Q_DECL_NOTHROW; #endif private: diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 09a3bcb521..f81a58813d 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -261,47 +261,47 @@ public: const QChar operator[](uint i) const; QCharRef operator[](uint i); - QString arg(qlonglong a, int fieldwidth=0, int base=10, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(qulonglong a, int fieldwidth=0, int base=10, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(long a, int fieldwidth=0, int base=10, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(ulong a, int fieldwidth=0, int base=10, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(int a, int fieldWidth = 0, int base = 10, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(uint a, int fieldWidth = 0, int base = 10, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(short a, int fieldWidth = 0, int base = 10, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(ushort a, int fieldWidth = 0, int base = 10, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(double a, int fieldWidth = 0, char fmt = 'g', int prec = -1, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(char a, int fieldWidth = 0, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(QChar a, int fieldWidth = 0, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(const QString &a, int fieldWidth = 0, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(const QString &a1, const QString &a2) const Q_REQUIRED_RESULT; - QString arg(const QString &a1, const QString &a2, const QString &a3) const Q_REQUIRED_RESULT; - QString arg(const QString &a1, const QString &a2, const QString &a3, - const QString &a4) const Q_REQUIRED_RESULT; - QString arg(const QString &a1, const QString &a2, const QString &a3, - const QString &a4, const QString &a5) const Q_REQUIRED_RESULT; - QString arg(const QString &a1, const QString &a2, const QString &a3, - const QString &a4, const QString &a5, const QString &a6) const Q_REQUIRED_RESULT; - QString arg(const QString &a1, const QString &a2, const QString &a3, + Q_REQUIRED_RESULT QString arg(qlonglong a, int fieldwidth=0, int base=10, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(qulonglong a, int fieldwidth=0, int base=10, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(long a, int fieldwidth=0, int base=10, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(ulong a, int fieldwidth=0, int base=10, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(int a, int fieldWidth = 0, int base = 10, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(uint a, int fieldWidth = 0, int base = 10, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(short a, int fieldWidth = 0, int base = 10, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(ushort a, int fieldWidth = 0, int base = 10, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(double a, int fieldWidth = 0, char fmt = 'g', int prec = -1, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(char a, int fieldWidth = 0, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(QChar a, int fieldWidth = 0, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(const QString &a, int fieldWidth = 0, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2) const; + Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3) const; + Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3, + const QString &a4) const; + Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3, + const QString &a4, const QString &a5) const; + Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3, + const QString &a4, const QString &a5, const QString &a6) const; + Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5, const QString &a6, - const QString &a7) const Q_REQUIRED_RESULT; - QString arg(const QString &a1, const QString &a2, const QString &a3, + const QString &a7) const; + Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5, const QString &a6, - const QString &a7, const QString &a8) const Q_REQUIRED_RESULT; - QString arg(const QString &a1, const QString &a2, const QString &a3, + const QString &a7, const QString &a8) const; + Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5, const QString &a6, - const QString &a7, const QString &a8, const QString &a9) const Q_REQUIRED_RESULT; + const QString &a7, const QString &a8, const QString &a9) const; QString &vsprintf(const char *format, va_list ap) Q_ATTRIBUTE_FORMAT_PRINTF(2, 0); QString &sprintf(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); @@ -363,12 +363,12 @@ public: #ifndef QT_NO_REGULAREXPRESSION QString section(const QRegularExpression &re, int start, int end = -1, SectionFlags flags = SectionDefault) const; #endif - QString left(int n) const Q_REQUIRED_RESULT; - QString right(int n) const Q_REQUIRED_RESULT; - QString mid(int position, int n = -1) const Q_REQUIRED_RESULT; - QStringRef leftRef(int n) const Q_REQUIRED_RESULT; - QStringRef rightRef(int n) const Q_REQUIRED_RESULT; - QStringRef midRef(int position, int n = -1) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QString left(int n) const; + Q_REQUIRED_RESULT QString right(int n) const; + Q_REQUIRED_RESULT QString mid(int position, int n = -1) const; + Q_REQUIRED_RESULT QStringRef leftRef(int n) const; + Q_REQUIRED_RESULT QStringRef rightRef(int n) const; + Q_REQUIRED_RESULT QStringRef midRef(int position, int n = -1) const; bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool startsWith(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; @@ -379,8 +379,8 @@ public: bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; - QString leftJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const Q_REQUIRED_RESULT; - QString rightJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QString leftJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const; + Q_REQUIRED_RESULT QString rightJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const; #if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) && !defined(Q_CLANG_QDOC) # if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) @@ -390,37 +390,37 @@ public: # define Q_REQUIRED_RESULT # define Q_REQUIRED_RESULT_pushed # endif - Q_ALWAYS_INLINE QString toLower() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString toLower() const & { return toLower_helper(*this); } - Q_ALWAYS_INLINE QString toLower() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString toLower() && { return toLower_helper(*this); } - Q_ALWAYS_INLINE QString toUpper() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString toUpper() const & { return toUpper_helper(*this); } - Q_ALWAYS_INLINE QString toUpper() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString toUpper() && { return toUpper_helper(*this); } - Q_ALWAYS_INLINE QString toCaseFolded() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString toCaseFolded() const & { return toCaseFolded_helper(*this); } - Q_ALWAYS_INLINE QString toCaseFolded() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString toCaseFolded() && { return toCaseFolded_helper(*this); } - Q_ALWAYS_INLINE QString trimmed() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString trimmed() const & { return trimmed_helper(*this); } - Q_ALWAYS_INLINE QString trimmed() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString trimmed() && { return trimmed_helper(*this); } - Q_ALWAYS_INLINE QString simplified() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString simplified() const & { return simplified_helper(*this); } - Q_ALWAYS_INLINE QString simplified() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString simplified() && { return simplified_helper(*this); } # ifdef Q_REQUIRED_RESULT_pushed # pragma pop_macro("Q_REQUIRED_RESULT") # endif #else - QString toLower() const Q_REQUIRED_RESULT; - QString toUpper() const Q_REQUIRED_RESULT; - QString toCaseFolded() const Q_REQUIRED_RESULT; - QString trimmed() const Q_REQUIRED_RESULT; - QString simplified() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QString toLower() const; + Q_REQUIRED_RESULT QString toUpper() const; + Q_REQUIRED_RESULT QString toCaseFolded() const; + Q_REQUIRED_RESULT QString trimmed() const; + Q_REQUIRED_RESULT QString simplified() const; #endif - QString toHtmlEscaped() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QString toHtmlEscaped() const; QString &insert(int i, QChar c); QString &insert(int i, const QChar *uc, int len); @@ -479,21 +479,21 @@ public: enum SplitBehavior { KeepEmptyParts, SkipEmptyParts }; - QStringList split(const QString &sep, SplitBehavior behavior = KeepEmptyParts, - Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_REQUIRED_RESULT; - QVector splitRef(const QString &sep, SplitBehavior behavior = KeepEmptyParts, - Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_REQUIRED_RESULT; - QStringList split(QChar sep, SplitBehavior behavior = KeepEmptyParts, - Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_REQUIRED_RESULT; - QVector splitRef(QChar sep, SplitBehavior behavior = KeepEmptyParts, - Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QStringList split(const QString &sep, SplitBehavior behavior = KeepEmptyParts, + Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + Q_REQUIRED_RESULT QVector splitRef(const QString &sep, SplitBehavior behavior = KeepEmptyParts, + Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + Q_REQUIRED_RESULT QStringList split(QChar sep, SplitBehavior behavior = KeepEmptyParts, + Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + Q_REQUIRED_RESULT QVector splitRef(QChar sep, SplitBehavior behavior = KeepEmptyParts, + Qt::CaseSensitivity cs = Qt::CaseSensitive) const; #ifndef QT_NO_REGEXP - QStringList split(const QRegExp &sep, SplitBehavior behavior = KeepEmptyParts) const Q_REQUIRED_RESULT; - QVector splitRef(const QRegExp &sep, SplitBehavior behavior = KeepEmptyParts) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QStringList split(const QRegExp &sep, SplitBehavior behavior = KeepEmptyParts) const; + Q_REQUIRED_RESULT QVector splitRef(const QRegExp &sep, SplitBehavior behavior = KeepEmptyParts) const; #endif #ifndef QT_NO_REGULAREXPRESSION - QStringList split(const QRegularExpression &sep, SplitBehavior behavior = KeepEmptyParts) const Q_REQUIRED_RESULT; - QVector splitRef(const QRegularExpression &sep, SplitBehavior behavior = KeepEmptyParts) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QStringList split(const QRegularExpression &sep, SplitBehavior behavior = KeepEmptyParts) const; + Q_REQUIRED_RESULT QVector splitRef(const QRegularExpression &sep, SplitBehavior behavior = KeepEmptyParts) const; #endif enum NormalizationForm { NormalizationForm_D, @@ -501,31 +501,31 @@ public: NormalizationForm_KD, NormalizationForm_KC }; - QString normalized(NormalizationForm mode, QChar::UnicodeVersion version = QChar::Unicode_Unassigned) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QString normalized(NormalizationForm mode, QChar::UnicodeVersion version = QChar::Unicode_Unassigned) const; - QString repeated(int times) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QString repeated(int times) const; const ushort *utf16() const; #if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) && !defined(Q_CLANG_QDOC) - QByteArray toLatin1() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT QByteArray toLatin1() const & { return toLatin1_helper(*this); } - QByteArray toLatin1() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT QByteArray toLatin1() && { return toLatin1_helper_inplace(*this); } - QByteArray toUtf8() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT QByteArray toUtf8() const & { return toUtf8_helper(*this); } - QByteArray toUtf8() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT QByteArray toUtf8() && { return toUtf8_helper(*this); } - QByteArray toLocal8Bit() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT QByteArray toLocal8Bit() const & { return toLocal8Bit_helper(isNull() ? nullptr : constData(), size()); } - QByteArray toLocal8Bit() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT QByteArray toLocal8Bit() && { return toLocal8Bit_helper(isNull() ? nullptr : constData(), size()); } #else - QByteArray toLatin1() const Q_REQUIRED_RESULT; - QByteArray toUtf8() const Q_REQUIRED_RESULT; - QByteArray toLocal8Bit() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QByteArray toLatin1() const; + Q_REQUIRED_RESULT QByteArray toUtf8() const; + Q_REQUIRED_RESULT QByteArray toLocal8Bit() const; #endif - QVector toUcs4() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QVector toUcs4() const; // note - this are all inline so we can benefit from strlen() compile time optimizations static inline QString fromLatin1(const char *str, int size = -1) @@ -563,12 +563,12 @@ public: { return fromLatin1(str, size); } QT_DEPRECATED static inline QString fromAscii(const QByteArray &str) { return fromLatin1(str); } - QByteArray toAscii() const Q_REQUIRED_RESULT + Q_REQUIRED_RESULT QByteArray toAscii() const { return toLatin1(); } #endif inline int toWCharArray(wchar_t *array) const; - static inline QString fromWCharArray(const wchar_t *string, int size = -1) Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT static inline QString fromWCharArray(const wchar_t *string, int size = -1); QString &setRawData(const QChar *unicode, int size); QString &setUnicode(const QChar *unicode, int size); @@ -1425,14 +1425,14 @@ public: int count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; int count(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; - QVector split(const QString &sep, QString::SplitBehavior behavior = QString::KeepEmptyParts, - Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_REQUIRED_RESULT; - QVector split(QChar sep, QString::SplitBehavior behavior = QString::KeepEmptyParts, - Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QVector split(const QString &sep, QString::SplitBehavior behavior = QString::KeepEmptyParts, + Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + Q_REQUIRED_RESULT QVector split(QChar sep, QString::SplitBehavior behavior = QString::KeepEmptyParts, + Qt::CaseSensitivity cs = Qt::CaseSensitive) const; - QStringRef left(int n) const Q_REQUIRED_RESULT; - QStringRef right(int n) const Q_REQUIRED_RESULT; - QStringRef mid(int pos, int n = -1) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QStringRef left(int n) const; + Q_REQUIRED_RESULT QStringRef right(int n) const; + Q_REQUIRED_RESULT QStringRef mid(int pos, int n = -1) const; void truncate(int pos) Q_DECL_NOTHROW { m_size = qBound(0, pos, m_size); } void chop(int n) Q_DECL_NOTHROW @@ -1478,13 +1478,13 @@ public: inline const_reverse_iterator crend() const { return rend(); } #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED QByteArray toAscii() const Q_REQUIRED_RESULT + Q_REQUIRED_RESULT QT_DEPRECATED QByteArray toAscii() const { return toLatin1(); } #endif - QByteArray toLatin1() const Q_REQUIRED_RESULT; - QByteArray toUtf8() const Q_REQUIRED_RESULT; - QByteArray toLocal8Bit() const Q_REQUIRED_RESULT; - QVector toUcs4() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QByteArray toLatin1() const; + Q_REQUIRED_RESULT QByteArray toUtf8() const; + Q_REQUIRED_RESULT QByteArray toLocal8Bit() const; + Q_REQUIRED_RESULT QVector toUcs4() const; inline void clear() { m_string = Q_NULLPTR; m_position = m_size = 0; } QString toString() const; @@ -1526,7 +1526,7 @@ public: static int localeAwareCompare(const QStringRef &s1, const QString &s2); static int localeAwareCompare(const QStringRef &s1, const QStringRef &s2); - QStringRef trimmed() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QStringRef trimmed() const; short toShort(bool *ok = Q_NULLPTR, int base = 10) const; ushort toUShort(bool *ok = Q_NULLPTR, int base = 10) const; int toInt(bool *ok = Q_NULLPTR, int base = 10) const; diff --git a/src/corelib/tools/qtimezoneprivate_p.h b/src/corelib/tools/qtimezoneprivate_p.h index 0038908160..74b79dce16 100644 --- a/src/corelib/tools/qtimezoneprivate_p.h +++ b/src/corelib/tools/qtimezoneprivate_p.h @@ -154,12 +154,12 @@ public: QLocale::Country country); // returns "UTC" QString and QByteArray - static inline QString utcQString() Q_REQUIRED_RESULT + Q_REQUIRED_RESULT static inline QString utcQString() { return QStringLiteral("UTC"); } - static inline QByteArray utcQByteArray() Q_REQUIRED_RESULT + Q_REQUIRED_RESULT static inline QByteArray utcQByteArray() { return QByteArrayLiteral("UTC"); } diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber.h index 2aaa6201f7..d3cf743a67 100644 --- a/src/corelib/tools/qversionnumber.h +++ b/src/corelib/tools/qversionnumber.h @@ -248,39 +248,39 @@ public: inline explicit QVersionNumber(int maj, int min, int mic) { m_segments.setSegments(3, maj, min, mic); } - inline bool isNull() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + Q_REQUIRED_RESULT inline bool isNull() const Q_DECL_NOTHROW { return segmentCount() == 0; } - inline bool isNormalized() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + Q_REQUIRED_RESULT inline bool isNormalized() const Q_DECL_NOTHROW { return isNull() || segmentAt(segmentCount() - 1) != 0; } - inline int majorVersion() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + Q_REQUIRED_RESULT inline int majorVersion() const Q_DECL_NOTHROW { return segmentAt(0); } - inline int minorVersion() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + Q_REQUIRED_RESULT inline int minorVersion() const Q_DECL_NOTHROW { return segmentAt(1); } - inline int microVersion() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + Q_REQUIRED_RESULT inline int microVersion() const Q_DECL_NOTHROW { return segmentAt(2); } - Q_CORE_EXPORT QVersionNumber normalized() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_CORE_EXPORT QVersionNumber normalized() const; - Q_CORE_EXPORT QVector segments() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_CORE_EXPORT QVector segments() const; - inline int segmentAt(int index) const Q_DECL_NOTHROW Q_REQUIRED_RESULT + Q_REQUIRED_RESULT inline int segmentAt(int index) const Q_DECL_NOTHROW { return (m_segments.size() > index) ? m_segments.at(index) : 0; } - inline int segmentCount() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + Q_REQUIRED_RESULT inline int segmentCount() const Q_DECL_NOTHROW { return m_segments.size(); } - Q_CORE_EXPORT bool isPrefixOf(const QVersionNumber &other) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_CORE_EXPORT bool isPrefixOf(const QVersionNumber &other) const Q_DECL_NOTHROW; - Q_CORE_EXPORT static int compare(const QVersionNumber &v1, const QVersionNumber &v2) Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_CORE_EXPORT static int compare(const QVersionNumber &v1, const QVersionNumber &v2) Q_DECL_NOTHROW; - Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber commonPrefix(const QVersionNumber &v1, const QVersionNumber &v2) Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber commonPrefix(const QVersionNumber &v1, const QVersionNumber &v2); - Q_CORE_EXPORT QString toString() const Q_REQUIRED_RESULT; - Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = Q_NULLPTR) Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const; + Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = Q_NULLPTR); private: #ifndef QT_NO_DATASTREAM -- cgit v1.2.3 From 126c4eae84fee0e5bc4e9c6db167d92e87b7f612 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 30 Mar 2017 19:49:32 +0200 Subject: Split Q_COMPILER_UNICODE_STRINGS: add Q_STDLIB_UNICODE_STRINGS Since commit bf2160e72cd8840a8e604438cbdc807483ac980a, we can rely on charNN_t support in all compilers except MSVC 2013, and since that commit, we use (in 5.10, not 5.9, yet) !defined(Q_OS_WIN) || defined(Q_COMPILER_UNICODE_STRINGS) when we only need charNN_t, the type, as opposed to its library support (u16string, char_traits, ...). This patch splits the Q_C_UNICODE_STRINGS macro into two, adding Q_STDLIB_UNICODE_STRINGS for when we need std::uNNstring, leaving Q_C_UNICODE_STRINGS for when we need just charNN_t support. In QDebug, when constructing a QChar out of a char16_t, cast to ushort first, since QChar(char16_t) was only officially introduced in Qt 5.10. [ChangeLog][Potentially Source-Incompatible Changes] The internal Q_COMPILER_UNICODE_STRINGS macro is now defined if the compiler supports charNN_t, even if the standard library does not. To check for availability of std::uNNstring, use the new Q_STDLIB_UNICODE_STRINGS macro. Change-Id: I8f210fd7f1799fe21faf54506475a759b1f76a59 Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 7 ++++++- src/corelib/io/qdebug.h | 2 +- src/corelib/tools/qstring.h | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 5497b9e14a..5fc7ac9c7e 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -994,6 +994,10 @@ # endif /* __cplusplus */ #endif /* Q_CC_MSVC */ +#ifdef Q_COMPILER_UNICODE_STRINGS +# define Q_STDLIB_UNICODE_STRINGS +#endif + #ifdef __cplusplus # include # if defined(Q_OS_QNX) @@ -1016,8 +1020,9 @@ # undef Q_COMPILER_INITIALIZER_LISTS # undef Q_COMPILER_RVALUE_REFS # undef Q_COMPILER_REF_QUALIFIERS -# undef Q_COMPILER_UNICODE_STRINGS # undef Q_COMPILER_NOEXCEPT +// Disable C++11 library features: +# undef Q_STDLIB_UNICODE_STRINGS # endif // !_HAS_CPP0X # if !defined(_HAS_NULLPTR_T) || !_HAS_NULLPTR_T # undef Q_COMPILER_NULLPTR diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 61059dd694..186722b69b 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -139,7 +139,7 @@ public: inline QDebug &operator<<(signed short t) { stream->ts << t; return maybeSpace(); } inline QDebug &operator<<(unsigned short t) { stream->ts << t; return maybeSpace(); } #ifdef Q_COMPILER_UNICODE_STRINGS - inline QDebug &operator<<(char16_t t) { return *this << QChar(t); } + inline QDebug &operator<<(char16_t t) { return *this << QChar(ushort(t)); } inline QDebug &operator<<(char32_t t) { putUcs4(t); return maybeSpace(); } #endif inline QDebug &operator<<(signed int t) { stream->ts << t; return maybeSpace(); } diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index f81a58813d..109b68c544 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -756,7 +756,7 @@ public: static inline QString fromStdWString(const std::wstring &s); inline std::wstring toStdWString() const; -#if defined(Q_COMPILER_UNICODE_STRINGS) || defined(Q_QDOC) +#if defined(Q_STDLIB_UNICODE_STRINGS) || defined(Q_QDOC) static inline QString fromStdU16String(const std::u16string &s); inline std::u16string toStdU16String() const; static inline QString fromStdU32String(const std::u32string &s); @@ -1339,7 +1339,7 @@ inline std::wstring QString::toStdWString() const inline QString QString::fromStdWString(const std::wstring &s) { return fromWCharArray(s.data(), int(s.size())); } -#if defined(Q_COMPILER_UNICODE_STRINGS) +#if defined(Q_STDLIB_UNICODE_STRINGS) inline QString QString::fromStdU16String(const std::u16string &s) { return fromUtf16(s.data(), int(s.size())); } -- cgit v1.2.3