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

Infinite recursion of a QSortFilterProxyModel with a QConcatenateTablesProxyModel as source

    XMLWordPrintable

Details

    • All
    • 93694e99c (dev), 149be782b (6.9)

    Description

      When adding the first sourceModel to a QConcatenateTablesProxyModel, it first updates its row count, firing rowsInserted, and only after recalculates the columns count, causing a moment of data inconsistency where the model has multiple rows but zero columns.

      This can cause an infinite recursion if the QConcatenateTablesProxyModel is the source model for any filter model which has to access source items in its own filterAcceptsRow and is set to setRecursiveFilteringEnabled

       

      Because in this case filterAcceptsRow will be called for a row of the source model which has an invalid index (because there are still 0 columns in this moment) so will always have to return false.

       

      being recursive, it will go into QSortFilterProxyModelPrivate::recursiveChildAcceptsRow where it will keep forever try to call filterAcceptsRow recursing forever

       

      The attached example is a very simple app which has a QSortFilterProxyModel subclass (custom filterAcceptsRow and set to recursive) with a QConcatenateTablesProxyModel as source model.

       

      when a QStandardItemModel with already an item inside is added, it will go into an infinite recursion and eventually crash.

       

      if the qstandarditemmodel is added empty and is populated afterwards, the issue doesn't happen

       

      if the model is not set as recursive, it will not crash but filterAcceptsRow will always return false and the filter model will always be empty

      Attachments

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

        Activity

          People

            dfaure_kdab David Faure
            notmart Marco Martin
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes