Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
4.6.2
-
None
Description
This is because deleteLater() is invoked before assigning it again.
An easy fix would be to return and not do anything if the widget passed is already the existing widget at the given index.
void QAbstractItemView::setIndexWidget(const QModelIndex &index, QWidget *widget) { Q_D(QAbstractItemView); if (!d->isIndexValid(index)) return; if (QWidget *oldWidget = indexWidget(index)) { d->removeEditor(oldWidget); oldWidget->deleteLater(); } if (widget) { widget->setParent(viewport()); d->persistent.insert(widget); d->addEditor(index, widget, true); widget->show(); if (!d->delayedPendingLayout) widget->setGeometry(visualRect(index)); dataChanged(index, index); // update the geometry } }
possible patch:
--- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -2831,7 +2831,7 @@ void QAbstractItemView::closePersistentEditor(const QModelIndex &index) void QAbstractItemView::setIndexWidget(const QModelIndex &index, QWidget *widget) { Q_D(QAbstractItemView); - if (!d->isIndexValid(index)) + if (!d->isIndexValid(index) || widget == indexWidget(index)) return; if (QWidget *oldWidget = indexWidget(index)) { d->removeEditor(oldWidget);