diff options
author | Ulf Hermann <[email protected]> | 2025-03-14 14:47:43 +0100 |
---|---|---|
committer | Ulf Hermann <[email protected]> | 2025-03-24 17:21:24 +0100 |
commit | 96a2ab231dc6e817a590cc3490562eeea6b7e862 (patch) | |
tree | 28eb25d1bb651f0aba3f9f06a53756fde2218b47 /src/qml/jsruntime/qv4qobjectwrapper.cpp | |
parent | 38f5768bcd49be5e500b31a255e56cc27ad3bc08 (diff) |
QtQml: Don't use bindables for bindings on value type aliases
Forwarding the bindability of aliases is a complicated affair because a
single alias can encompass two properties (the "core" and the "value
type" property). This change adds another flag to discern between "can
use the bindable for notifications" and "can install a QBinding on this
property". Those are different aspects. Deep aliases can still notify
via the bindable of the core property, but they cannot accept a
QBinding.
Accordingly, when querying the metaobject for a bindable of a value type
alias, return the bindable of the core property. This is the one you at
least meaningfully install an observer on. The bindable of the value
type property would be entirely useless.
Amends commit 1f40e12a844ca2939c86f19610590920841efb15.
Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-134688
Change-Id: Ib219657bcbd2e263285d54f8736cada74ac594f5
Reviewed-by: Fabian Kosmale <[email protected]>
Diffstat (limited to 'src/qml/jsruntime/qv4qobjectwrapper.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 87af49ffb9..1eebede8ca 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -369,9 +369,13 @@ ReturnedValue QObjectWrapper::getProperty( QQmlEnginePrivate *ep = engine->qmlEngine() ? QQmlEnginePrivate::get(engine->qmlEngine()) : nullptr; - if (ep && ep->propertyCapture && !property->isConstant()) - if (!property->isBindable() || ep->propertyCapture->expression->mustCaptureBindableProperty()) - ep->propertyCapture->captureProperty(object, property->coreIndex(), property->notifyIndex()); + if (ep && ep->propertyCapture && !property->isConstant()) { + if (!property->notifiesViaBindable() + || ep->propertyCapture->expression->mustCaptureBindableProperty()) { + ep->propertyCapture->captureProperty( + object, property->coreIndex(), property->notifyIndex()); + } + } if (property->isVarProperty()) { QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(object); @@ -648,7 +652,7 @@ void QObjectWrapper::setProperty( ScopedContext ctx(scope, f->scope()); // binding assignment. - if (property->isBindable()) { + if (property->acceptsQBinding()) { const QQmlPropertyIndex idx(property->coreIndex(), /*not a value type*/-1); auto [targetObject, targetIndex] = QQmlPropertyPrivate::findAliasTarget(object, idx); QUntypedPropertyBinding binding; @@ -659,6 +663,7 @@ void QObjectWrapper::setProperty( } else { binding = QQmlPropertyBinding::create(property, f->function(), object, callingQmlContext, ctx, targetObject, targetIndex); + } QUntypedBindable bindable; void *argv = {&bindable}; |