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

QSortFilterProxyModel crashes, wrong rowCount() value, incorrect setDynamicSortFilter() behavior

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P1: Critical
    • 4.7.2
    • 4.7.0
    • Widgets: Itemviews
    • None
    • Windows 2003, Qt 4.7 SDK: for minGW and VS 2008.

    Description

      Seems QSortFilterProxyModel have serious problems recent time. QSortFilterProxyModel crashes on many things, produces wrong rowCount() value if data in source model changed and have incorrect setDynamicSortFilter() behavior. I saw bugtracker has many reports: http://bugreports.qt.nokia.com/secure/IssueNavigator.jspa?reset=true&&query=QSortFilterProxyModel&summary=true&description=true&type=1&pid=10510&fixfor=-2&component=19135 about, but they were not fixed.

      Sample workable application (GPL) is attached to reproduce . Details:
      1) Crashes: if source model changed QSortFilterProxyModel on endResetModel() function, on emit layoutChanged(), on reset() - those are in in source model and on invalidate(). You can uncomment either lines: 41, 42, 54, 55 or 211 in cfilebrowsermodel.cpp file to reproduce (or insert reset() there).
      2) if data in source model totally changed QSortFilterProxyModel ->rowCount() produces wrong value - old (previous) source model value. You can debug through the void CFileBrowserSortModel::reset() method (line 206) to see that. Signal dataChanged() was added to at least a one way to tell proxy that source was changed. I won't be necessary if endResetModel() function, or layoutChanged() signal, or reset(), or invalidate() will function properly and do not cause crashes. In final application version I was forced to remove QSortFilterProxyModel at all and implement sorting in source model.
      3) Setting setDynamicSortFilter() to true causes wrong sorting, not the behaviour I implemented - works just terrible. You can set it to true and run the application to see. Model sorts correctly only with initial data set in source model (You may check that). If data completely changed (or even partially I think - according to bugreports) - sorting is wrong and terrible. If I set setDynamicSortFilter() to false sorting is correct but QTreeView contains many empty rows because of wrong rowCount() in proxy model.

      Attachments

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

        Activity

          People

            dedietri Gabriel de Dietrich (drgvond)
            alekseyk Aleksey Kontsevich (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes