summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetatype.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-10-09 15:33:05 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-10-18 13:48:16 +0200
commit9ceedd586321a2eeac4b63ee90d4e9726e143b78 (patch)
tree0647908ccaf4f4eca43140880eef4d4efe30f43d /src/corelib/kernel/qmetatype.cpp
parent0b0acce5a7b2b209e6359e64d91d300a4eb70a3c (diff)
Make most of QMetaTypeInterface constexpr
The only thing we need to modify at runtime is the typeId and that can be mutable. This way we can have a constexpr ctor for QMetaType which hopefully makes the importing and exporting of related symbols less fickle. On Windows we cannot make QMetaTypeForType constexpr as that leads to mysterious errors in other places. Until we figure out why that is, we just leave this class as non-constexpr. This reveals that qcoreapplication.h and qvariant.h are using QDebug without including it. We now get template instantiation errors. Include qdebug.h to avoid that. Change-Id: If1bf0437ada52459c59c6fa45bab3d22dfb0bc92 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel/qmetatype.cpp')
-rw-r--r--src/corelib/kernel/qmetatype.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index c9a0a40cd0..d9de26141c 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -107,12 +107,12 @@ struct DefinedTypesFilter {
struct QMetaTypeCustomRegistry
{
QReadWriteLock lock;
- QList<QtPrivate::QMetaTypeInterface *> registry;
- QHash<QByteArray, QtPrivate::QMetaTypeInterface *> aliases;
+ QList<const QtPrivate::QMetaTypeInterface *> registry;
+ QHash<QByteArray, const QtPrivate::QMetaTypeInterface *> aliases;
// index of first empty (unregistered) type in registry, if any.
int firstEmpty = 0;
- int registerCustomType(QtPrivate::QMetaTypeInterface *ti)
+ int registerCustomType(const QtPrivate::QMetaTypeInterface *ti)
{
{
QWriteLocker l(&lock);
@@ -168,7 +168,7 @@ struct QMetaTypeCustomRegistry
firstEmpty = std::min(firstEmpty, idx);
}
- QtPrivate::QMetaTypeInterface *getCustomType(int id)
+ const QtPrivate::QMetaTypeInterface *getCustomType(int id)
{
QReadLocker l(&lock);
return registry.value(id - QMetaType::User - 1);
@@ -847,7 +847,7 @@ static const struct : QMetaTypeModuleHelper
return !(str.isEmpty() || str == LiteralWrapper("0") || str == LiteralWrapper("false"));
}
- QtPrivate::QMetaTypeInterface *interfaceForType(int type) const override {
+ const QtPrivate::QMetaTypeInterface *interfaceForType(int type) const override {
switch (type) {
QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(QT_METATYPE_CONVERT_ID_TO_TYPE)
QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(QT_METATYPE_CONVERT_ID_TO_TYPE)
@@ -2898,9 +2898,9 @@ QMetaType QMetaType::fromName(QByteArrayView typeName)
\sa Q_DECLARE_METATYPE(), QMetaType::type()
*/
-static QtPrivate::QMetaTypeInterface *interfaceForType(int typeId)
+static const QtPrivate::QMetaTypeInterface *interfaceForType(int typeId)
{
- QtPrivate::QMetaTypeInterface *iface = nullptr;
+ const QtPrivate::QMetaTypeInterface *iface = nullptr;
if (typeId >= QMetaType::User) {
if (auto reg = customTypeRegistry())
iface = reg->getCustomType(typeId);