aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqml.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-04-19 17:33:47 +0200
committerUlf Hermann <ulf.hermann@qt.io>2021-04-22 22:14:54 +0200
commit92b99e85bb294d598a8143f33eab5bbce3fbebaa (patch)
tree94bcb5a1b56e221f4508853ffa9a955051c10e21 /src/qml/qml/qqml.cpp
parent297a3479c6b7c5220deccb1baf8806c2c15be9ed (diff)
Provide optimized variant of QmlContextPropertyLookup for AOT
Change-Id: Ie06b029850b74e98d6d6e38b480cedef4e481691 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqml.cpp')
-rw-r--r--src/qml/qml/qqml.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp
index a0fbe507fd..ebfde26a67 100644
--- a/src/qml/qml/qqml.cpp
+++ b/src/qml/qml/qqml.cpp
@@ -755,6 +755,21 @@ QObject *QQmlPrivate::AOTCompiledContext::loadQmlContextPropertyIdLookup(uint in
return o ? o->object() : nullptr;
}
+bool QQmlPrivate::AOTCompiledContext::loadQmlContextPropertyLookup(
+ uint index, void *target, QMetaType type) const
+{
+ QV4::Lookup *l = compilationUnit->runtimeLookups + index;
+ QV4::Scope scope(engine->handle());
+ QV4::ScopedValue result(scope, l->qmlContextPropertyGetter(l, scope.engine, nullptr));
+ if (type == QMetaType::fromType<QVariant>()) {
+ // Special case QVariant in order to retain JS objects.
+ // We don't want to convert JS arrays into QVariantList, for example.
+ *static_cast<QVariant *>(target) = scope.engine->toVariant(result, QMetaType {});
+ return true;
+ }
+ return scope.engine->metaTypeFromJS(result, type, target);
+}
+
bool QQmlPrivate::AOTCompiledContext::getObjectLookup(
uint index, QObject *object, void *target, QMetaType type) const
{