aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-11-29 11:16:16 +0100
committerUlf Hermann <ulf.hermann@qt.io>2019-12-03 10:03:52 +0100
commita2f7de70d60a9ac212a575cae2387adfb0e5426b (patch)
treecfefd18ce6a6b3f87de760a49135e17e9f00fe2c /tests
parent265a6dc6e294f00fd12d87d2ceeb48e4ee505306 (diff)
QQmlDelegateModel: Read values from the correct object
If we have a proxyObject, we need to use that one for reading proxy values. Otherwise the read operation will crash. Fixes: QTBUG-80420 Change-Id: I88cd5499802bff1aea2e43da9ab61d6565ab7ede Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/readFromProxyObject.qml23
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp16
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickvisualdatamodel/data/readFromProxyObject.qml b/tests/auto/quick/qquickvisualdatamodel/data/readFromProxyObject.qml
new file mode 100644
index 0000000000..3983c707a1
--- /dev/null
+++ b/tests/auto/quick/qquickvisualdatamodel/data/readFromProxyObject.qml
@@ -0,0 +1,23 @@
+import QtQuick 2.15
+import QtQuick.Window 2.15
+
+Window {
+ id: window
+ width: 200
+ height: 200
+ color: "red"
+ visible: true
+ Repeater {
+ model: Qt.application.screens
+ Text {
+ required property string name
+ required property int virtualX
+ required property int virtualY
+
+ text: name + virtualX + ", " + virtualY
+ Component.onCompleted: window.name = name
+ }
+ }
+
+ property string name: "wrong"
+}
diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
index c5a3bceee0..66069c48cb 100644
--- a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
+++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
@@ -434,6 +434,7 @@ private slots:
void externalManagedModel();
void delegateModelChangeDelegate();
void checkFilterGroupForDelegate();
+ void readFromProxyObject();
private:
template <int N> void groups_verify(
@@ -4356,6 +4357,21 @@ void tst_qquickvisualdatamodel::checkFilterGroupForDelegate()
QVERIFY(obj->property("ok").toBool());
}
+void tst_qquickvisualdatamodel::readFromProxyObject()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("readFromProxyObject.qml"));
+
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(obj);
+
+ auto *window = qobject_cast<QQuickWindow *>(obj.get());
+ QVERIFY(window);
+
+ QCOMPARE(window->property("name").type(), QMetaType::QString);
+ QTRY_VERIFY(window->property("name").toString() != QLatin1String("wrong"));
+}
+
QTEST_MAIN(tst_qquickvisualdatamodel)
#include "tst_qquickvisualdatamodel.moc"