diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2020-03-23 21:32:38 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2020-03-30 14:18:18 +0200 |
commit | dff7689a016d63fbaf1abc6f00a768dbfb8ec095 (patch) | |
tree | 6f0b67ce5d6dec279c0bbf62f014955cd0f25e32 /src/qml/qml/qqmlobjectcreator.cpp | |
parent | 9f2c5aa2efd24507f4508889911873bc1c9d301e (diff) |
Add support for binding directly to QProperty instances
Avoid going through externally managed bindings and instead allocate a
more lightweight property binding. It's basically a
QQmlJavaScriptExpression and one pointer plus the overhead of
QPropertyBindingPrivate.
Change-Id: I1530330926d351b61f2b3bbad39301c628a8bef1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlobjectcreator.cpp')
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 213e15e173..2ee2969d43 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -60,6 +60,7 @@ #include <private/qjsvalue_p.h> #include <private/qv4generatorobject_p.h> #include <private/qv4resolvedtypereference_p.h> +#include <private/qqmlpropertybinding_p.h> #include <QScopedValueRollback> @@ -917,6 +918,12 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *bindingProper _scopeObject, runtimeFunction, currentQmlContext()); bs->takeExpression(expr); + } else if (bindingProperty->isQProperty()) { + // ### TODO: support binding->isTranslationBinding() + QV4::Function *runtimeFunction = compilationUnit->runtimeFunctions[binding->value.compiledScriptIndex]; + auto qmlBinding = QQmlPropertyBinding::create(bindingProperty, runtimeFunction, _scopeObject, context, currentQmlContext()); + void *argv[] = { &qmlBinding }; + _bindingTarget->qt_metacall(QMetaObject::SetQPropertyBinding, bindingProperty->coreIndex(), argv); } else { // When writing bindings to grouped properties implemented as value types, // such as point.x: { someExpression; }, then the binding is installed on |