QAbstractItemView: fix crash if setData() does a model reset
Task-number: QTBUG-96654 Pick-to: 6.2 Change-Id: I2dca4af387ef5ad549a1a41fba2bc6de217f4ea9 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
657525965b
commit
18bb10373a
@ -2755,16 +2755,23 @@ bool QAbstractItemView::edit(const QModelIndex &index, EditTrigger trigger, QEve
|
||||
d->delayedEditing.stop();
|
||||
}
|
||||
|
||||
// in case e.g. setData() triggers a reset()
|
||||
QPersistentModelIndex safeIndex(index);
|
||||
|
||||
if (d->sendDelegateEvent(index, event)) {
|
||||
update(index);
|
||||
update(safeIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!safeIndex.isValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// save the previous trigger before updating
|
||||
EditTriggers lastTrigger = d->lastTrigger;
|
||||
d->lastTrigger = trigger;
|
||||
|
||||
if (!d->shouldEdit(trigger, d->model->buddy(index)))
|
||||
if (!d->shouldEdit(trigger, d->model->buddy(safeIndex)))
|
||||
return false;
|
||||
|
||||
if (d->delayedEditing.isActive())
|
||||
@ -2779,7 +2786,7 @@ bool QAbstractItemView::edit(const QModelIndex &index, EditTrigger trigger, QEve
|
||||
if (trigger == SelectedClicked)
|
||||
d->delayedEditing.start(QApplication::doubleClickInterval(), this);
|
||||
else
|
||||
d->openEditor(index, d->shouldForwardEvent(trigger, event) ? event : nullptr);
|
||||
d->openEditor(safeIndex, d->shouldForwardEvent(trigger, event) ? event : nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user