Skip to content

Commit 396a135

Browse files
authored
Merge pull request #4540 from boundlessgeo/attributetable-fixes-16492-backport
[bugfix] Attribute table crashes QGIS when deleting selected
2 parents 477d1bd + 2b6b495 commit 396a135

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/gui/attributetable/qgsattributetabledelegate.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,18 @@ void QgsAttributeTableDelegate::setModelData( QWidget *editor, QAbstractItemMode
9898

9999
if (( oldValue != newValue && newValue.isValid() ) || oldValue.isNull() != newValue.isNull() )
100100
{
101-
vl->beginEditCommand( tr( "Attribute changed" ) );
102-
vl->changeAttributeValue( fid, fieldIdx, newValue, oldValue );
103-
vl->endEditCommand();
101+
// This fixes https://issues.qgis.org/issues/16492
102+
QgsFeatureRequest request( fid );
103+
request.setFlags( QgsFeatureRequest::NoGeometry );
104+
request.setSubsetOfAttributes( QgsAttributeList( ) );
105+
QgsFeature feature;
106+
vl->getFeatures( request ).nextFeature( feature );
107+
if ( feature.isValid( ) )
108+
{
109+
vl->beginEditCommand( tr( "Attribute changed" ) );
110+
vl->changeAttributeValue( fid, fieldIdx, newValue, oldValue );
111+
vl->endEditCommand();
112+
}
104113
}
105114
}
106115

0 commit comments

Comments
 (0)