A customer detected that if model inherited from QAbstractListModel gets update at the time QML ListView is reading the data, the result ends up corrupted. Namely the items in view get misplaced.
(See attached screenshot - ListViewOverlap.png - it shows item with index 7 being drawn on top of item at index 0.)
Sample codes that reveal the issue are attached. (ListViewBug_cpp.tar.gz and ListViewBug_qml.zip)
The sample code in ListViewBug_cpp.tar.gz does a call from ListView delegate to the ListView model. It is completely understood that this kind of implementation is error prone and should not be used, it is done , as the situation seems to depend on timing and is a tricky thing to get to occur 100%.
The new attachment ListViewBug_qml.zip has an implementation that produces the overlapping items without communication from the delegate to the model. It also uses QML model without any custom implementation.
However the ListViewBug_qml version is not fully reliable to cause issues. E.g. it does not cause overlap on my PC if I run it on Linux, whereas the issue is 100% reproduceable if I run it on Windows. Both are native installations, not virtual boxed.
That being said, it is obvious that the issue in ListViewBug_cpp gets solved by removing the call to the list model from delegate but that is not the point here as the problem can occur also without a call to list model (like in ListViewBug_qml).
Instructions for ListViewBug_qml:
Start the app.
Wait 1 second for the timer to expire.
Instructions for ListViewBug_cpp:
Start the app.
List already should be mixed, e.g. indexes are not 0, 1 and 2.
If no visual errors (missing items or overlap) is visible, press "Shuffle" button.
Repeat previous step if necessary.
|For Gerrit Dashboard: QTBUG-61537|
|198410,4||QQuickListView: ensure we re-layout when a delegate is placed at the last visible pos||5.9||qt/qtdeclarative||Status: MERGED||+2||0|
|208143,3||QQuickListView: ensure recently inserted item becomes visible||5.9||qt/qtdeclarative||Status: ABANDONED||-1||0|
|210768,5||QQmlIntanceModel: use QQmlIncubator::IncubationMode instead of bool to specify incubation mode||5.9||qt/qtdeclarative||Status: MERGED||+2||0|
|210769,4||QQmlDelegateModel: ensure item gets loaded immediately when requested sync||5.9||qt/qtdeclarative||Status: ABANDONED||+1||0|
|210770,13||QQuickListView/GridView: load items that results from model changes synchronously||5.9||qt/qtdeclarative||Status: MERGED||+2||0|
|210839,6||QQmlDelegateModel: add incubationStatus(), and use it to determine 'requestedIndex'||5.9||qt/qtdeclarative||Status: MERGED||+2||0|
|213180,4||Quick3DNodeInstantiatorPrivate: Fix build after private API change||5.9||qt/qt3d||Status: MERGED||+2||0|