diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-11-05 15:00:24 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-11-09 00:03:09 +0100 |
commit | 5fee28537b5f2ed6f1ca1558545597b66ec22270 (patch) | |
tree | fe3580bd5ca31c45d4ffc927bcb50b165d706d48 /src/qml/qml/qqmlpropertyvalidator.cpp | |
parent | 13a0da5bd2cf59aeb343fe9345b9bac2cfbb5e6f (diff) |
Clean up PropertyCache life cycle
We generally want to use QQmlRefPointer for it, rather than manually
calling addref() and release() all over the place. Also, we can
completely inline its ctor and drop an unused member.
Also, do not keep property caches of dynamic meta objects in type
registry. The dynamic metaobjects will change, and the outdated
property caches will eventually be retrieved.
Change-Id: I8042c85b32f3031b554f97a35c1545a3412d2acb
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlpropertyvalidator.cpp')
-rw-r--r-- | src/qml/qml/qqmlpropertyvalidator.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/qml/qml/qqmlpropertyvalidator.cpp b/src/qml/qml/qqmlpropertyvalidator.cpp index 1a19f92069..8e60afb57d 100644 --- a/src/qml/qml/qqmlpropertyvalidator.cpp +++ b/src/qml/qml/qqmlpropertyvalidator.cpp @@ -151,7 +151,7 @@ QVector<QQmlError> QQmlPropertyValidator::validateObject( QString defaultPropertyName; QQmlPropertyData *defaultProperty = nullptr; if (obj->indexOfDefaultPropertyOrAlias != -1) { - QQmlPropertyCache *cache = propertyCache->parent(); + QQmlPropertyCache *cache = propertyCache->parent().data(); defaultPropertyName = cache->defaultPropertyName(); defaultProperty = cache->defaultProperty(); } else { @@ -379,7 +379,9 @@ QVector<QQmlError> QQmlPropertyValidator::validateObject( return noError; } -QQmlError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache *propertyCache, QQmlPropertyData *property, const QV4::CompiledData::Binding *binding) const +QQmlError QQmlPropertyValidator::validateLiteralBinding( + const QQmlRefPointer<QQmlPropertyCache> &propertyCache, QQmlPropertyData *property, + const QV4::CompiledData::Binding *binding) const { if (property->isQList()) { return qQmlCompileError(binding->valueLocation, tr("Cannot assign primitives to lists")); @@ -659,9 +661,9 @@ QQmlError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache *prope */ bool QQmlPropertyValidator::canCoerce(QMetaType to, QQmlPropertyCache *fromMo) const { - QQmlPropertyCache *toMo = enginePrivate->rawPropertyCacheForType(to); + QQmlRefPointer<QQmlPropertyCache> toMo = enginePrivate->rawPropertyCacheForType(to); - if (toMo == nullptr) { + if (toMo.isNull()) { // if we have an inline component from the current file, // it is not properly registered at this point, as registration // only occurs after the whole file has been validated @@ -677,7 +679,7 @@ bool QQmlPropertyValidator::canCoerce(QMetaType to, QQmlPropertyCache *fromMo) c while (fromMo) { if (fromMo == toMo) return true; - fromMo = fromMo->parent(); + fromMo = fromMo->parent().data(); } return false; } @@ -769,7 +771,8 @@ QQmlError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *propert // actual property type before we applied any extensions that might // effect the properties on the type, but don't effect assignability // Not passing a version ensures that we get the raw metaObject. - QQmlPropertyCache *propertyMetaObject = enginePrivate->rawPropertyCacheForType(propType); + QQmlRefPointer<QQmlPropertyCache> propertyMetaObject + = enginePrivate->rawPropertyCacheForType(propType); if (!propertyMetaObject) { // if we have an inline component from the current file, // it is not properly registered at this point, as registration @@ -790,7 +793,7 @@ QQmlError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *propert QQmlPropertyCache *c = propertyCaches.at(binding->value.objectIndex); while (c && !isAssignable) { isAssignable |= c == propertyMetaObject; - c = c->parent(); + c = c->parent().data(); } if (!isAssignable) { |