Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
5.14.1
-
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); });