QVariant: guard usage of fromType.metaObject()
This patch amends 19874d6a63. That patch caused a
crash to occur when running the auto test
tst_QQuickApplicationWindow::attachedProperties().
The crash can be traced back to QMetaType trying
to access fromType.metaObject(), which is null.
This patch will add a guard to ensure that we
don't try to call a function on an object that is null.
Fixes: QTBUG-86517
Change-Id: Idafd154a7b6a43e16126038fc5f9b30d7871f0d0
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
bb10
parent
3a1dad83ed
commit
f9f1043e8a
|
|
@ -2049,7 +2049,7 @@ bool QMetaType::convert(QMetaType fromType, const void *from, QMetaType toType,
|
|||
if (fromObject && fromObject->metaObject()->inherits(toType.metaObject())) {
|
||||
*static_cast<QObject **>(to) = toType.metaObject()->cast(fromObject);
|
||||
return true;
|
||||
} else if (!fromObject) {
|
||||
} else if (!fromObject && fromType.metaObject()) {
|
||||
// if fromObject is null, use static fromType to check if conversion works
|
||||
*static_cast<void **>(to) = nullptr;
|
||||
return fromType.metaObject()->inherits(toType.metaObject());
|
||||
|
|
|
|||
Loading…
Reference in New Issue