Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-61537

QAbstractListModel changes during delegate creation cause overlap ListView items

    XMLWordPrintable

    Details

      Description

      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)

      NOTE:

      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 only to force the issue to happen, 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.
      Scroll.
      Overlap occurs.

      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.
      Items overlap.

        Attachments

        1. ListViewBug_cpp.tar.gz
          3 kB
        2. ListViewBug_qml.zip
          3 kB
        3. ListViewOverlap.png
          ListViewOverlap.png
          61 kB
        For Gerrit Dashboard: QTBUG-61537
        # Subject Branch Project Status CR V

          Activity

            People

            • Assignee:
              richard Richard Moe Gustavsen
              Reporter:
              ottoryynanen Otto Ryynänen
            • Votes:
              3 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: