summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-01-13 01:01:03 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2020-01-13 10:13:01 +0100
commitcccc9d0b95cd021ae93c70867771a57aaadd16ff (patch)
tree34948260f68ee30b3ee0f8656d9b518e1438b606 /src/corelib
parent0dc5562fa4f01140e98e55ceaa743b0f4fc276c7 (diff)
parent76c4c5d5581b2cd36a043234eb167dd55041301d (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp Change-Id: I4d3041fa291a918c774ffa5eb5c8792a0966451d
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp16
-rw-r--r--src/corelib/global/qcompilerdetection.h7
-rw-r--r--src/corelib/io/qprocess_unix.cpp7
-rw-r--r--src/corelib/kernel/qobject.cpp64
-rw-r--r--src/corelib/serialization/qcborvalue.h4
-rw-r--r--src/corelib/text/qlocale.cpp73
-rw-r--r--src/corelib/text/qlocale.h6
-rw-r--r--src/corelib/text/qlocale_mac.mm14
-rw-r--r--src/corelib/text/qstring.cpp8
9 files changed, 126 insertions, 73 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp
index 1966f8195a..43bcc22720 100644
--- a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp
@@ -71,7 +71,7 @@ QTimer *timer = qobject_cast<QTimer *>(obj);
// timer == (QObject *)obj
QAbstractButton *button = qobject_cast<QAbstractButton *>(obj);
-// button == 0
+// button == nullptr
//! [3]
@@ -144,7 +144,7 @@ class MyObject : public QObject
Q_OBJECT
public:
- MyObject(QObject *parent = 0);
+ MyObject(QObject *parent = nullptr);
protected:
void timerEvent(QTimerEvent *event) override;
@@ -322,7 +322,7 @@ QObject::connect: Cannot queue arguments of type 'MyType'
//! [26]
-disconnect(myObject, 0, 0, 0);
+disconnect(myObject, nullptr, nullptr, nullptr);
//! [26]
@@ -332,7 +332,7 @@ myObject->disconnect();
//! [28]
-disconnect(myObject, SIGNAL(mySignal()), 0, 0);
+disconnect(myObject, SIGNAL(mySignal()), nullptr, nullptr);
//! [28]
@@ -342,7 +342,7 @@ myObject->disconnect(SIGNAL(mySignal()));
//! [30]
-disconnect(myObject, 0, myReceiver, 0);
+disconnect(myObject, nullptr, myReceiver, nullptr);
//! [30]
@@ -391,7 +391,7 @@ class MyClass : public QObject
Q_OBJECT
public:
- MyClass(QObject *parent = 0);
+ MyClass(QObject *parent = nullptr);
~MyClass();
enum Priority { High, Low, VeryHigh, VeryLow };
@@ -467,7 +467,7 @@ QObject::connect(socket, &QTcpSocket::connected, [=] () {
//! [46]
//! [47]
-disconnect(myObject, &MyObject::mySignal(), 0, 0);
+disconnect(myObject, &MyObject::mySignal(), nullptr, nullptr);
//! [47]
//! [48]
@@ -505,7 +505,7 @@ class MyClass : public QWidget
Q_OBJECT
public:
- MyClass(QWidget *parent = 0);
+ MyClass(QWidget *parent = nullptr);
~MyClass();
bool event(QEvent* ev) override
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index e4c37451d2..99a30e941b 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -870,7 +870,6 @@
# define Q_COMPILER_DEFAULT_MEMBERS
# define Q_COMPILER_DELETE_MEMBERS
/* C++11 features supported in GCC 4.6: */
-# define Q_COMPILER_CONSTEXPR
# define Q_COMPILER_NULLPTR
# define Q_COMPILER_UNRESTRICTED_UNIONS
# define Q_COMPILER_RANGE_FOR
@@ -901,7 +900,11 @@
# define Q_COMPILER_REF_QUALIFIERS
# endif
# endif
- /* C++11 features are complete as of GCC 4.8.1 */
+# if Q_CC_GNU >= 500
+ /* GCC 4.6 introduces constexpr, but it's bugged (at least) in the whole
+ * 4.x series, see e.g. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57694 */
+# define Q_COMPILER_CONSTEXPR
+# endif
# endif
# if __cplusplus > 201103L
# if Q_CC_GNU >= 409
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 9cd3bd531b..2186f23ab6 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -451,8 +451,13 @@ void QProcessPrivate::startProcess()
}
// Start the process manager, and fork off the child process.
+ // ### Qt6: revisit whether the change in behavior due to not using fork()
+ // is acceptable for derived classes.
+ int ffdflags = FFD_CLOEXEC;
+ if (typeid(*q) != typeid(QProcess))
+ ffdflags |= FFD_USE_FORK;
pid_t childPid;
- forkfd = ::forkfd(FFD_CLOEXEC, &childPid);
+ forkfd = ::forkfd(ffdflags , &childPid);
int lastForkErrno = errno;
if (forkfd != FFD_CHILD_PROCESS) {
// Parent process.
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index e51d91e389..133ccc88d9 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -1153,8 +1153,8 @@ QObjectPrivate::Connection::~Connection()
\relates QObject
Returns the given \a object cast to type T if the object is of type
- T (or of a subclass); otherwise returns 0. If \a object is 0 then
- it will also return 0.
+ T (or of a subclass); otherwise returns \nullptr. If \a object is
+ \nullptr then it will also return \nullptr.
The class T must inherit (directly or indirectly) QObject and be
declared with the \l Q_OBJECT macro.
@@ -1506,7 +1506,7 @@ QThread *QObject::thread() const
the thread affinity is changed. You can handle this event to
perform any special processing. Note that any new events that are
posted to this object will be handled in the \a targetThread,
- provided it is non-null: when it is \nullptr, no event processing
+ provided it is not \nullptr: when it is \nullptr, no event processing
for this object or its children can happen, as they are no longer
associated with any thread.
@@ -2311,7 +2311,7 @@ void QObject::deleteLater()
If the same \a sourceText is used in different roles within the
same context, an additional identifying string may be passed in
- \a disambiguation (0 by default). In Qt 4.4 and earlier, this was
+ \a disambiguation (\nullptr by default). In Qt 4.4 and earlier, this was
the preferred way to pass comments to translators.
Example:
@@ -2497,7 +2497,7 @@ QObject *QObject::sender() const
For signals with default parameters, this function will always return
the index with all parameters, regardless of which was used with
- connect(). For example, the signal \c {destroyed(QObject *obj = 0)}
+ connect(). For example, the signal \c {destroyed(QObject *obj = \nullptr)}
will have two different indexes (with and without the parameter), but
this function will always return the index with a parameter. This does
not apply when overloading signals with different parameters.
@@ -2638,7 +2638,7 @@ bool QObject::isSignalConnected(const QMetaMethod &signal) const
member in the specified class.
\list
- \li If member.mobj is 0 then both signalIndex and methodIndex are set to -1.
+ \li If member.mobj is \nullptr then both signalIndex and methodIndex are set to -1.
\li If specified member is not a member of obj instance class (or one of
its parent classes) then both signalIndex and methodIndex are set to -1.
@@ -2777,10 +2777,10 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const char *sign
{
if (sender == nullptr || receiver == nullptr || signal == nullptr || method == nullptr) {
qWarning("QObject::connect: Cannot connect %s::%s to %s::%s",
- sender ? sender->metaObject()->className() : "(null)",
- (signal && *signal) ? signal+1 : "(null)",
- receiver ? receiver->metaObject()->className() : "(null)",
- (method && *method) ? method+1 : "(null)");
+ sender ? sender->metaObject()->className() : "(nullptr)",
+ (signal && *signal) ? signal+1 : "(nullptr)",
+ receiver ? receiver->metaObject()->className() : "(nullptr)",
+ (method && *method) ? method+1 : "(nullptr)");
return QMetaObject::Connection(nullptr);
}
QByteArray tmp_signal_name;
@@ -2918,9 +2918,9 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho
|| signal.methodType() != QMetaMethod::Signal
|| method.methodType() == QMetaMethod::Constructor) {
qWarning("QObject::connect: Cannot connect %s::%s to %s::%s",
- sender ? sender->metaObject()->className() : "(null)",
+ sender ? sender->metaObject()->className() : "(nullptr)",
signal.methodSignature().constData(),
- receiver ? receiver->metaObject()->className() : "(null)",
+ receiver ? receiver->metaObject()->className() : "(nullptr)",
method.methodSignature().constData() );
return QMetaObject::Connection(nullptr);
}
@@ -3022,20 +3022,20 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho
\endlist
- 0 may be used as a wildcard, meaning "any signal", "any receiving
+ \nullptr may be used as a wildcard, meaning "any signal", "any receiving
object", or "any slot in the receiving object", respectively.
The \a sender may never be \nullptr. (You cannot disconnect signals
from more than one object in a single call.)
- If \a signal is 0, it disconnects \a receiver and \a method from
+ If \a signal is \nullptr, it disconnects \a receiver and \a method from
any signal. If not, only the specified signal is disconnected.
- If \a receiver is 0, it disconnects anything connected to \a
+ If \a receiver is \nullptr, it disconnects anything connected to \a
signal. If not, slots in objects other than \a receiver are not
disconnected.
- If \a method is 0, it disconnects anything that is connected to \a
+ If \a method is \nullptr, it disconnects anything that is connected to \a
receiver. If not, only slots named \a method will be disconnected,
and all other slots are left alone. The \a method must be \nullptr
if \a receiver is left out, so you cannot disconnect a
@@ -3047,7 +3047,7 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
const QObject *receiver, const char *method)
{
if (sender == nullptr || (receiver == nullptr && method != nullptr)) {
- qWarning("QObject::disconnect: Unexpected null parameter");
+ qWarning("QObject::disconnect: Unexpected nullptr parameter");
return false;
}
@@ -3173,8 +3173,8 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
\endlist
QMetaMethod() may be used as wildcard in the meaning "any signal" or "any slot in receiving object".
- In the same way 0 can be used for \a receiver in the meaning "any receiving object". In this case
- method should also be QMetaMethod(). \a sender parameter should be never 0.
+ In the same way \nullptr can be used for \a receiver in the meaning "any receiving object".
+ In this case method should also be QMetaMethod(). \a sender parameter should be never \nullptr.
\sa disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
*/
@@ -3182,7 +3182,7 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal,
const QObject *receiver, const QMetaMethod &method)
{
if (sender == nullptr || (receiver == nullptr && method.mobj != nullptr)) {
- qWarning("QObject::disconnect: Unexpected null parameter");
+ qWarning("QObject::disconnect: Unexpected nullptr parameter");
return false;
}
if (signal.mobj) {
@@ -3216,7 +3216,7 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal,
QMetaObjectPrivate::memberIndexes(sender, signal, &signal_index, &dummy);
QMetaObjectPrivate::memberIndexes(receiver, method, &dummy, &method_index);
}
- // If we are here sender is not null. If signal is not null while signal_index
+ // If we are here sender is not nullptr. If signal is not nullptr while signal_index
// is -1 then this signal is not a member of sender.
if (signal.mobj && signal_index == -1) {
qWarning("QObject::disconect: signal %s not found on class %s",
@@ -3305,7 +3305,7 @@ void QObject::connectNotify(const QMetaMethod &signal)
\a signal with a specific signal.
If all signals were disconnected from this object (e.g., the
- signal argument to disconnect() was 0), disconnectNotify()
+ signal argument to disconnect() was \nullptr), disconnectNotify()
is only called once, and the \a signal will be an invalid
QMetaMethod (QMetaMethod::isValid() returns \c false).
@@ -4853,7 +4853,7 @@ void qDeleteInEventHandler(QObject *o)
\a sender is the sender object
\a signal is a pointer to a pointer to a member signal of the sender
- \a receiver is the receiver object, may not be null, will be equal to sender when
+ \a receiver is the receiver object, may not be \nullptr, will be equal to sender when
connecting to a static function or a functor
\a slot a pointer only used when using Qt::UniqueConnection
\a type the Qt::ConnctionType passed as argument to connect
@@ -4861,7 +4861,7 @@ void qDeleteInEventHandler(QObject *o)
to be used with queued connection
must stay valid at least for the whole time of the connection, this function
do not take ownership. typically static data.
- If null, then the types will be computed when the signal is emit in a queued
+ If \nullptr, then the types will be computed when the signal is emit in a queued
connection from the types from the signature.
\a senderMetaObject is the metaobject used to lookup the signal, the signal must be in
this metaobject
@@ -4872,7 +4872,7 @@ QMetaObject::Connection QObject::connectImpl(const QObject *sender, void **signa
const int *types, const QMetaObject *senderMetaObject)
{
if (!signal) {
- qWarning("QObject::connect: invalid null parameter");
+ qWarning("QObject::connect: invalid nullptr parameter");
if (slotObj)
slotObj->destroyIfLastRef();
return QMetaObject::Connection();
@@ -4912,7 +4912,7 @@ QMetaObject::Connection QObjectPrivate::connectImpl(const QObject *sender, int s
: "Unknown";
const char *receiverString = receiver ? receiver->metaObject()->className()
: "Unknown";
- qWarning("QObject::connect(%s, %s): invalid null parameter", senderString, receiverString);
+ qWarning("QObject::connect(%s, %s): invalid nullptr parameter", senderString, receiverString);
if (slotObj)
slotObj->destroyIfLastRef();
return QMetaObject::Connection();
@@ -5045,20 +5045,20 @@ bool QObject::disconnect(const QMetaObject::Connection &connection)
\endlist
- 0 may be used as a wildcard, meaning "any signal", "any receiving
+ \nullptr may be used as a wildcard, meaning "any signal", "any receiving
object", or "any slot in the receiving object", respectively.
The \a sender may never be \nullptr. (You cannot disconnect signals
from more than one object in a single call.)
- If \a signal is 0, it disconnects \a receiver and \a method from
+ If \a signal is \nullptr, it disconnects \a receiver and \a method from
any signal. If not, only the specified signal is disconnected.
- If \a receiver is 0, it disconnects anything connected to \a
+ If \a receiver is \nullptr, it disconnects anything connected to \a
signal. If not, slots in objects other than \a receiver are not
disconnected.
- If \a method is 0, it disconnects anything that is connected to \a
+ If \a method is \nullptr, it disconnects anything that is connected to \a
receiver. If not, only slots named \a method will be disconnected,
and all other slots are left alone. The \a method must be \nullptr
if \a receiver is left out, so you cannot disconnect a
@@ -5075,7 +5075,7 @@ bool QObject::disconnect(const QMetaObject::Connection &connection)
bool QObject::disconnectImpl(const QObject *sender, void **signal, const QObject *receiver, void **slot, const QMetaObject *senderMetaObject)
{
if (sender == nullptr || (receiver == nullptr && slot != nullptr)) {
- qWarning("QObject::disconnect: Unexpected null parameter");
+ qWarning("QObject::disconnect: Unexpected nullptr parameter");
return false;
}
@@ -5106,7 +5106,7 @@ bool QObject::disconnectImpl(const QObject *sender, void **signal, const QObject
QMetaObject::Connection QObjectPrivate::connect(const QObject *sender, int signal_index, QtPrivate::QSlotObjectBase *slotObj, Qt::ConnectionType type)
{
if (!sender) {
- qWarning("QObject::connect: invalid null parameter");
+ qWarning("QObject::connect: invalid nullptr parameter");
if (slotObj)
slotObj->destroyIfLastRef();
return QMetaObject::Connection();
diff --git a/src/corelib/serialization/qcborvalue.h b/src/corelib/serialization/qcborvalue.h
index 1df8425d45..f7064ac6e1 100644
--- a/src/corelib/serialization/qcborvalue.h
+++ b/src/corelib/serialization/qcborvalue.h
@@ -332,9 +332,9 @@ private:
return Type(quint8(st) | SimpleType);
}
- Q_DECL_CONSTEXPR static bool isTag_helper(Type t)
+ Q_DECL_CONSTEXPR static bool isTag_helper(Type tt)
{
- return t == Tag || t >= 0x10000;
+ return tt == Tag || tt >= 0x10000;
}
};
Q_DECLARE_SHARED(QCborValue)
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp
index c643c2a514..93a8abb1ce 100644
--- a/src/corelib/text/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2019 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
@@ -651,7 +651,6 @@ int qt_repeatCount(QStringView s)
}
static const QLocaleData *default_data = nullptr;
-static QLocale::NumberOptions default_number_options = QLocale::DefaultNumberOptions;
static const QLocaleData *const c_data = locale_data;
static QLocalePrivate *c_private()
@@ -834,7 +833,7 @@ QDataStream &operator>>(QDataStream &ds, QLocale &l)
static const int locale_data_size = sizeof(locale_data)/sizeof(QLocaleData) - 1;
Q_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer<QLocalePrivate>, defaultLocalePrivate,
- (QLocalePrivate::create(defaultData(), default_number_options)))
+ (QLocalePrivate::create(defaultData())))
Q_GLOBAL_STATIC_WITH_ARGS(QExplicitlySharedDataPointer<QLocalePrivate>, systemLocalePrivate,
(QLocalePrivate::create(systemData())))
@@ -862,8 +861,9 @@ static QLocalePrivate *findLocalePrivate(QLocale::Language language, QLocale::Sc
QLocale::NumberOptions numberOptions = QLocale::DefaultNumberOptions;
// If not found, should default to system
- if (data->m_language_id == QLocale::C && language != QLocale::C) {
- numberOptions = default_number_options;
+ if (data->m_language_id == QLocale::C) {
+ if (defaultLocalePrivate.exists())
+ numberOptions = defaultLocalePrivate->data()->m_numberOptions;
data = defaultData();
}
return QLocalePrivate::create(data, offset, numberOptions);
@@ -1048,6 +1048,8 @@ uint qHash(const QLocale &key, uint seed) noexcept
Sets the \a options related to number conversions for this
QLocale instance.
+
+ \sa numberOptions()
*/
void QLocale::setNumberOptions(NumberOptions options)
{
@@ -1060,7 +1062,10 @@ void QLocale::setNumberOptions(NumberOptions options)
Returns the options related to number conversions for this
QLocale instance.
- By default, no options are set for the standard locales.
+ By default, no options are set for the standard locales, except
+ for the "C" locale, which has OmitGroupSeparator set by default.
+
+ \sa setNumberOptions(), toString(), groupSeparator()
*/
QLocale::NumberOptions QLocale::numberOptions() const
{
@@ -1170,12 +1175,9 @@ QString QLocale::createSeparatedList(const QStringList &list) const
void QLocale::setDefault(const QLocale &locale)
{
default_data = locale.d->m_data;
- default_number_options = locale.numberOptions();
- if (defaultLocalePrivate.exists()) {
- // update the cached private
+ if (defaultLocalePrivate.exists()) // update the cached private
*defaultLocalePrivate = locale.d;
- }
}
/*!
@@ -1962,7 +1964,7 @@ double QLocale::toDouble(QStringView s, bool *ok) const
/*!
Returns a localized string representation of \a i.
- \sa toLongLong()
+ \sa toLongLong(), numberOptions(), zeroDigit(), positiveSign()
*/
QString QLocale::toString(qlonglong i) const
@@ -1978,7 +1980,7 @@ QString QLocale::toString(qlonglong i) const
/*!
\overload
- \sa toULongLong()
+ \sa toULongLong(), numberOptions(), zeroDigit(), positiveSign()
*/
QString QLocale::toString(qulonglong i) const
@@ -2525,6 +2527,12 @@ QDateTime QLocale::toDateTime(const QString &string, const QString &format, QCal
\since 4.1
Returns the decimal point character of this locale.
+
+ \note This function shall change to return a QString instead of QChar in
+ Qt6. Callers are encouraged to exploit the QString(QChar) constructor to
+ convert early in preparation for this.
+
+ \sa groupSeparator(), toString()
*/
QChar QLocale::decimalPoint() const
{
@@ -2535,6 +2543,12 @@ QChar QLocale::decimalPoint() const
\since 4.1
Returns the group separator character of this locale.
+
+ \note This function shall change to return a QString instead of QChar in
+ Qt6. Callers are encouraged to exploit the QString(QChar) constructor to
+ convert early in preparation for this.
+
+ \sa decimalPoint(), toString()
*/
QChar QLocale::groupSeparator() const
{
@@ -2545,6 +2559,12 @@ QChar QLocale::groupSeparator() const
\since 4.1
Returns the percent character of this locale.
+
+ \note This function shall change to return a QString instead of QChar in
+ Qt6. Callers are encouraged to exploit the QString(QChar) constructor to
+ convert early in preparation for this.
+
+ \sa toString()
*/
QChar QLocale::percent() const
{
@@ -2555,6 +2575,12 @@ QChar QLocale::percent() const
\since 4.1
Returns the zero digit character of this locale.
+
+ \note This function shall change to return a QString instead of QChar in
+ Qt6. Callers are encouraged to exploit the QString(QChar) constructor to
+ convert early in preparation for this.
+
+ \sa toString()
*/
QChar QLocale::zeroDigit() const
{
@@ -2565,6 +2591,12 @@ QChar QLocale::zeroDigit() const
\since 4.1
Returns the negative sign character of this locale.
+
+ \note This function shall change to return a QString instead of QChar in
+ Qt6. Callers are encouraged to exploit the QString(QChar) constructor to
+ convert early in preparation for this.
+
+ \sa positiveSign(), toString()
*/
QChar QLocale::negativeSign() const
{
@@ -2575,6 +2607,12 @@ QChar QLocale::negativeSign() const
\since 4.5
Returns the positive sign character of this locale.
+
+ \note This function shall change to return a QString instead of QChar in
+ Qt6. Callers are encouraged to exploit the QString(QChar) constructor to
+ convert early in preparation for this.
+
+ \sa negativeSign(), toString()
*/
QChar QLocale::positiveSign() const
{
@@ -2584,7 +2622,14 @@ QChar QLocale::positiveSign() const
/*!
\since 4.1
- Returns the exponential character of this locale.
+ Returns the exponential character of this locale, used to separate exponent
+ from mantissa in some floating-point numeric representations.
+
+ \note This function shall change to return a QString instead of QChar in
+ Qt6. Callers are encouraged to exploit the QString(QChar) constructor to
+ convert early in preparation for this.
+
+ \sa toString(double, char, int)
*/
QChar QLocale::exponential() const
{
@@ -2609,7 +2654,7 @@ static char qToLower(char c)
\a f and \a prec have the same meaning as in QString::number(double, char, int).
- \sa toDouble()
+ \sa toDouble(), numberOptions(), exponential(), decimalPoint(), zeroDigit(), positiveSign(), percent()
*/
QString QLocale::toString(double i, char f, int prec) const
diff --git a/src/corelib/text/qlocale.h b/src/corelib/text/qlocale.h
index 8b73eb5493..513e0f097b 100644
--- a/src/corelib/text/qlocale.h
+++ b/src/corelib/text/qlocale.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -1044,8 +1044,8 @@ public:
QDateTime toDateTime(const QString &string, const QString &format, QCalendar cal) const;
#endif
- // ### Qt 5: We need to return QString from these function since
- // unicode data contains several characters for these fields.
+ // ### Qt 6: We need to return QString from these function since
+ // UTF-16 may need surrogate pairs to represent these fields.
QChar decimalPoint() const;
QChar groupSeparator() const;
QChar percent() const;
diff --git a/src/corelib/text/qlocale_mac.mm b/src/corelib/text/qlocale_mac.mm
index 9719278426..31ede1352b 100644
--- a/src/corelib/text/qlocale_mac.mm
+++ b/src/corelib/text/qlocale_mac.mm
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -67,16 +67,16 @@ static QByteArray envVarLocale()
return lang;
}
-static QByteArray getMacLocaleName()
+static QString getMacLocaleName()
{
- QByteArray result = envVarLocale();
+ QString result = QString::fromLocal8Bit(envVarLocale());
QString lang, script, cntry;
if (result.isEmpty()
- || (result != "C" && !qt_splitLocaleName(QString::fromLocal8Bit(result), lang, script, cntry))) {
+ || (result != QLatin1String("C") && !qt_splitLocaleName(result, lang, script, cntry))) {
QCFType<CFLocaleRef> l = CFLocaleCopyCurrent();
CFStringRef locale = CFLocaleGetIdentifier(l);
- result = QString::fromCFString(locale).toUtf8();
+ result = QString::fromCFString(locale);
}
return result;
}
@@ -402,10 +402,10 @@ static QVariant macQuoteString(QSystemLocale::QueryType type, const QStringRef &
QLocale QSystemLocale::fallbackUiLocale() const
{
- return QLocale(QString::fromUtf8(getMacLocaleName().constData()));
+ return QLocale(getMacLocaleName());
}
-QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
+QVariant QSystemLocale::query(QueryType type, QVariant in) const
{
QMacAutoReleasePool pool;
switch(type) {
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index 51d383ea18..ff1152b4e9 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -929,7 +929,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, size_t l)
};
// we're going to read a[0..15] and b[0..15] (32 bytes)
- for ( ; a + offset + 16 <= end; offset += 16) {
+ for ( ; end - a >= offset + 16; offset += 16) {
#ifdef __AVX2__
__m256i a_data = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(a + offset));
__m256i b_data = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(b + offset));
@@ -953,7 +953,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, size_t l)
}
// we're going to read a[0..7] and b[0..7] (16 bytes)
- if (a + offset + 8 <= end) {
+ if (end - a >= offset + 8) {
__m128i a_data = _mm_loadu_si128(reinterpret_cast<const __m128i *>(a + offset));
__m128i b_data = _mm_loadu_si128(reinterpret_cast<const __m128i *>(b + offset));
if (isDifferent(a_data, b_data))
@@ -963,7 +963,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, size_t l)
}
// we're going to read a[0..3] and b[0..3] (8 bytes)
- if (a + offset + 4 <= end) {
+ if (end - a >= offset + 4) {
__m128i a_data = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(a + offset));
__m128i b_data = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(b + offset));
if (isDifferent(a_data, b_data))
@@ -984,7 +984,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, size_t l)
if (l >= 8) {
const QChar *end = a + l;
const uint16x8_t mask = { 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7 };
- while (a + 7 < end) {
+ while (end - a > 7) {
uint16x8_t da = vld1q_u16(reinterpret_cast<const uint16_t *>(a));
uint16x8_t db = vld1q_u16(reinterpret_cast<const uint16_t *>(b));