diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-04-23 09:43:34 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-04-23 13:30:02 +0200 |
commit | 45ba08cfd860841f3311d89480618e6f580c8aa4 (patch) | |
tree | c20f69ba51926a45849d965b914b55d85c0df41d /src/qml/qml/qqml.cpp | |
parent | e29cbde522a3723f9bc087dd1263ae9e1e429208 (diff) |
Drop further sanity checks from AOT lookups
The caller has to make sure the types match. We only check for QVariant.
Change-Id: I17d08cab650f9f4d467fa61e2f285f045b73ba0c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqml.cpp')
-rw-r--r-- | src/qml/qml/qqml.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp index 7288850784..9da48fc0e0 100644 --- a/src/qml/qml/qqml.cpp +++ b/src/qml/qml/qqml.cpp @@ -779,7 +779,7 @@ static void *transformVariant(void *target, QMetaType propertyType) return v->data(); } -static bool loadObjectProperty(QV4::Lookup *l, QObject *object, void *target, QMetaType type, +static void loadObjectProperty(QV4::Lookup *l, QObject *object, void *target, QMetaType type, QQmlContextData *qmlContext) { const QQmlPropertyCache *propertyCache = l->qobjectLookup.propertyCache; @@ -787,18 +787,17 @@ static bool loadObjectProperty(QV4::Lookup *l, QObject *object, void *target, QM Q_ASSERT(QQmlData::get(object)->propertyCache == propertyCache); const QQmlPropertyData *property = l->qobjectLookup.propertyData; const QMetaType propertyType = property->propType(); - if (propertyType == type) { - // We can directly read the property into the target, without conversion. - captureObjectProperty(object, propertyCache, property, qmlContext); - property->readProperty(object, target); - return true; - } else if (type == QMetaType::fromType<QVariant>()) { - // We can also read into the contents of a QVariant without conversion. + if (type != propertyType && type == QMetaType::fromType<QVariant>()) { + // We can read into the contents of a QVariant without conversion. captureObjectProperty(object, propertyCache, property, qmlContext); property->readProperty(object, transformVariant(target, propertyType)); - return true; + } else { + Q_ASSERT(propertyType == type + || (type.flags() & QMetaType::PointerToQObject + && propertyType.flags() & QMetaType::PointerToQObject)); + captureObjectProperty(object, propertyCache, property, qmlContext); + property->readProperty(object, target); } - return false; } bool QQmlPrivate::AOTCompiledContext::loadQmlContextPropertyLookup( @@ -806,8 +805,8 @@ bool QQmlPrivate::AOTCompiledContext::loadQmlContextPropertyLookup( { QV4::Lookup *l = compilationUnit->runtimeLookups + index; if (l->qmlContextPropertyGetter == QV4::QQmlContextWrapper::lookupScopeObjectProperty) { - if (loadObjectProperty(l, qmlScopeObject, target, type, qmlContext)) - return true; + loadObjectProperty(l, qmlScopeObject, target, type, qmlContext); + return true; } QV4::Scope scope(engine->handle()); @@ -830,8 +829,8 @@ bool QQmlPrivate::AOTCompiledContext::getObjectLookup( return false; if (l->getter == QV4::QObjectWrapper::lookupGetter) { - if (loadObjectProperty(l, object, target, type, qmlContext)) - return true; + loadObjectProperty(l, object, target, type, qmlContext); + return true; } QV4::Scope scope(engine->handle()); |