Warn about constructing QMetaTypes/QVariants with invalid type ids
Warn about using an invalid type id in all cases. So far, only some constructors of QVariant would warn. Move the warning over to the place where we map a typeid to a QMetaTypeInterface to catch all cases. Change-Id: I4cd48a2b5d6c597dbf2afbeae9b811cd0819b768 Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
87bc5f7a7c
commit
30ad4cf558
@ -1735,6 +1735,8 @@ static QtPrivate::QMetaTypeInterface *interfaceForType(int typeId)
|
||||
QT_FOR_EACH_STATIC_CORE_POINTER(QT_METATYPE_CONVERT_ID_TO_TYPE)
|
||||
QT_FOR_EACH_STATIC_CORE_TEMPLATE(QT_METATYPE_CONVERT_ID_TO_TYPE)
|
||||
default:
|
||||
if (typeId != QMetaType::UnknownType)
|
||||
qWarning("Trying to construct an instance of an invalid type, type id: %i", typeId);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -1752,9 +1752,6 @@ Q_CORE_EXPORT void QVariantPrivate::registerHandler(const int /* Modules::Names
|
||||
void QVariant::create(int type, const void *copy)
|
||||
{
|
||||
d = Private(QMetaType(type));
|
||||
if (Q_UNLIKELY(type && !d.type().isValid())) {
|
||||
qWarning("Trying to construct an instance of an invalid type, type id: %i", type);
|
||||
}
|
||||
customConstruct(&d, copy);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user