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

REG[5.15-6.1]QTreeView crash when checkbox triggers reset

    XMLWordPrintable

    Details

    • Platform/s:
      macOS, Windows
    • Commits:
      cb10cf1e43

      Description

      We have an application that contains a QTreeView where checking a box in one of the cells ends up resetting the model. The view's model is a QSortFilterProxyModel with an underlying QAbstractItemModel implementation based on the Simple Tree Model Example. This seemed to work OK on Qt 5.12.11 and earlier, but now that we have migrated to 6.1.3 it causes a crash. In Debug mode, it triggers the following ASSERT:

      ASSERT: "it != source_index_mapping.constEnd()" in file \Users\qt\work\qt\qtbase\src\corelib\itemmodels\qsortfilterproxymodel.cpp, line 218  
      
      

      I've attached a small example project based on the Simple Tree Model example that reproduces the issue. To reproduce the issue most reliably, click on a checkbox for one of the child nodes (i.e. expand the "Form Editing Mode" node, and click the checkbox next to "Loading and saving forms"). The following stack trace is produced:

                                                                                                               
                                                                                                               
      1   qt_message_fatal                                       qlogging.cpp              1863 0x7ff95ecb7532 
      2   QMessageLogger::fatal                                  qlogging.cpp              891  0x7ff95ecb5926 
      3   qt_assert                                              qglobal.cpp               3123 0x7ff95eca1abd 
      4   QSortFilterProxyModelPrivate::index_to_iterator        qsortfilterproxymodel.cpp 219  0x7ff95f43be46 
      5   QSortFilterProxyModelPrivate::proxy_to_source          qsortfilterproxymodel.cpp 494  0x7ff95f40de80 
      6   QSortFilterProxyModel::mapToSource                     qsortfilterproxymodel.cpp 3111 0x7ff95f4091eb 
      7   QSortFilterProxyModel::buddy                           qsortfilterproxymodel.cpp 2471 0x7ff95f40cc6a 
      8   QAbstractItemView::edit                                qabstractitemview.cpp     2700 0x7ff95e37bac9 
      9   QAbstractItemView::mouseReleaseEvent                   qabstractitemview.cpp     1938 0x7ff95e37ebde 
      10  QTreeView::mouseReleaseEvent                           qtreeview.cpp             1952 0x7ff95e4c1839 
      11  QWidget::event                                         qwidget.cpp               8659 0x7ff95dd96f70 
      12  QFrame::event                                          qframe.cpp                550  0x7ff95df326a4 
      13  QAbstractScrollArea::viewportEvent                     qabstractscrollarea.cpp   1095 0x7ff95df27ec1 
      14  QAbstractItemView::viewportEvent                       qabstractitemview.cpp     1766 0x7ff95e37d716 
      15  QTreeView::viewportEvent                               qtreeview.cpp             1332 0x7ff95e4c241b 
      16  QAbstractScrollAreaPrivate::viewportEvent              qabstractscrollarea_p.h   110  0x7ff95df2fcb4 
      17  QAbstractScrollAreaFilter::eventFilter                 qabstractscrollarea_p.h   121  0x7ff95df2f26c 
      18  QCoreApplicationPrivate::sendThroughObjectEventFilters qcoreapplication.cpp      1174 0x7ff95ee2c764 
      19  QApplicationPrivate::notify_helper                     qapplication.cpp          3404 0x7ff95dcb505d 
      20  QApplication::notify                                   qapplication.cpp          2868 0x7ff95dcafca4 
      ... <More>                                                                                               
                                         
      
      

       

      If I compile and run the program with 5.12.11 (MSVC2017 64-bit) you do not get a crash (it prints "It didn't crash"). If I run the program with 6.1.3 (MSVC2019 64-bit, also macOS), I get a crash almost every time (occasionally it doesn't crash on the first click). I'm not sure if this is exposing a problem with how we coded reset functionality or due to some other change since 5.12.

      Final note: if I change the connection type to QueuedConnection the problem goes away, but I'm not sure if that's a valid solution or a workaround.

        

        Attachments

        1. treecrash.gif
          treecrash.gif
          258 kB
        2. TreeCrashTest.zip
          8 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            dfaure_kdab David Faure
            Reporter:
            mattcwill Matthew Williams
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes