aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqml.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-05-14 08:42:12 +0200
committerUlf Hermann <ulf.hermann@qt.io>2021-05-17 22:24:36 +0200
commitc18b3e943af47c0ca0c35779eed770fc7b657274 (patch)
treea7af4dcd6d42cd268cdaed164778245dbe69ed3b /src/qml/qml/qqml.cpp
parentf4f1e348c01f8301cbebde870a5cef098baaa0b8 (diff)
Be more lenient about property caches when doing AOT lookups
If we know that a property is final, we don't have to consider overrides. Therefore, we can accept a derived class as subject of the lookup. It doesn't have to be the exact same class. Change-Id: I831c64b661730d78d12cec5c98e39282fc8742d8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqml.cpp')
-rw-r--r--src/qml/qml/qqml.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp
index f169474cb7..3514156c36 100644
--- a/src/qml/qml/qqml.cpp
+++ b/src/qml/qml/qqml.cpp
@@ -723,12 +723,21 @@ static void captureObjectProperty(
capture->captureProperty(object, propertyCache, property);
}
+static bool inherits(const QQmlPropertyCache *descendent, const QQmlPropertyCache *ancestor)
+{
+ for (const QQmlPropertyCache *cache = descendent; cache; cache = cache->parent()) {
+ if (cache == ancestor)
+ return true;
+ }
+ return false;
+}
+
static void loadObjectProperty(QV4::Lookup *l, QObject *object, void *target,
QQmlContextData *qmlContext)
{
- const QQmlPropertyCache *propertyCache = l->qobjectLookup.propertyCache;
Q_ASSERT(!QQmlData::wasDeleted(object));
- Q_ASSERT(QQmlData::get(object)->propertyCache == propertyCache);
+ const QQmlPropertyCache *propertyCache = l->qobjectLookup.propertyCache;
+ Q_ASSERT(inherits(QQmlData::get(object)->propertyCache, propertyCache));
const QQmlPropertyData *property = l->qobjectLookup.propertyData;
captureObjectProperty(object, propertyCache, property, qmlContext);
property->readProperty(object, target);
@@ -736,9 +745,8 @@ static void loadObjectProperty(QV4::Lookup *l, QObject *object, void *target,
static void storeObjectProperty(QV4::Lookup *l, QObject *object, void *value)
{
- const QQmlPropertyCache *propertyCache = l->qobjectLookup.propertyCache;
Q_ASSERT(!QQmlData::wasDeleted(object));
- Q_ASSERT(QQmlData::get(object)->propertyCache == propertyCache);
+ Q_ASSERT(inherits(QQmlData::get(object)->propertyCache, l->qobjectLookup.propertyCache));
const QQmlPropertyData *property = l->qobjectLookup.propertyData;
QQmlPropertyPrivate::removeBinding(object, QQmlPropertyIndex(property->coreIndex()));
property->writeProperty(object, value, {});