summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetatype.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2022-06-29 09:00:28 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2022-07-11 08:21:35 +0000
commite19bd973e3d15d62c6e959f52ae5db297b2fad7c (patch)
tree680024723a28ba044d2a6c3020175e365e3e5e89 /src/corelib/kernel/qmetatype.cpp
parent4851eae5ba4d8dcf88fc0155fa39638ce2464c43 (diff)
QMetaType: Do not warn about unknown types in isRegistered
isRegistered naturally has the potential to run into unregistered types; in that case, we should not print any warning. Pick-to: 6.4 6.3 6.2 Change-Id: I060b23199ed1d41f67ebe656ed3c396094edffd4 Reviewed-by: Stefan Gehn <stefan.gehn@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qmetatype.cpp')
-rw-r--r--src/corelib/kernel/qmetatype.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 2760a67e8a..13cac5f305 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -2593,6 +2593,20 @@ void QMetaType::registerNormalizedTypedef(const NS(QByteArray) & normalizedTypeN
}
}
+
+static const QtPrivate::QMetaTypeInterface *interfaceForTypeNoWarning(int typeId)
+{
+ const QtPrivate::QMetaTypeInterface *iface = nullptr;
+ if (typeId >= QMetaType::User) {
+ if (customTypeRegistry.exists())
+ iface = customTypeRegistry->getCustomType(typeId);
+ } else {
+ if (auto moduleHelper = qModuleHelperForType(typeId))
+ iface = moduleHelper->interfaceForType(typeId);
+ }
+ return iface;
+}
+
/*!
Returns \c true if the datatype with ID \a type is registered;
otherwise returns \c false.
@@ -2601,7 +2615,7 @@ void QMetaType::registerNormalizedTypedef(const NS(QByteArray) & normalizedTypeN
*/
bool QMetaType::isRegistered(int type)
{
- return QMetaType(type).isRegistered();
+ return interfaceForTypeNoWarning(type) != nullptr;
}
template <bool tryNormalizedType>
@@ -2959,15 +2973,7 @@ QMetaType QMetaType::fromName(QByteArrayView typeName)
static const QtPrivate::QMetaTypeInterface *interfaceForType(int typeId)
{
- const QtPrivate::QMetaTypeInterface *iface = nullptr;
- if (typeId >= QMetaType::User) {
- if (customTypeRegistry.exists())
- iface = customTypeRegistry->getCustomType(typeId);
- } else {
- if (auto moduleHelper = qModuleHelperForType(typeId))
- iface = moduleHelper->interfaceForType(typeId);
- }
-
+ const QtPrivate::QMetaTypeInterface *iface = interfaceForTypeNoWarning(typeId);
if (!iface && typeId != QMetaType::UnknownType)
qWarning("Trying to construct an instance of an invalid type, type id: %i", typeId);