diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-05-13 16:40:11 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-05-17 09:38:30 +0200 |
commit | 04f9219a388ce1f2e2f7d4a1f94e055ce42a22e7 (patch) | |
tree | 72291099370eee1553de74e96bb67d1fbf1a1116 /src/qml/qml/qqmlobjectcreator.cpp | |
parent | 2ebee301fd6629f2d5c604fd021c61c15692775f (diff) |
QQmlDelegateModel: Consider only top level required properties
Required properties deeper inside the delegate must not suppress the
passing of model data via the context.
Fixes: QTBUG-103479
Change-Id: I2d350d93633a87b90e7a7d08b1e26a06a966b24a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlobjectcreator.cpp')
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index b1bedc7c37..f3af43577d 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -82,6 +82,7 @@ QQmlObjectCreator::QQmlObjectCreator( , propertyCaches(&compilationUnit->propertyCaches) , sharedState(new QQmlObjectCreatorSharedState, QQmlRefPointer<QQmlObjectCreatorSharedState>::Adopt) , topLevelCreator(true) + , isContextObject(true) , incubator(incubator) { init(std::move(parentContext)); @@ -93,7 +94,7 @@ QQmlObjectCreator::QQmlObjectCreator( sharedState->allJavaScriptObjects = nullptr; sharedState->creationContext = creationContext; sharedState->rootContext.reset(); - sharedState->hadRequiredProperties = false; + sharedState->hadTopLevelRequiredProperties = false; if (auto profiler = QQmlEnginePrivate::get(engine)->profiler) { Q_QML_PROFILE_IF_ENABLED(QQmlProfilerDefinitions::ProfileCreating, profiler, @@ -103,15 +104,15 @@ QQmlObjectCreator::QQmlObjectCreator( } } -QQmlObjectCreator::QQmlObjectCreator( - QQmlRefPointer<QQmlContextData> parentContext, +QQmlObjectCreator::QQmlObjectCreator(QQmlRefPointer<QQmlContextData> parentContext, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, - QQmlObjectCreatorSharedState *inheritedSharedState) + QQmlObjectCreatorSharedState *inheritedSharedState, bool isContextObject) : phase(Startup) , compilationUnit(compilationUnit) , propertyCaches(&compilationUnit->propertyCaches) , sharedState(inheritedSharedState) , topLevelCreator(false) + , isContextObject(isContextObject) , incubator(nullptr) { init(std::move(parentContext)); @@ -1249,7 +1250,8 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo } if (!type.isInlineComponentType()) { - QQmlObjectCreator subCreator(context, compilationUnit, sharedState.data()); + QQmlObjectCreator subCreator(context, compilationUnit, sharedState.data(), + isContextObject); instance = subCreator.create(); if (!instance) { errors += subCreator.errors; @@ -1258,7 +1260,8 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo } else { int subObjectId = type.inlineComponentId(); QScopedValueRollback<int> rollback {compilationUnit->icRoot, subObjectId}; - QQmlObjectCreator subCreator(context, compilationUnit, sharedState.data()); + QQmlObjectCreator subCreator(context, compilationUnit, sharedState.data(), + isContextObject); instance = subCreator.create(subObjectId, nullptr, nullptr, CreationFlags::InlineComponent); if (!instance) { errors += subCreator.errors; @@ -1559,7 +1562,8 @@ bool QQmlObjectCreator::populateInstance(int index, QObject *instance, QObject * continue; if (postHocIt != postHocRequired.end()) postHocRequired.erase(postHocIt); - sharedState->hadRequiredProperties = true; + if (isContextObject) + sharedState->hadTopLevelRequiredProperties = true; sharedState->requiredProperties.insert(propertyData, RequiredPropertyInfo {compilationUnit->stringAt(property->nameIndex), compilationUnit->finalUrl(), property->location, {}}); @@ -1617,7 +1621,8 @@ bool QQmlObjectCreator::populateInstance(int index, QObject *instance, QObject * if (postHocIt != postHocRequired.end()) postHocRequired.erase(postHocIt); - sharedState->hadRequiredProperties = true; + if (isContextObject) + sharedState->hadTopLevelRequiredProperties = true; sharedState->requiredProperties.insert( propertyData, RequiredPropertyInfo { @@ -1647,7 +1652,8 @@ bool QQmlObjectCreator::populateInstance(int index, QObject *instance, QObject * continue; postHocRequired.erase(postHocIt); - sharedState->hadRequiredProperties = true; + if (isContextObject) + sharedState->hadTopLevelRequiredProperties = true; sharedState->requiredProperties.insert( propertyData, RequiredPropertyInfo { |