QMetaType: Assert on consistency when unregistering
If we are trying to unregister a metatype with an ID that belongs to a different metatype, then something is very wrong. Change-Id: I3191557883b69030f91c3aca7f359acf2dde66e7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
076026fd60
commit
3bc179c30d
@ -907,13 +907,22 @@ bool QMetaType::isOrdered() const
|
|||||||
*/
|
*/
|
||||||
void QMetaType::unregisterMetaType(QMetaType type)
|
void QMetaType::unregisterMetaType(QMetaType type)
|
||||||
{
|
{
|
||||||
if (type.d_ptr && type.d_ptr->typeId.loadRelaxed() >= QMetaType::User) {
|
const QtPrivate::QMetaTypeInterface *d_ptr = type.d_ptr;
|
||||||
// this is a custom meta type (not read-only)
|
if (!d_ptr)
|
||||||
auto d = const_cast<QtPrivate::QMetaTypeInterface *>(type.d_ptr);
|
return;
|
||||||
if (auto reg = customTypeRegistry())
|
|
||||||
reg->unregisterDynamicType(d->typeId.loadRelaxed());
|
const int typeId = d_ptr->typeId.loadRelaxed();
|
||||||
d->typeId.storeRelease(0);
|
if (typeId < QMetaType::User)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// this is a custom meta type (not read-only)
|
||||||
|
|
||||||
|
if (auto reg = customTypeRegistry()) {
|
||||||
|
Q_ASSERT(reg->getCustomType(typeId) == d_ptr);
|
||||||
|
reg->unregisterDynamicType(typeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const_cast<QtPrivate::QMetaTypeInterface *>(d_ptr)->typeId.storeRelease(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user