Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1633

QAbstractItemModel crashes randomly when emitting layoutChanged

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • Not Evaluated
    • None
    • 5.15.4, 6.1.1
    • PySide
    • None
    • Windows 10 64bit 19043, Python 3.9.6
    • Windows

    Description

      I'm trying to write a model (QAbstractItemModel child class) to populate data into a QTreeView. I need the items to be checkable and want to later filter out everything that is not checked. To achieve correct hiding of items that have been unchecked when filtering is active, I need to emit layoutChanged in my setData method. Nevertheless, this one signal (in combination with layoutAboutToBeChanged) leads to unpredictable crashes when checking items. I narrowed it down to the following code example, I know two things that will prevent crashes when checking items:

      1. Remove the QSortFilterProxyModel
      2. Do not emit the layoutChanged signal

      Nevertheless, both are vital to my filtering (which I took out of the example code since it's too much anyway). To reproduce, you can just select an item and press the space bar - won't take long until the app crashes (it also crashes without that monkey test, but this is fast to reproduce). I already checked it with QtModelTester from pytest-qt - it's ok.

       

      Example code: https://pastebin.com/HYx4UzbK

       

      Attachments

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

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            tilman_krummeck Tilman Krummeck
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes