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

QSortFilterProxyModel Crash after endRemoveRows() in sourceModel



    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Incomplete
    • Affects Version/s: 4.8.2
    • Fix Version/s: None
    • Component/s: Widgets: Itemviews
    • Labels:
    • Environment:
      windows 7


      Let us assume a sourceModel as shown below:
      A COL2 COL3
      ---X COL2 COL3
      ---Y COL2 COL3
      ---Z COL2 COL3
      B COL2 COL3
      ---X COL2 COL3

      etc... --denotes a child. so X happens to be the child of A. Each of X, Y and Z are different. It is just that their display role has same value.
      Suppose, you show this sourceModel in a QTreeView srcTreeView.
      Now, you want a QSortFilterProxyModel so that if you click on a item on srcTreeView, it shows all it's children which don't have the name Y. and only column1 and column3
      so if A,B OR C is clicked, it QSFPM attached view has to show as:
      X COL3
      Z COL3
      filteracceptrows() and filteracceptcolumn() is written accordingly. Now the view attached to QSFPM is showing x and z of A if A is clicked on srcTreeView(assuming selectionChanged properly overridden which intimates QSFPM of selectionChanged so that it can QSFPM view can setRootIndex).
      As we click on srcTreeView items, rows are being added and removed from QSFPM as reported by qmodeltest. Suppose we select item Y in srcTreeView, then select A.
      Now if item Y under A is removed in sourcemodel in a function with calls beginremoverows() and endremoverows(), it will lead to crash, with following Q_ASSERT message:
      ASSERT: “cm” in file itemviews/qsortfilterproxymodel.cpp line 935.
      This happens, because item Y which has been removed is being searched in QSFPM internal mappings, and not being found.


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



            stephen.kelly Stephen Kelly (Unused account) (Inactive)
            pkj Prashant
            0 Vote for this issue
            4 Start watching this issue



                Gerrit Reviews

                There are no open Gerrit changes