diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2021-01-11 13:07:37 +0100 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2021-01-11 15:23:24 +0100 |
commit | 2c82f4f8b61e8d7c22a979ef7ca3ea0465da278d (patch) | |
tree | fdb054f199790947cf2e6b50c630882141ab5692 /src | |
parent | 8a3ede5ba1daf2d9314d71db972175b2791456c0 (diff) |
qqmlengine: Fix crash when encountering bad singletons
Previously errors occurring when parsing QML singletons would just be ignored resulting in a crash.
The errors are now properly printed and the execution is aborted in time.
Fixes: QTBUG-85932
Change-Id: I61cef5f97546ce2e0753bc46c548838a21b1f506
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index ef9fec56fb..5a20b93c2c 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -2391,6 +2391,12 @@ QJSValue QQmlEnginePrivate::singletonInstance<QJSValue>(const QQmlType &type) singletonInstances.convertAndInsert(v4engine(), type, &value); } else if (!siinfo->url.isEmpty()) { QQmlComponent component(q, siinfo->url, QQmlComponent::PreferSynchronous); + if (component.isError()) { + warning(component.errors()); + v4engine()->throwError(QLatin1String("Due to the preceding error(s), Singleton \"%1\" could not be loaded.").arg(QString::fromUtf8(type.typeName()))); + + return QJSValue(QJSValue::UndefinedValue); + } QObject *o = component.beginCreate(q->rootContext()); value = q->newQObject(o); singletonInstances.convertAndInsert(v4engine(), type, &value); |