diff options
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlcomponent_p.h | 26 | ||||
-rw-r--r-- | src/qml/types/qqmlbind.cpp | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickdeferredexecute.cpp | 2 |
4 files changed, 26 insertions, 8 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 2a284a6bf9..5a674b5c49 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1032,7 +1032,7 @@ QObject *QQmlComponentPrivate::beginCreate(QQmlRefPointer<QQmlContextData> conte state.initCreator(std::move(context), compilationUnit, creationContext); rv = state.creator()->create(start); if (!rv) - state.appendErrors(state.creator()->errors); + state.appendCreatorErrors(); enginePriv->dereferenceScarceResources(); } else { rv = loadedType.createWithQQmlData(); @@ -1071,7 +1071,7 @@ void QQmlComponentPrivate::beginDeferred(QQmlEnginePrivate *enginePriv, QQmlRefPointer<QQmlContextData>()); if (!creator->populateDeferredProperties(object, deferredData)) - state.appendErrors(creator->errors); + state.appendCreatorErrors(); deferredData->bindings.clear(); deferredState->push_back(std::move(state)); diff --git a/src/qml/qml/qqmlcomponent_p.h b/src/qml/qml/qqmlcomponent_p.h index c6b30cf2f5..f614b7e8a2 100644 --- a/src/qml/qml/qqmlcomponent_p.h +++ b/src/qml/qml/qqmlcomponent_p.h @@ -77,12 +77,15 @@ public: struct AnnotatedQmlError { AnnotatedQmlError() = default; - AnnotatedQmlError(const QQmlError &error) // convenience ctor - : error(error) + + AnnotatedQmlError(QQmlError error) + : error(std::move(error)) { } - AnnotatedQmlError(const QQmlError &error, bool transient) - : error(error), isTransient(transient) + + + AnnotatedQmlError(QQmlError error, bool transient) + : error(std::move(error)), isTransient(transient) { } QQmlError error; @@ -99,6 +102,21 @@ public: errors.emplaceBack(e); } + //! \internal Moves errors from creator into construction state itself + void appendCreatorErrors() + { + if (!hasCreator()) + return; + auto creatorErrorCount = creator()->errors.size(); + if (creatorErrorCount == 0) + return; + auto existingErrorCount = errors.size(); + errors.resize(existingErrorCount + creatorErrorCount); + for (qsizetype i = 0; i < creatorErrorCount; ++i) + errors[existingErrorCount + i] = AnnotatedQmlError { std::move(creator()->errors[i]) }; + creator()->errors.clear(); + } + QQmlObjectCreator *creator() {return m_creator.get(); } const QQmlObjectCreator *creator() const {return m_creator.get(); } bool hasCreator() const { return m_creator != nullptr; } diff --git a/src/qml/types/qqmlbind.cpp b/src/qml/types/qqmlbind.cpp index fb9a9d2221..ed52ecb557 100644 --- a/src/qml/types/qqmlbind.cpp +++ b/src/qml/types/qqmlbind.cpp @@ -885,7 +885,7 @@ void QQmlBindPrivate::buildBindEntries(QQmlBind *q, QQmlComponentPrivate::Deferr if (constructionState.hasCreator()) { ++ep->inProgressCreations; constructionState.creator()->finalizePopulateDeferred(); - constructionState.appendErrors(constructionState.creator()->errors); + constructionState.appendCreatorErrors(); deferredState->push_back(std::move(constructionState)); } } else { diff --git a/src/quicktemplates2/qquickdeferredexecute.cpp b/src/quicktemplates2/qquickdeferredexecute.cpp index 63f33d01e6..d7fd6c9e62 100644 --- a/src/quicktemplates2/qquickdeferredexecute.cpp +++ b/src/quicktemplates2/qquickdeferredexecute.cpp @@ -55,7 +55,7 @@ static bool beginDeferred(QQmlEnginePrivate *enginePriv, const QQmlProperty &pro for (const QV4::CompiledData::Binding *binding : reversedBindings) state.creator()->populateDeferredBinding(property, deferData->deferredIdx, binding); state.creator()->finalizePopulateDeferred(); - state.appendErrors(state.creator()->errors); + state.appendCreatorErrors(); deferredState->push_back(std::move(state)); |