diff options
author | Andrei Golubev <andrei.golubev@qt.io> | 2022-06-14 10:35:42 +0200 |
---|---|---|
committer | Andrei Golubev <andrei.golubev@qt.io> | 2022-06-30 20:26:21 +0200 |
commit | 79f9e22ef7e18af289457c0c4030f1e2af870213 (patch) | |
tree | d95e9973401e5bfc0c8328050afe3576bdd321a2 /src/qml/types/qqmlbind.cpp | |
parent | d968b23671d596d3502555f41feb38d046cb6414 (diff) |
Do not store instantiation errors in QQmlComponent
QQmlComponent::createWithInitialProperties() allows to pass non-existent
properties to create the object with. In this case, we still return a
valid pointer (pre-existing), however, the state of the component is
affected: there are errors internally that fail repeated calls even with
valid properties specified. Fix this, aligning to the behavior of
QQmlComponent::createObject() which is a QML counterpart of the same
function (to a degree)
Additionally, make required properties warnings also not break the
component state: if a required property is not set, we return nullptr
instead of object. The error state is affected but it gets cleaned
on the next creation call, allowing one to set the missing required
properties
Unify the logic (with slight deviations) between create() (the
non-incubator-accepting version), createWithInitialProperties() and
createObject() as all they all should do roughly equivalent things
[ChangeLog][QQmlComponent][Important Behavior Changes] Setting properties
via createWithInitialProperties() and setInitialProperties() no longer
affects the QQmlComponent's error state unless there are unset required
properties. A warning is issued when a property could not be set.
Fixes: QTBUG-101439
Change-Id: I814c00bc3715d7a54004c3fcd0af6ee6d50b0726
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/types/qqmlbind.cpp')
-rw-r--r-- | src/qml/types/qqmlbind.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/qml/types/qqmlbind.cpp b/src/qml/types/qqmlbind.cpp index fb2664da73..522dc48c92 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.creator.get()) { ++ep->inProgressCreations; constructionState.creator->finalizePopulateDeferred(); - constructionState.errors << constructionState.creator->errors; + constructionState.appendErrors(constructionState.creator->errors); deferredState->push_back(std::move(constructionState)); } } else { |