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

QStandardItemModel takeItem / takeChild does not emit the right signals

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.15.2, 6.0.0 RC2
    • Fix Version/s: 6.1.1, 6.2.0 Alpha
    • Component/s: Core: Item Models
    • Labels:
      None
    • Commits:
      811a6c6b77a94d86e28a0b00079e02a863391108 (qt/qtbase/dev) 838b1d1b76abf8219e0177cb0c0e201c1917ca92 (qt/qtbase/6.1)

      Description

      Given a populated QStandardItemModel, taking one of the QStandardItems out of it (via takeItem() on the model, or takeChild() on an item) does not cause the model to emit the right signals. It must, at a minimum, go through row deletion protocol (to signal that the children of the item are getting removed) and then emit a dataChanged for the index that got removed.

      This makes QAIMT to correctly scream when pointed at a QSIM.

      Fix is tricky, because depending on whether QSIM emits first dataChanged or the row removal, the "other" data must still be correct for a little while.

      1. If you do dataChanged first, then you must report dummy data (= equivalent to a default constructed QSI) while going through the row removal.
      2. If you do row removal first, then after rowRemoved the QSMI still has its children, but the model must not report them. It must however still report the old data for the item. Then the dataChanged() wipes the data out

      I'd also suggest to document to never do structural modifications of the model from slots connected to QSIM signals, or it'll make QSIM super hard to implement correctly.

        Attachments

        For Gerrit Dashboard: QTBUG-89145
        # Subject Branch Project Status CR V

          Activity

            People

            Assignee:
            dfaure_kdab David Faure
            Reporter:
            peppe Giuseppe D'Angelo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There is 1 open Gerrit change