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

QPersistentModelIndex crashes in dataChanged connection

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.14.1
    • Core: Item Models
    • None

    Description

      It seems that QPersistentModelIndexes are corrupted internally when dataChanged signal is emitted. This makes it impossible for a slot or anybody connected to the signal to refer to the model using a persistent model index, it also makes it impossible to compare the persistent indexes (which leads to a segfault).

       

      This can be reproduced on the official editable tree model example.

          QPersistentModelIndex pmi = model->index(0,0,QModelIndex());
          qDebug() << "woah" << pmi.isValid(); // << valid
          connect(model, &TreeModel::dataChanged, [&]() {
            auto lol = (pmi == model->index(0,0,QModelIndex())); // << operator==() will crash
            qDebug() << "hey" << pmi.isValid(); // << invalid & corrupted internally
            QMetaObject::invokeMethod(this,
                                     [&]{
              qDebug() << "wut" << pmi.isValid(); // << still invalid
            },Qt::QueuedConnection);
          });
      

      Attachments

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

        Activity

          People

            dfaure_kdab David Faure
            RobertBColton Robert B. Colton
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes