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

MapItemView crashes the application after beginMoveRows/endMoveRows in underlying model

    XMLWordPrintable

Details

    • All

    Description

      Implemented QML Dynamic View Ordering by Dragging View Items using this Qt tutorial: QML Dynamic View Ordering Tutorial. Only changed original underlying model which is QAbstractListModel descendant in our case. Model stores data in a QList<QObject*> objectList; field type.

      Was necessary to change items order automatically in original underlying model as well (not only in DelegateModel) for other C++ and QML consumers where this order matters. Implemented this by adding void ObjectListModel::move(int from, int to) to the ObjectListModel implementation like I've mentioned here on Stackoverflow:

      void ObjectListModel::move(int from, int to)
      {
          if(0 <= from && from < count() && 0 <= to && to < count() && from != to) {
              if(from == to - 1) // Allow item moving to the bottom
                  to = from++;
      
              beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
              objectList.move(from, to);
              endMoveRows();
          }
      }
      

      However another model consumer like MapItemView fails to use the model after beginMoveRows/endMoveRows calls: moved indicator item disappeared on the map (not destroyed or visibility changed) and other manipulations with the item crashes the app.

       Map {
           ...
           MapItemView {
               model: objectListModel
      
               delegate: SomeItemIndicator {
               }
           }
       }
      

      Think Qt bug. Some other hacks like emitting dataChanged() signal, etc do not help as well.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              paangele Paolo Angelelli
              jirauser39314 user-45b5b (Inactive)
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes