aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-01-18 14:32:00 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2021-01-18 14:58:30 +0100
commite98b48f55cdb57a369513100f82d7c1df99c1243 (patch)
tree327a296abcced1c8bb137eef652c6373ad46cf98 /tests/auto/quick
parent1fa352f0e0a62d0b445e9a2a01953f8afca29858 (diff)
QQmlComponentPrivate::setInitialProperties: Do not silently swallow exceptions
Instead, log them with qmlWarning. Change-Id: Icde7397085841a84aca8a81c716d552c4cd4485a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/qquickloader/data/Component.qml5
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyTriggerException.qml12
-rw-r--r--tests/auto/quick/qquickloader/tst_qquickloader.cpp7
3 files changed, 23 insertions, 1 deletions
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);