From 3d8dd4913c255d557536746c7b2d909d3755bc62 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 27 Mar 2018 10:40:30 +1000 Subject: [PATCH] Fix crash in attribute table when action column is visible and edit is toggled --- src/gui/attributetable/qgsattributetableview.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/gui/attributetable/qgsattributetableview.cpp b/src/gui/attributetable/qgsattributetableview.cpp index 80fc01e345c..22b425e8707 100644 --- a/src/gui/attributetable/qgsattributetableview.cpp +++ b/src/gui/attributetable/qgsattributetableview.cpp @@ -449,14 +449,13 @@ void QgsAttributeTableView::onActionColumnItemPainted( const QModelIndex &index void QgsAttributeTableView::recreateActionWidgets() { - QMap< QModelIndex, QWidget * > newWidgets; QMap< QModelIndex, QWidget * >::const_iterator it = mActionWidgets.constBegin(); for ( ; it != mActionWidgets.constEnd(); ++it ) { - it.value()->deleteLater(); //? - QWidget *widget = createActionWidget( mFilterModel->data( it.key(), QgsAttributeTableModel::FeatureIdRole ).toLongLong() ); - newWidgets.insert( it.key(), widget ); - setIndexWidget( it.key(), widget ); + // ownership of widget was transferred by initial call to setIndexWidget - clearing + // the index widget will delete the old widget safely + // they should then be recreated by onActionColumnItemPainted + setIndexWidget( it.key(), nullptr ); } - mActionWidgets = newWidgets; + mActionWidgets.clear(); }