diff options
4 files changed, 25 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index f35c3011d3..d1aa2a09db 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1387,13 +1387,13 @@ void QQmlComponentPrivate::setInitialProperties(QV4::ExecutionEngine *engine, QV } } if (engine->hasException || !object) { - engine->hasException = false; + qmlWarning(createdComponent, engine->catchExceptionAsQmlError()); continue; } name = engine->newString(properties.last()); object->put(name, val); if (engine->hasException) { - engine->hasException = false; + qmlWarning(createdComponent, engine->catchExceptionAsQmlError()); continue; } else if (isTopLevelProperty) { auto prop = removePropertyFromRequired(createdComponent, name->toQString(), requiredProperties); diff --git a/tests/auto/quick/qquickloader/data/Component.qml b/tests/auto/quick/qquickloader/data/Component.qml new file mode 100644 index 0000000000..8a9318a0de --- /dev/null +++ b/tests/auto/quick/qquickloader/data/Component.qml @@ -0,0 +1,5 @@ +import QtQuick 2.15 + +Item { + property int i +} diff --git a/tests/auto/quick/qquickloader/data/initialPropertyTriggerException.qml b/tests/auto/quick/qquickloader/data/initialPropertyTriggerException.qml new file mode 100644 index 0000000000..457a6a4e26 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/initialPropertyTriggerException.qml @@ -0,0 +1,12 @@ +import QtQuick 2.15 + +Item { + id: root + Loader { + id: myloader + } + function f() {} + Component.onCompleted: { + myloader.setSource("Component.qml", {"i": root.f}); + } +} diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp index 698f410f9f..fcc6d0914d 100644 --- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp +++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp @@ -706,6 +706,11 @@ void tst_QQuickLoader::initialPropertyValues_data() << QStringList() << (QStringList() << "i") << (QVariantList() << 12); + + QTest::newRow("initial property errors get reported") << testFileUrl("initialPropertyTriggerException.qml") + << (QStringList() << "^.*:11: Error: Cannot assign JavaScript function to int") + << QStringList() + << QVariantList(); } void tst_QQuickLoader::initialPropertyValues() @@ -718,7 +723,7 @@ void tst_QQuickLoader::initialPropertyValues() ThreadedTestHTTPServer server(dataDirectory()); foreach (const QString &warning, expectedWarnings) - QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(warning.toLatin1().constData())); QQmlEngine engine; QQmlComponent component(&engine, qmlFile); |