aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlbinding
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2019-07-04 10:39:43 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2019-07-04 12:29:41 +0200
commit9db3ec26136aa7a7ea58c85c92f5c6288e50e8f5 (patch)
tree042b46fecfbe3087868fc18f3b31386bd8663ea6 /tests/auto/qml/qqmlbinding
parent341ab7708049b1a3f559b76f16393e688951a938 (diff)
Fix crash when binding to QML component
As the properties were missing their context, we could not get the correct QMetaObject and would trigger an assertion in canConvert. We now always set the context when creating QQmlProperties in qqmlbind. Fixes: QTBUG-40487 Change-Id: I766c5697dc33fc1e18c2316e28d944975e84ae3c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlbinding')
-rw-r--r--tests/auto/qml/qqmlbinding/data/MyComponent.qml2
-rw-r--r--tests/auto/qml/qqmlbinding/data/bindToQMLComponent.qml12
-rw-r--r--tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp8
3 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlbinding/data/MyComponent.qml b/tests/auto/qml/qqmlbinding/data/MyComponent.qml
new file mode 100644
index 0000000000..5892539a5d
--- /dev/null
+++ b/tests/auto/qml/qqmlbinding/data/MyComponent.qml
@@ -0,0 +1,2 @@
+import QtQuick 2.3
+QtObject { property real p: 0 }
diff --git a/tests/auto/qml/qqmlbinding/data/bindToQMLComponent.qml b/tests/auto/qml/qqmlbinding/data/bindToQMLComponent.qml
new file mode 100644
index 0000000000..471db9023b
--- /dev/null
+++ b/tests/auto/qml/qqmlbinding/data/bindToQMLComponent.qml
@@ -0,0 +1,12 @@
+import QtQuick 2.0
+
+Item {
+ id: root
+ property MyComponent myProperty
+ Binding {
+ target: root
+ property: "myProperty"
+ value: myObject
+ }
+ MyComponent { id: myObject }
+}
diff --git a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp
index 717fd5dbd1..9b66cd828a 100644
--- a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp
+++ b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp
@@ -54,6 +54,7 @@ private slots:
void disabledOnReadonlyProperty();
void delayed();
void bindingOverwriting();
+ void bindToQmlComponent();
private:
QQmlEngine engine;
@@ -394,6 +395,13 @@ void tst_qqmlbinding::bindingOverwriting()
QCOMPARE(messageHandler.messages().count(), 2);
}
+void tst_qqmlbinding::bindToQmlComponent()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("bindToQMLComponent.qml"));
+ QVERIFY(c.create());
+}
+
QTEST_MAIN(tst_qqmlbinding)
#include "tst_qqmlbinding.moc"