diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-11-01 09:30:04 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-11-02 22:05:00 +0100 |
commit | 41f0e7d085fcca73212c7d684338bf8c3e36ddf5 (patch) | |
tree | 43a682207cc9a21014dcbf3972f062c1df1f4b69 /src | |
parent | c9d9448353a7b11bc8a3a93c496fa19fd0d54a65 (diff) |
Allow attached properties in generalized grouped properties
As a side effect this also removes the restriction on attached
properties in regular grouped properties. This restriction was an
artifact of a past implementation detail.
Task-number: QTBUG-95117
Change-Id: I8761e350ed476dc02663b8fb9e1888f0b1392392
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/qml/qqmlpropertycachecreator_p.h | 51 | ||||
-rw-r--r-- | src/qml/qml/qqmlpropertyvalidator.cpp | 4 |
2 files changed, 36 insertions, 19 deletions
diff --git a/src/qml/qml/qqmlpropertycachecreator_p.h b/src/qml/qml/qqmlpropertycachecreator_p.h index cabaff38fc..969a5b4e2d 100644 --- a/src/qml/qml/qqmlpropertycachecreator_p.h +++ b/src/qml/qml/qqmlpropertycachecreator_p.h @@ -340,24 +340,39 @@ inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObjectRecur } } - if (QQmlPropertyCache *thisCache = propertyCaches->at(objectIndex)) { - auto binding = obj->bindingsBegin(); - auto end = obj->bindingsEnd(); - for ( ; binding != end; ++binding) - if (binding->type >= QV4::CompiledData::Binding::Type_Object) { - QQmlBindingInstantiationContext context(objectIndex, &(*binding), stringAt(binding->propertyNameIndex), thisCache); - - // Binding to group property where we failed to look up the type of the - // property? Possibly a group property that is an alias that's not resolved yet. - // Let's attempt to resolve it after we're done with the aliases and fill in the - // propertyCaches entry then. - if (!context.resolveInstantiatingProperty()) - pendingGroupPropertyBindings->append(context); - - QQmlError error = buildMetaObjectRecursively(binding->value.objectIndex, context, VMEMetaObjectIsRequired::Maybe); - if (error.isValid()) - return error; - } + QQmlPropertyCache *thisCache = propertyCaches->at(objectIndex); + auto binding = obj->bindingsBegin(); + auto end = obj->bindingsEnd(); + for (; binding != end; ++binding) { + switch (binding->type) { + case QV4::CompiledData::Binding::Type_Object: + case QV4::CompiledData::Binding::Type_GroupProperty: + // We can resolve object and group properties if we have a property cache. + if (thisCache) + break; + continue; + case QV4::CompiledData::Binding::Type_AttachedProperty: + // We can always resolve attached properties. + break; + default: + // Everything else is of no interest here. + continue; + } + + QQmlBindingInstantiationContext context( + objectIndex, &(*binding), stringAt(binding->propertyNameIndex), thisCache); + + // Binding to group property where we failed to look up the type of the + // property? Possibly a group property that is an alias that's not resolved yet. + // Let's attempt to resolve it after we're done with the aliases and fill in the + // propertyCaches entry then. + if (!thisCache || !context.resolveInstantiatingProperty()) + pendingGroupPropertyBindings->append(context); + + QQmlError error = buildMetaObjectRecursively( + binding->value.objectIndex, context, VMEMetaObjectIsRequired::Maybe); + if (error.isValid()) + return error; } QQmlError noError; diff --git a/src/qml/qml/qqmlpropertyvalidator.cpp b/src/qml/qml/qqmlpropertyvalidator.cpp index 6e0a578f6c..017648b88c 100644 --- a/src/qml/qml/qqmlpropertyvalidator.cpp +++ b/src/qml/qml/qqmlpropertyvalidator.cpp @@ -248,7 +248,7 @@ QVector<QQmlError> QQmlPropertyValidator::validateObject( continue; } - if (binding->type == QV4::CompiledData::Binding::Type_AttachedProperty + if ((pd && binding->type == QV4::CompiledData::Binding::Type_AttachedProperty) || (!pd && binding->type == QV4::CompiledData::Binding::Type_GroupProperty)) { if (instantiatingBinding && (instantiatingBinding->isAttachedProperty() || instantiatingBinding->isGroupProperty())) { @@ -259,6 +259,8 @@ QVector<QQmlError> QQmlPropertyValidator::validateObject( : QStringLiteral("Group"))); } continue; + } else if (binding->type == QV4::CompiledData::Binding::Type_AttachedProperty) { + continue; } if (pd) { |