diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2021-03-01 15:34:58 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-03-04 09:30:21 +0000 |
commit | 6898e59357a0a5f7c3b369aa270a3338ffa78da7 (patch) | |
tree | 61c9b56785d06b2e9093e5c625594eb0906faa61 /src | |
parent | 5ef7e0b285992120e3a1d32418fe19a2614e6e47 (diff) |
qqmlapplicationengine: Handle errors during component creation
Previously QQmlApplicationEngine did not handle any errors that occurred during object creation
(i.e. failures to initialize required properties) which lead to QObject::connect errors and to
the error messages not getting printed among other issues.
Change-Id: I69bc566a6d349c786cae82a963a621388684c8f5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 890cb4cb236333fd5b112fffc0e9088ecb43f2df)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/qml/qqmlapplicationengine.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp index d866301f84..e0ab25892f 100644 --- a/src/qml/qml/qqmlapplicationengine.cpp +++ b/src/qml/qml/qqmlapplicationengine.cpp @@ -152,6 +152,14 @@ void QQmlApplicationEnginePrivate::finishLoad(QQmlComponent *c) break; case QQmlComponent::Ready: { auto newObj = initialProperties.empty() ? c->create() : c->createWithInitialProperties(initialProperties); + + if (c->isError()) { + qWarning() << "QQmlApplicationEngine failed to create component"; + warning(c->errors()); + q->objectCreated(nullptr, c->url()); + break; + } + objects << newObj; QObject::connect(newObj, &QObject::destroyed, q, [&](QObject *obj) { objects.removeAll(obj); }); q->objectCreated(objects.constLast(), c->url()); |