From cbd6273833c5910c77748c15a8ac83cc5080bd71 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Tue, 24 Sep 2019 08:51:52 +0200 Subject: required properties: move hadRequiredProperties to shared state If hadRequiredProperties is a property of a specific object creator instance, we lose the information until the required property gets noticed in the toplevel creator. By storing it in sharedState, hadRequiredProperties will always be set in case we encountered a required property. Change-Id: I226604175febe36406ca4eae57cab2a3a6be9777 Reviewed-by: Qt CI Bot Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlobjectcreator.cpp | 4 ++-- src/qml/qml/qqmlobjectcreator_p.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index d2e9d36d55..dfcab6181d 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -82,7 +82,6 @@ QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, const QQmlR , propertyCaches(&compilationUnit->propertyCaches) , sharedState(new QQmlObjectCreatorSharedState) , topLevelCreator(true) - , hadRequiredProperties(false) , incubator(incubator) { init(parentContext); @@ -94,6 +93,7 @@ QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, const QQmlR sharedState->allJavaScriptObjects = nullptr; sharedState->creationContext = creationContext; sharedState->rootContext = nullptr; + sharedState->hadRequiredProperties = false; if (auto profiler = QQmlEnginePrivate::get(engine)->profiler) { Q_QML_PROFILE_IF_ENABLED(QQmlProfilerDefinitions::ProfileCreating, profiler, @@ -1524,7 +1524,7 @@ bool QQmlObjectCreator::populateInstance(int index, QObject *instance, QObject * const QV4::CompiledData::Property* property = _compiledObject->propertiesBegin() + propertyIndex; QQmlPropertyData *propertyData = _propertyCache->property(_propertyCache->propertyOffset() + propertyIndex); if (property->isRequired) { - hadRequiredProperties = true; + sharedState->hadRequiredProperties = true; sharedState->requiredProperties.insert(propertyData, RequiredPropertyInfo {compilationUnit->stringAt(property->nameIndex), compilationUnit->finalUrl(), property->location, {}}); } diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h index c302660799..59e236c855 100644 --- a/src/qml/qml/qqmlobjectcreator_p.h +++ b/src/qml/qml/qqmlobjectcreator_p.h @@ -101,6 +101,7 @@ struct QQmlObjectCreatorSharedState : public QSharedData QQmlVmeProfiler profiler; QRecursionNode recursionNode; RequiredProperties requiredProperties; + bool hadRequiredProperties; }; class Q_QML_PRIVATE_EXPORT QQmlObjectCreator @@ -126,7 +127,7 @@ public: QFiniteStack > &allCreatedObjects() { return sharedState->allCreatedObjects; } RequiredProperties &requiredProperties() {return sharedState->requiredProperties;} - bool componentHadRequiredProperties() const {return hadRequiredProperties;} + bool componentHadRequiredProperties() const {return sharedState->hadRequiredProperties;} private: QQmlObjectCreator(QQmlContextData *contextData, const QQmlRefPointer &compilationUnit, QQmlObjectCreatorSharedState *inheritedSharedState); @@ -173,7 +174,6 @@ private: const QQmlPropertyCacheVector *propertyCaches; QExplicitlySharedDataPointer sharedState; bool topLevelCreator; - bool hadRequiredProperties; QQmlIncubatorPrivate *incubator; QObject *_qobject; -- cgit v1.2.3