diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-10-06 13:30:19 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-10-12 19:14:47 +0200 |
commit | 63865ebd75ede8122011a19e58dc56c19978c91a (patch) | |
tree | 90f250b1c692475ea4d17407d39c82b3c80a97e5 /src/qml/jsruntime/qv4qmlcontext.cpp | |
parent | 852c8d1d8a953c626735f044838454a4d249c225 (diff) |
Avoid QAbstractDynamicMetaObject where possible
We don't want to copy metaobjects, but QAbstractDynamicMetaObject forces
us. Rather, use plain QDynamicMetaObjectData, and store a pointer to the
actual metaobject.
This requires us to drop the "isDirect()" optimization for property
access, as we realize that there can be dynamic meta objects which are
not QAbstractDynamicMetaObject. However, this optimization was
questionable anyway. What it did was cache the fact that an object might
have a dynamic metaobject in a flag. Checking this on the object itself
should not be much more expensive, though. On the other hand, an object
might receive a dynamic metaobject individually without us adjusting
flags for its type. In that case we would call the wrong method.
Furthermore, most property access can be done using the static metacall
function anyway.
Change-Id: I5897351253496309721bd38adf3e35a1f069b080
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4qmlcontext.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4qmlcontext.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4qmlcontext.cpp b/src/qml/jsruntime/qv4qmlcontext.cpp index 65481e4539..66693fb0d2 100644 --- a/src/qml/jsruntime/qv4qmlcontext.cpp +++ b/src/qml/jsruntime/qv4qmlcontext.cpp @@ -206,7 +206,10 @@ ReturnedValue QQmlContextWrapper::getPropertyAndBase(const QQmlContextWrapper *r // // Note: The scope object is only a QADMO for example when somebody registers a QQmlPropertyMap // sub-class as QML type and then instantiates it in .qml. - if (scopeObject && QQmlPropertyCache::isDynamicMetaObject(scopeObject->metaObject())) { + const QMetaObjectPrivate *metaObjectPrivate = scopeObject + ? reinterpret_cast<const QMetaObjectPrivate *>(scopeObject->metaObject()->d.data) + : nullptr; + if (metaObjectPrivate && metaObjectPrivate->flags & DynamicMetaObject) { // all bets are off, so don't try to optimize any lookups lookup = nullptr; if (performGobalLookUp()) |