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_qabstractnativeeventfilter.h12
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.mm12
-rw-r--r--src/corelib/doc/src/objectmodel/signalsandslots.qdoc3
-rw-r--r--src/corelib/global/qglobal.cpp13
-rw-r--r--src/corelib/kernel/qmetatype.cpp106
-rw-r--r--src/corelib/kernel/qobject.cpp15
-rw-r--r--src/corelib/kernel/qtcore_eval.cpp2
-rw-r--r--src/corelib/tools/qbytearraymatcher.h4
-rw-r--r--src/corelib/tools/qregularexpression.cpp2
9 files changed, 140 insertions, 29 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.h b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.h
index 8818e23ffa..bb44782ac5 100644
--- a/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.h
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.h
@@ -6,7 +6,17 @@
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.mm b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.mm
index 2c94178e13..7c40330de0 100644
--- a/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.mm
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.mm
@@ -6,7 +6,17 @@
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
diff --git a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
index 6366350cde..ed61511c62 100644
--- a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
+++ b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
@@ -364,9 +364,6 @@
connect(sender, &QObject::destroyed, [=](){ this->m_objects.remove(sender); });
\endcode
- Note that if your compiler does not support C++11 variadic templates,
- this syntax only works if the signal and slot have 6 arguments or less.
-
The other way to connect a signal to a slot is to use QObject::connect()
and the \c{SIGNAL} and \c{SLOT} macros.
The rule about whether to
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index f8c58c6b3e..7ca22e4a93 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1938,6 +1938,19 @@ bool qSharedBuild() Q_DECL_NOTHROW
disable functions deprecated in Qt 5.1 and earlier. In any release, set
QT_DISABLE_DEPRECATED_BEFORE=0x000000 to enable any functions, including the ones
deprecated in Qt 5.0
+
+ \sa QT_DEPRECATED_WARNINGS
+ */
+
+
+/*!
+ \macro QT_DEPRECATED_WARNINGS
+ \relates <QtGlobal>
+
+ If this macro is defined, the compiler will generate warnings if API declared as
+ deprecated by Qt is used.
+
+ \sa QT_DISABLE_DEPRECATED_BEFORE
*/
#if defined(QT_BUILD_QMAKE)
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 1764c8116e..38e0d6055c 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -825,9 +825,91 @@ void QMetaType::registerStreamOperators(int idx, SaveOperator saveOp,
}
#endif // QT_NO_DATASTREAM
+#if defined(Q_COMPILER_CONSTEXPR) || (defined(Q_CC_MSVC) && Q_CC_MSVC >= 1900)
+// We don't officially support constexpr in MSVC 2015, but the limited support it
+// has is enough for the code below.
+
+# define STRINGIFY_TYPE_NAME(MetaTypeName, TypeId, RealName) \
+ #RealName "\0"
+# define CALCULATE_TYPE_LEN(MetaTypeName, TypeId, RealName) \
+ short(sizeof(#RealName)),
+# define MAP_TYPE_ID_TO_IDX(MetaTypeName, TypeId, RealName) \
+ TypeId,
+
+namespace {
+// All type names in one long string.
+constexpr char metaTypeStrings[] = QT_FOR_EACH_STATIC_TYPE(STRINGIFY_TYPE_NAME);
+
+// The sizes of the strings in the metaTypeStrings string (including terminating null)
+constexpr short metaTypeNameSizes[] = {
+ QT_FOR_EACH_STATIC_TYPE(CALCULATE_TYPE_LEN)
+};
+
+// The type IDs, in the order of the metaTypeStrings data
+constexpr short metaTypeIds[] = {
+ QT_FOR_EACH_STATIC_TYPE(MAP_TYPE_ID_TO_IDX)
+};
+
+constexpr int MetaTypeNameCount = sizeof(metaTypeNameSizes) / sizeof(metaTypeNameSizes[0]);
+
+template <typename IntegerSequence> struct MetaTypeOffsets;
+template <int... TypeIds> struct MetaTypeOffsets<QtPrivate::IndexesList<TypeIds...>>
+{
+ // This would have been a lot easier if the meta types that the macro
+ // QT_FOR_EACH_STATIC_TYPE declared were in sorted, ascending order, but
+ // they're not (i.e., the first one declared is QMetaType::Void == 43,
+ // followed by QMetaType::Bool == 1)... As a consequence, we need to use
+ // the C++11 constexpr function calculateOffsetForTypeId below in order to
+ // create the offset array.
+
+ static constexpr int findTypeId(int typeId, int i = 0)
+ {
+ return i >= MetaTypeNameCount ? -1 :
+ metaTypeIds[i] == typeId ? i : findTypeId(typeId, i + 1);
+ }
+
+ static constexpr short calculateOffsetForIdx(int i)
+ {
+ return i < 0 ? -1 :
+ i == 0 ? 0 : metaTypeNameSizes[i - 1] + calculateOffsetForIdx(i - 1);
+ }
+
+ static constexpr short calculateOffsetForTypeId(int typeId)
+ {
+ return calculateOffsetForIdx(findTypeId(typeId));
+#if 0
+ // same as, but this is only valid in C++14:
+ short offset = 0;
+ for (int i = 0; i < MetaTypeNameCount; ++i) {
+ if (metaTypeIds[i] == typeId)
+ return offset;
+ offset += metaTypeNameSizes[i];
+ }
+ return -1;
+#endif
+ }
+
+ short offsets[sizeof...(TypeIds)];
+ constexpr MetaTypeOffsets() : offsets{calculateOffsetForTypeId(TypeIds)...} {}
+
+ const char *operator[](int typeId) const Q_DECL_NOTHROW
+ {
+ short o = offsets[typeId];
+ return o < 0 ? nullptr : metaTypeStrings + o;
+ }
+};
+} // anonymous namespace
+
+constexpr MetaTypeOffsets<QtPrivate::Indexes<QMetaType::HighestInternalId + 1>::Value> metaTypeNames {};
+# undef STRINGIFY_TYPE_NAME
+# undef CALCULATE_TYPE_LEN
+# undef MAP_TYPE_ID_TO_IDX
+#endif
+
/*!
- Returns the type name associated with the given \a typeId, or 0 if no
- matching type was found. The returned pointer must not be deleted.
+ Returns the type name associated with the given \a typeId, or a null
+ pointer if no matching type was found. The returned pointer must not be
+ deleted.
\sa type(), isRegistered(), Type
*/
@@ -837,14 +919,18 @@ const char *QMetaType::typeName(int typeId)
#define QT_METATYPE_TYPEID_TYPENAME_CONVERTER(MetaTypeName, TypeId, RealName) \
case QMetaType::MetaTypeName: return #RealName; break;
- switch (QMetaType::Type(type)) {
- QT_FOR_EACH_STATIC_TYPE(QT_METATYPE_TYPEID_TYPENAME_CONVERTER)
- case QMetaType::UnknownType:
- case QMetaType::User:
- break;
- }
-
- if (Q_UNLIKELY(type < QMetaType::User)) {
+ if (Q_LIKELY(type <= QMetaType::HighestInternalId)) {
+#if defined(Q_COMPILER_CONSTEXPR) || (defined(Q_CC_MSVC) && Q_CC_MSVC >= 1900)
+ return metaTypeNames[typeId];
+#else
+ switch (QMetaType::Type(type)) {
+ QT_FOR_EACH_STATIC_TYPE(QT_METATYPE_TYPEID_TYPENAME_CONVERTER)
+ case QMetaType::UnknownType:
+ case QMetaType::User:
+ break;
+ }
+#endif
+ } else if (Q_UNLIKELY(type < QMetaType::User)) {
return nullptr; // It can happen when someone cast int to QVariant::Type, we should not crash...
}
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 8e906b278d..2f4f76856f 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -4655,12 +4655,8 @@ void qDeleteInEventHandler(QObject *o)
make sure to declare the argument type with Q_DECLARE_METATYPE
Overloaded functions can be resolved with help of \l qOverload.
-
- \note The number of arguments in the signal or slot are limited to 6 if
- the compiler does not support C++11 variadic templates.
*/
-
/*!
\fn QMetaObject::Connection QObject::connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
@@ -4683,7 +4679,7 @@ void qDeleteInEventHandler(QObject *o)
\snippet code/src_corelib_kernel_qobject.cpp 45
- If your compiler support C++11 lambda expressions, you can use them:
+ Lambda expressions can also be used:
\snippet code/src_corelib_kernel_qobject.cpp 46
@@ -4693,9 +4689,6 @@ void qDeleteInEventHandler(QObject *o)
Overloaded functions can be resolved with help of \l qOverload.
- \note If the compiler does not support C++11 variadic templates, the number
- of arguments in the signal or slot are limited to 6, and the functor object
- must not have an overloaded or templated operator().
*/
/*!
@@ -4726,7 +4719,7 @@ void qDeleteInEventHandler(QObject *o)
\snippet code/src_corelib_kernel_qobject.cpp 50
- If your compiler support C++11 lambda expressions, you can use them:
+ Lambda expressions can also be used:
\snippet code/src_corelib_kernel_qobject.cpp 51
@@ -4736,10 +4729,6 @@ void qDeleteInEventHandler(QObject *o)
are still alive when the signal is emitted.
Overloaded functions can be resolved with help of \l qOverload.
-
- \note If the compiler does not support C++11 variadic templates, the number
- of arguments in the signal or slot are limited to 6, and the functor object
- must not have an overloaded or templated operator().
*/
/*!
diff --git a/src/corelib/kernel/qtcore_eval.cpp b/src/corelib/kernel/qtcore_eval.cpp
index 787db8a8a6..86992ce10b 100644
--- a/src/corelib/kernel/qtcore_eval.cpp
+++ b/src/corelib/kernel/qtcore_eval.cpp
@@ -207,7 +207,9 @@ QT_BEGIN_INCLUDE_NAMESPACE
#include <qlabel.h>
#include <qlayout.h>
#include <qmessagebox.h>
+#if QT_CONFIG(pushbutton)
#include <qpushbutton.h>
+#endif
#include <qtimer.h>
#include <qapplication.h>
QT_END_INCLUDE_NAMESPACE
diff --git a/src/corelib/tools/qbytearraymatcher.h b/src/corelib/tools/qbytearraymatcher.h
index 476bc3c049..c1c0c3a660 100644
--- a/src/corelib/tools/qbytearraymatcher.h
+++ b/src/corelib/tools/qbytearraymatcher.h
@@ -83,7 +83,9 @@ private:
};
};
-class QStaticByteArrayMatcherBase {
+class QStaticByteArrayMatcherBase
+{
+ Q_DECL_ALIGN(16)
struct Skiptable {
uchar data[256];
} m_skiptable;
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
index 791a4970f0..8366e01ee8 100644
--- a/src/corelib/tools/qregularexpression.cpp
+++ b/src/corelib/tools/qregularexpression.cpp
@@ -54,6 +54,8 @@
#include <QtCore/qatomic.h>
#include <QtCore/qdatastream.h>
+#define PCRE2_CODE_UNIT_WIDTH 16
+
#include <pcre2.h>
QT_BEGIN_NAMESPACE