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. 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> (cherry picked from commit e19bd973e3d15d62c6e959f52ae5db297b2fad7c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
c5685f6654
commit
6dbb5d3e45
@ -2577,6 +2577,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;
|
Returns \c true if the datatype with ID \a type is registered;
|
||||||
otherwise returns \c false.
|
otherwise returns \c false.
|
||||||
@ -2585,7 +2599,7 @@ void QMetaType::registerNormalizedTypedef(const NS(QByteArray) & normalizedTypeN
|
|||||||
*/
|
*/
|
||||||
bool QMetaType::isRegistered(int type)
|
bool QMetaType::isRegistered(int type)
|
||||||
{
|
{
|
||||||
return QMetaType(type).isRegistered();
|
return interfaceForTypeNoWarning(type) != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool tryNormalizedType>
|
template <bool tryNormalizedType>
|
||||||
@ -2943,15 +2957,7 @@ QMetaType QMetaType::fromName(QByteArrayView typeName)
|
|||||||
|
|
||||||
static const QtPrivate::QMetaTypeInterface *interfaceForType(int typeId)
|
static const QtPrivate::QMetaTypeInterface *interfaceForType(int typeId)
|
||||||
{
|
{
|
||||||
const QtPrivate::QMetaTypeInterface *iface = nullptr;
|
const QtPrivate::QMetaTypeInterface *iface = interfaceForTypeNoWarning(typeId);
|
||||||
if (typeId >= QMetaType::User) {
|
|
||||||
if (customTypeRegistry.exists())
|
|
||||||
iface = customTypeRegistry->getCustomType(typeId);
|
|
||||||
} else {
|
|
||||||
if (auto moduleHelper = qModuleHelperForType(typeId))
|
|
||||||
iface = moduleHelper->interfaceForType(typeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!iface && typeId != QMetaType::UnknownType)
|
if (!iface && typeId != QMetaType::UnknownType)
|
||||||
qWarning("Trying to construct an instance of an invalid type, type id: %i", typeId);
|
qWarning("Trying to construct an instance of an invalid type, type id: %i", typeId);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user