diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-10-05 17:02:03 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-10-19 20:32:01 +0200 |
commit | a824a6f060ec3a0000d7349649a3ab9e0570ecaa (patch) | |
tree | 9574d4f96d52bf0de792bab52d42bd35a08027e6 /src/qml/jsruntime/qv4qmlcontext.cpp | |
parent | e89a06753c772bd96b3299e03b2f7ad78ffc9fb9 (diff) |
Recursively write back value types and sequences
Both types have functionality to write themselves back to the properties
they were loaded from on change, but so far we could not nest those
writes.
[ChangeLog][QtQml] You can now assign to properties of nested value
types and to elements of containers from QML functions. You cannot,
however, take references of such values and elements. This is in
contrast to non-nested value types and the containers themselves.
However, passing references of value types and containers around
generally leads to very confusing effects. Don't do this.
Fixes: QTBUG-99766
Change-Id: I74cb89e5c3d733b0b61e42969d617b2ecc1562f4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4qmlcontext.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4qmlcontext.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/qml/jsruntime/qv4qmlcontext.cpp b/src/qml/jsruntime/qv4qmlcontext.cpp index 1a1636a988..1cabf7c6c2 100644 --- a/src/qml/jsruntime/qv4qmlcontext.cpp +++ b/src/qml/jsruntime/qv4qmlcontext.cpp @@ -277,14 +277,16 @@ ReturnedValue QQmlContextWrapper::getPropertyAndBase(const QQmlContextWrapper *r bool hasProp = false; const QQmlPropertyData *propertyData = nullptr; + + QV4::ScopedObject wrapper(scope, QV4::QObjectWrapper::wrap(v4, scopeObject)); QV4::ScopedValue result(scope, QV4::QObjectWrapper::getQmlProperty( - v4, context, scopeObject, name, getQmlPropertyFlags(lookup), - &hasProp, &propertyData)); + v4, context, wrapper->d(), scopeObject, name, + getQmlPropertyFlags(lookup), &hasProp, &propertyData)); if (hasProp) { if (hasProperty) *hasProperty = true; if (base) - *base = QV4::QObjectWrapper::wrap(v4, scopeObject); + *base = wrapper; if (lookup && propertyData) { QQmlData *ddata = QQmlData::get(scopeObject, false); @@ -318,14 +320,15 @@ ReturnedValue QQmlContextWrapper::getPropertyAndBase(const QQmlContextWrapper *r if (QObject *contextObject = context->contextObject()) { bool hasProp = false; const QQmlPropertyData *propertyData = nullptr; + QV4::ScopedObject wrapper(scope, QV4::QObjectWrapper::wrap(v4, contextObject)); result = QV4::QObjectWrapper::getQmlProperty( - v4, context, contextObject, name, getQmlPropertyFlags(lookup), + v4, context, wrapper->d(), contextObject, name, getQmlPropertyFlags(lookup), &hasProp, &propertyData); if (hasProp) { if (hasProperty) *hasProperty = true; if (base) - *base = QV4::QObjectWrapper::wrap(v4, contextObject); + *base = wrapper; if (propertyData) { if (lookup) { @@ -750,11 +753,13 @@ ReturnedValue QQmlContextWrapper::lookupInParentContextHierarchy(Lookup *l, Exec // Search context object if (QObject *contextObject = context->contextObject()) { bool hasProp = false; + QV4::ScopedObject wrapper(scope, QV4::QObjectWrapper::wrap(engine, contextObject)); result = QV4::QObjectWrapper::getQmlProperty( - engine, context, contextObject, name, getQmlPropertyFlags(l), &hasProp); + engine, context, wrapper->d(), contextObject, name, getQmlPropertyFlags(l), + &hasProp); if (hasProp) { if (base) - *base = QV4::QObjectWrapper::wrap(engine, contextObject); + *base = wrapper; return result->asReturnedValue(); } |