diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2022-10-31 11:17:03 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2022-11-10 15:00:11 +0100 |
commit | 826d4eb5ac97f8f35b242eb2096cc36ade6ee236 (patch) | |
tree | 407fbf8408c8ea4a608dd6eb302dd12d6cff56a2 /src/qml/qml/qqmlcomponent_p.h | |
parent | 0e4e74bffc102d6e8e3f220562231914b75c8027 (diff) |
ConstructionState: Add helper function to take errors from creator
As a drive-by, let AnnotatedQmlError's ctors take the QQmlError by
value, and move-construct it into the member.
Change-Id: I4c7aea5a966cfdb45abdc74ee352d5dd41b73aba
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlcomponent_p.h')
-rw-r--r-- | src/qml/qml/qqmlcomponent_p.h | 26 |
1 files changed, 22 insertions, 4 deletions
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; } |