summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp16
-rw-r--r--src/corelib/doc/src/dontdocument.qdoc2
-rw-r--r--src/corelib/global/qcompilerdetection.h7
-rw-r--r--src/corelib/global/qglobal.h2
-rw-r--r--src/corelib/global/qnumeric_p.h3
-rw-r--r--src/corelib/io/qfilesystemwatcher_win.cpp1
-rw-r--r--src/corelib/io/qprocess.cpp4
-rw-r--r--src/corelib/itemmodels/qstringlistmodel.cpp5
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix_p.h2
-rw-r--r--src/corelib/kernel/qobject.cpp76
-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/qregularexpression.cpp4
-rw-r--r--src/corelib/text/qstring.cpp52
-rw-r--r--src/corelib/time/qdatetimeparser.cpp29
-rw-r--r--src/corelib/tools/qline.cpp2
-rw-r--r--src/corelib/tools/qscopeguard.qdoc8
-rw-r--r--src/corelib/tools/qsharedpointer.cpp2
20 files changed, 189 insertions, 123 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/doc/src/dontdocument.qdoc b/src/corelib/doc/src/dontdocument.qdoc
index 19ca7db299..ff0aa98709 100644
--- a/src/corelib/doc/src/dontdocument.qdoc
+++ b/src/corelib/doc/src/dontdocument.qdoc
@@ -37,5 +37,5 @@
QCborValueRef qfloat16 QDeferredDeleteEvent QSpecialInteger QLittleEndianStorageType
QBigEndianStorageType QFactoryInterface QFutureWatcherBase QJsonValuePtr
QJsonValueRefPtr QLinkedListNode QAbstractConcatenable QStringBuilderCommon
- QTextCodec::ConverterState QThreadStorageData)
+ QTextCodec::ConverterState QThreadStorageData QTextStreamManipulator)
*/
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 0091cfcb60..1ea4e7d287 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -883,7 +883,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
@@ -914,7 +913,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/global/qglobal.h b/src/corelib/global/qglobal.h
index e636a7cf8f..fe8e8e8bc8 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -945,7 +945,7 @@ QT_WARNING_POP
#endif
QT_WARNING_PUSH
-// warning: noexcept-expression evaluates to ‘false’ because of a call to ‘void swap(..., ...)'
+// warning: noexcept-expression evaluates to 'false' because of a call to 'void swap(..., ...)'
QT_WARNING_DISABLE_GCC("-Wnoexcept")
namespace QtPrivate
diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h
index fdfcbda6ca..7418579fe0 100644
--- a/src/corelib/global/qnumeric_p.h
+++ b/src/corelib/global/qnumeric_p.h
@@ -249,7 +249,8 @@ QT_WARNING_POP
// size_t. Implementations for 8- and 16-bit types will work but may not be as
// efficient. Implementations for 64-bit may be missing on 32-bit platforms.
-#if (defined(Q_CC_GNU) && (Q_CC_GNU >= 500) || (defined(Q_CC_INTEL) && !defined(Q_OS_WIN))) || __has_builtin(__builtin_add_overflow)
+#if ((defined(Q_CC_INTEL) ? (Q_CC_INTEL >= 1800 && !defined(Q_OS_WIN)) : defined(Q_CC_GNU)) \
+ && Q_CC_GNU >= 500) || __has_builtin(__builtin_add_overflow)
// GCC 5, ICC 18, and Clang 3.8 have builtins to detect overflows
template <typename T> inline
diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp
index 5f91ce5e3d..3b67dd61c7 100644
--- a/src/corelib/io/qfilesystemwatcher_win.cpp
+++ b/src/corelib/io/qfilesystemwatcher_win.cpp
@@ -403,6 +403,7 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths,
const QString absolutePath = isDir ? fileInfo.absoluteFilePath() : fileInfo.absolutePath();
const uint flags = isDir
? (FILE_NOTIFY_CHANGE_DIR_NAME
+ | FILE_NOTIFY_CHANGE_ATTRIBUTES
| FILE_NOTIFY_CHANGE_FILE_NAME)
: (FILE_NOTIFY_CHANGE_DIR_NAME
| FILE_NOTIFY_CHANGE_FILE_NAME
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 3a77242d7c..49e0847d44 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -1004,7 +1004,7 @@ QT_WARNING_POP
/*!
\internal
- Returns true if we emitted readyRead().
+ Returns \c true if we emitted readyRead().
*/
bool QProcessPrivate::tryReadFromChannel(Channel *channel)
{
@@ -2187,6 +2187,8 @@ bool QProcess::startDetached(qint64 *pid)
This method is an alias for start(), and exists only to fully implement
the interface defined by QIODevice.
+ Returns \c true if the program has been started.
+
\sa start(), setProgram(), setArguments()
*/
bool QProcess::open(OpenMode mode)
diff --git a/src/corelib/itemmodels/qstringlistmodel.cpp b/src/corelib/itemmodels/qstringlistmodel.cpp
index a248cdcd38..4c7616a126 100644
--- a/src/corelib/itemmodels/qstringlistmodel.cpp
+++ b/src/corelib/itemmodels/qstringlistmodel.cpp
@@ -212,6 +212,7 @@ Qt::ItemFlags QStringListModel::flags(const QModelIndex &index) const
\a index in the model, to the provided \a value.
The dataChanged() signal is emitted if the item is changed.
+ Returns \c true after emitting the dataChanged() signal.
\sa Qt::ItemDataRole, data()
*/
@@ -249,6 +250,8 @@ bool QStringListModel::clearItemData(const QModelIndex &index)
specified, indicating that the rows are inserted in the top level of
the model.
+ Returns \c true if the insertion was successful.
+
\sa QAbstractItemModel::insertRows()
*/
@@ -275,6 +278,8 @@ bool QStringListModel::insertRows(int row, int count, const QModelIndex &parent)
specified, indicating that the rows are removed in the top level of
the model.
+ Returns \c true if the row removal was successful.
+
\sa QAbstractItemModel::removeRows()
*/
diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h
index f37edfc967..581df9242c 100644
--- a/src/corelib/kernel/qeventdispatcher_unix_p.h
+++ b/src/corelib/kernel/qeventdispatcher_unix_p.h
@@ -118,7 +118,7 @@ public:
int remainingTime(int timerId) final;
- void wakeUp() final;
+ void wakeUp() override;
void interrupt() final;
void flush() override;
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index cc50d9ccc7..e2e133ac28 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -1185,8 +1185,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.
@@ -1538,7 +1538,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.
@@ -2335,7 +2335,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:
@@ -2521,7 +2521,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.
@@ -2662,7 +2662,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.
@@ -2799,12 +2799,12 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const char *sign
const QObject *receiver, const char *method,
Qt::ConnectionType type)
{
- if (sender == 0 || receiver == 0 || signal == 0 || method == 0) {
+ 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(0);
}
QByteArray tmp_signal_name;
@@ -2937,14 +2937,14 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho
const QObject *receiver, const QMetaMethod &method,
Qt::ConnectionType type)
{
- if (sender == 0
- || receiver == 0
+ if (sender == nullptr
+ || receiver == nullptr
|| 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(0);
}
@@ -3046,20 +3046,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
@@ -3070,8 +3070,8 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho
bool QObject::disconnect(const QObject *sender, const char *signal,
const QObject *receiver, const char *method)
{
- if (sender == 0 || (receiver == 0 && method != 0)) {
- qWarning("QObject::disconnect: Unexpected null parameter");
+ if (sender == nullptr || (receiver == nullptr && method != nullptr)) {
+ qWarning("QObject::disconnect: Unexpected nullptr parameter");
return false;
}
@@ -3197,16 +3197,16 @@ 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)
*/
bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal,
const QObject *receiver, const QMetaMethod &method)
{
- if (sender == 0 || (receiver == 0 && method.mobj != 0)) {
- qWarning("QObject::disconnect: Unexpected null parameter");
+ if (sender == nullptr || (receiver == nullptr && method.mobj != nullptr)) {
+ qWarning("QObject::disconnect: Unexpected nullptr parameter");
return false;
}
if (signal.mobj) {
@@ -3240,7 +3240,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",
@@ -3329,7 +3329,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).
@@ -4929,7 +4929,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
@@ -4937,7 +4937,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
@@ -4948,7 +4948,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();
@@ -4988,7 +4988,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();
@@ -5121,20 +5121,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
@@ -5150,8 +5150,8 @@ 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 == 0 || (receiver == 0 && slot != 0)) {
- qWarning("QObject::disconnect: Unexpected null parameter");
+ if (sender == nullptr || (receiver == nullptr && slot != nullptr)) {
+ qWarning("QObject::disconnect: Unexpected nullptr parameter");
return false;
}
@@ -5182,7 +5182,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 914103b0a5..dcbe7efc26 100644
--- a/src/corelib/serialization/qcborvalue.h
+++ b/src/corelib/serialization/qcborvalue.h
@@ -320,9 +320,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 425cb87d31..e3530eeee1 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/qregularexpression.cpp b/src/corelib/text/qregularexpression.cpp
index 8627cbba4f..67be67c243 100644
--- a/src/corelib/text/qregularexpression.cpp
+++ b/src/corelib/text/qregularexpression.cpp
@@ -463,10 +463,10 @@ QT_BEGIN_NAMESPACE
\c{\xHHHH} with more than 2 digits. A pattern like \c{\x2022} neeeds to
be ported to \c{\x{2022}}, or it will match a space (\c{0x20}) followed
by the string \c{"22"}. In general, it is highly recommended to always use
- curly braces with the \c{\\x} escape, no matter the amount of digits
+ curly braces with the \c{\x} escape, no matter the amount of digits
specified.
- \li A 0-to-n quantification like \c{{,n}} needs to be ported to c{{0,n}} to
+ \li A 0-to-n quantification like \c{{,n}} needs to be ported to \c{{0,n}} to
preserve semantics. Otherwise, a pattern such as \c{\d{,3}} would
actually match a digit followed by the exact string \c{"{,3}"}.
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index 4d83f19db7..fa8b5cf3f8 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -915,7 +915,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));
@@ -939,7 +939,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))
@@ -949,7 +949,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))
@@ -970,7 +970,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));
@@ -5109,21 +5109,25 @@ bool QString::endsWith(QChar c, Qt::CaseSensitivity cs) const
}
/*!
- Returns \c true if the string only contains uppercase letters,
- otherwise returns \c false.
+ Returns \c true if the string is uppercase, that is, it's identical
+ to its toUpper() folding.
+
+ Note that this does \e not mean that the string does not contain
+ lowercase letters (some lowercase letters do not have a uppercase
+ folding; they are left unchanged by toUpper()).
+ For more information, refer to the Unicode standard, section 3.13.
+
\since 5.12
- \sa QChar::isUpper(), isLower()
+ \sa QChar::toUpper(), isLower()
*/
bool QString::isUpper() const
{
- if (isEmpty())
- return false;
+ QStringIterator it(*this);
- const QChar *d = data();
-
- for (int i = 0, max = size(); i < max; ++i) {
- if (!d[i].isUpper())
+ while (it.hasNext()) {
+ uint uc = it.nextUnchecked();
+ if (qGetProp(uc)->cases[QUnicodeTables::UpperCase].diff)
return false;
}
@@ -5131,21 +5135,25 @@ bool QString::isUpper() const
}
/*!
- Returns \c true if the string only contains lowercase letters,
- otherwise returns \c false.
+ Returns \c true if the string is lowercase, that is, it's identical
+ to its toLower() folding.
+
+ Note that this does \e not mean that the string does not contain
+ uppercase letters (some uppercase letters do not have a lowercase
+ folding; they are left unchanged by toLower()).
+ For more information, refer to the Unicode standard, section 3.13.
+
\since 5.12
- \sa QChar::isLower(), isUpper()
+ \sa QChar::toLower(), isUpper()
*/
bool QString::isLower() const
{
- if (isEmpty())
- return false;
+ QStringIterator it(*this);
- const QChar *d = data();
-
- for (int i = 0, max = size(); i < max; ++i) {
- if (!d[i].isLower())
+ while (it.hasNext()) {
+ uint uc = it.nextUnchecked();
+ if (qGetProp(uc)->cases[QUnicodeTables::LowerCase].diff)
return false;
}
diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp
index 61214b0c7e..2636928e69 100644
--- a/src/corelib/time/qdatetimeparser.cpp
+++ b/src/corelib/time/qdatetimeparser.cpp
@@ -137,13 +137,12 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const
#endif
return false;
}
- const SectionNode &node = sectionNodes.at(index);
- const QDate date = v.date();
+ QCalendar::YearMonthDay date = calendar.partsFromDate(v.date());
+ if (!date.isValid())
+ return false;
+
const QTime time = v.time();
- int year = date.year(calendar);
- int month = date.month(calendar);
- int day = date.day(calendar);
int hour = time.hour();
int minute = time.minute();
int second = time.second();
@@ -152,14 +151,15 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const
// Only offset from UTC is amenable to setting an int value:
int offset = tspec == Qt::OffsetFromUTC ? v.offsetFromUtc() : 0;
+ const SectionNode &node = sectionNodes.at(index);
switch (node.type) {
case Hour24Section: case Hour12Section: hour = newVal; break;
case MinuteSection: minute = newVal; break;
case SecondSection: second = newVal; break;
case MSecSection: msec = newVal; break;
case YearSection2Digits:
- case YearSection: year = newVal; break;
- case MonthSection: month = newVal; break;
+ case YearSection: date.year = newVal; break;
+ case MonthSection: date.month = newVal; break;
case DaySection:
case DayOfWeekSectionShort:
case DayOfWeekSectionLong:
@@ -169,7 +169,7 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const
// to 31 for february should return true
return false;
}
- day = newVal;
+ date.day = newVal;
break;
case TimeZoneSection:
if (newVal < absoluteMin(index) || newVal > absoluteMax(index))
@@ -185,15 +185,14 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const
}
if (!(node.type & DaySectionMask)) {
- if (day < cachedDay)
- day = cachedDay;
- const int max = calendar.daysInMonth(month, year);
- if (day > max) {
- day = max;
- }
+ if (date.day < cachedDay)
+ date.day = cachedDay;
+ const int max = calendar.daysInMonth(date.month, date.year);
+ if (date.day > max)
+ date.day = max;
}
- const QDate newDate(year, month, day, calendar);
+ const QDate newDate = calendar.dateFromParts(date);
const QTime newTime(hour, minute, second, msec);
if (!newDate.isValid() || !newTime.isValid())
return false;
diff --git a/src/corelib/tools/qline.cpp b/src/corelib/tools/qline.cpp
index 3afd23d76b..dde66ed093 100644
--- a/src/corelib/tools/qline.cpp
+++ b/src/corelib/tools/qline.cpp
@@ -374,7 +374,7 @@ QDataStream &operator>>(QDataStream &stream, QLine &line)
*/
/*!
- \enum QLineF::IntersectionType
+ \enum QLineF::IntersectType
Describes the intersection between two lines.
diff --git a/src/corelib/tools/qscopeguard.qdoc b/src/corelib/tools/qscopeguard.qdoc
index 5a9b7fd210..6b3c942e84 100644
--- a/src/corelib/tools/qscopeguard.qdoc
+++ b/src/corelib/tools/qscopeguard.qdoc
@@ -51,10 +51,10 @@ QT_BEGIN_NAMESPACE
of the scope.
\ingroup misc
- QScopeGuard<F> is a class which sole purpose is to run a function \e F in
- its destructor. This is useful for guaranteeing your cleanup code is
- executed, whether the function is exited normally, exited early by a return
- statement, or exited by an exception.
+ QScopeGuard<F> is a class of which the sole purpose is to run the function
+ \a f in its destructor. This is useful for guaranteeing
+ your cleanup code is executed, whether the function is exited normally,
+ exited early by a return statement, or exited by an exception.
If \e F is a lambda then you cannot instantiate the template directly,
therefore the qScopeGuard() helper is provided and QScopeGuard<F> is made a
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index f185d2f23f..0576fb2bd0 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -1285,6 +1285,8 @@
\relates QSharedPointer
\since 5.14
+ Returns a shared pointer to the pointer held by \a src.
+
Same as qSharedPointerObjectCast(). This function is provided for STL
compatibility.
*/