QAbstractItemView: port Q_FOREACH to ranged-for
Take a copy as the loop may end up calling QCoreApplication::postEvent() which in turn could invoke unknown code that results in modifying the QHash that is being iterated over. Task-number: QTBUG-115803 Change-Id: I5f8aabb13ef7f60b470d0d3a986063775e787036 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>bb10
parent
79dc2980e6
commit
3e6724b11a
|
|
@ -1121,7 +1121,11 @@ void QAbstractItemView::reset()
|
|||
{
|
||||
Q_D(QAbstractItemView);
|
||||
d->delayedReset.stop(); //make sure we stop the timer
|
||||
foreach (const QEditorInfo &info, d->indexEditorHash) {
|
||||
// Taking a copy because releaseEditor() eventurally calls deleteLater() on the
|
||||
// editor, which calls QCoreApplication::postEvent(), the latter may invoke unknown
|
||||
// code that may modify d->indexEditorHash.
|
||||
const auto copy = d->indexEditorHash;
|
||||
for (const auto &[index, info] : copy.asKeyValueRange()) {
|
||||
if (info.widget)
|
||||
d->releaseEditor(info.widget.data(), d->indexForEditor(info.widget.data()));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue