aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2017-11-07 14:56:03 +0100
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2017-11-30 07:36:14 +0000
commit9e7dbbeec0be2ce07c58edf84ce6e03d60946bce (patch)
tree19052bf9ba4f73e32de4c38f5cb36620aea2a1d4 /src
parent816b5a667f0b5b47c3f80c2c775535310c89b727 (diff)
QQuickListView/GridView: load items that results from model changes synchronously
The current implementation created new items with default incubation mode, which is AsynchronousIfNested. But from reading the code, it seems like changes to the model were really expected to be handled synchronously, since there aren't any sections in the code that will recover from situations were requested items ends up incubating async. This is also backed by the fact that the second argument used to be a bool set to 'synchronous'. The fact that this was translated to AsynchronousIfNested later down the chain didn't seems to be taken into account. A bug with this is found in ListView when it's embedded inside an async Loader. In that case, all list items will be incubating async at startup, which is normally expected and fine. But if the model assigned to the ListView is modified before the loader has finished, async loading will also happen to the items created because of the change. And then the situation described above will occur. This patch will force any items loaded because of a model change to be synchronous. This seems to be in line with the synchronous logic that already exists. And its also quite acceptable, since changing the model before everything is completed is a corner case, and can naturally lead to some stuttering in the list view anyway. A potential for improvement on this logic is to try to recover whenever creating an item fails. But this takes a lot of work because of the way model changes are structured and stored, and can easily cause regressions. Since this is a corner case, it is probably not worth it. [ChangeLog][QtQml][ListView] Fixed a bug in ListView that sometimes make items end up with wrong geometry when changes to its model happens while the ListView is being loaded async (e.g if wrapped inside an async Loader). Task-number: QTBUG-61537 Change-Id: I8d6857beaf8ef98b02bb46282a1312749b0fb801 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/qquickgridview.cpp4
-rw-r--r--src/quick/items/qquicklistview.cpp4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp
index e59c579790..c56cfd3005 100644
--- a/src/quick/items/qquickgridview.cpp
+++ b/src/quick/items/qquickgridview.cpp
@@ -2417,7 +2417,7 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch
if (change.isMove() && (item = currentChanges.removedItems.take(change.moveKey(modelIndex + i))))
item->index = modelIndex + i;
if (!item)
- item = createItem(modelIndex + i);
+ item = createItem(modelIndex + i, QQmlIncubator::Synchronous);
if (!item)
return false;
@@ -2470,7 +2470,7 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch
item->index = modelIndex + i;
bool newItem = !item;
if (!item)
- item = createItem(modelIndex + i);
+ item = createItem(modelIndex + i, QQmlIncubator::Synchronous);
if (!item)
return false;
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index d924bc4460..11eaf393ea 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -3273,7 +3273,7 @@ bool QQuickListViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch
if (change.isMove() && (item = currentChanges.removedItems.take(change.moveKey(modelIndex + i))))
item->index = modelIndex + i;
if (!item)
- item = createItem(modelIndex + i);
+ item = createItem(modelIndex + i, QQmlIncubator::Synchronous);
if (!item)
return false;
@@ -3315,7 +3315,7 @@ bool QQuickListViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch
item->index = modelIndex + i;
bool newItem = !item;
if (!item)
- item = createItem(modelIndex + i);
+ item = createItem(modelIndex + i, QQmlIncubator::Synchronous);
if (!item)
return false;