Make the canConvertMetaObject method safe
This triggered a crash in QtQml, where an manually created metattype interface set the PointerToQObject flag to true while not providing a metaobject. Change-Id: I206fb9655058a1e8a2d04e44186b05db33358338 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
02dfec9209
commit
75097c7782
@ -1968,9 +1968,10 @@ static bool convertToAssociativeIterable(QMetaType fromType, const void *from, v
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
static bool canConvertMetaObject(QMetaType fromType, QMetaType toType)
|
||||
{
|
||||
if ((fromType.flags() & QMetaType::PointerToQObject) && (toType.flags() & QMetaType::PointerToQObject)) {
|
||||
return fromType.metaObject()->inherits(toType.metaObject()) ||
|
||||
toType.metaObject()->inherits(fromType.metaObject());
|
||||
const QMetaObject *f = fromType.metaObject();
|
||||
const QMetaObject *t = toType.metaObject();
|
||||
if (f && t) {
|
||||
return f->inherits(t) || (t->inherits(f));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user