aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllistmodelworkerscript/data/listmodel_async_sort/main.qml
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-01-13 10:39:15 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2021-01-13 15:19:05 +0100
commit2996439993c587bc9c7169e4f152169f28247c21 (patch)
tree7ebe0be13cd61bececf6df05de4ac6528ded0b6b /tests/auto/qml/qqmllistmodelworkerscript/data/listmodel_async_sort/main.qml
parentf1410debc7905e704b6ed16ae345e43765ef8ef5 (diff)
ListModel: Fix move handling in sync
When a ListModel is modified in a workerscript, we reconciliate the state in ListModel::sync. However, the logic for moving elements was wrong, causing crashes in endMoveRows due to invalid moves. This patch ensures that elements are moved to the correct position. Notably, whenever an element is moved, we must update the targetIndex of all elements affected by that move. Amends 3accc1dae76575120e71cadb547e961ecd50bcb0. Task-number: QTBUG-85557 Pick-to: 5.15 6.0 Change-Id: I1a1ffa43eab39ed2315f1916527d897b208c2c3b Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmllistmodelworkerscript/data/listmodel_async_sort/main.qml')
-rw-r--r--tests/auto/qml/qqmllistmodelworkerscript/data/listmodel_async_sort/main.qml23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllistmodelworkerscript/data/listmodel_async_sort/main.qml b/tests/auto/qml/qqmllistmodelworkerscript/data/listmodel_async_sort/main.qml
new file mode 100644
index 0000000000..88a23511fa
--- /dev/null
+++ b/tests/auto/qml/qqmllistmodelworkerscript/data/listmodel_async_sort/main.qml
@@ -0,0 +1,23 @@
+import QtQuick 2.13
+import QtQuick.Window 2.13
+
+Window {
+ visible: true
+ width: 640
+ height: 640
+ title: qsTr("Hello World")
+
+ ListModelSort {
+ id: lms
+ anchors.fill: parent
+ }
+
+ function doSort() {
+ lms.doSort()
+ }
+
+ function verify(): bool {
+ let ok = lms.verify()
+ return ok
+ }
+}