From 4f82b0ba529adad2ba71f5b128e9f331a0b80323 Mon Sep 17 00:00:00 2001 From: Alessandro Pasotti Date: Fri, 12 May 2017 09:17:22 +0200 Subject: [PATCH] [bugfix] Attribute table crashes QGIS when deleting selected Fixes https://issues.qgis.org/issues/16492 Backport from https://github.com/qgis/QGIS/pull/4535 --- src/gui/attributetable/qgsattributetabledelegate.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gui/attributetable/qgsattributetabledelegate.cpp b/src/gui/attributetable/qgsattributetabledelegate.cpp index caf03f583ba4..7bb8b0d90799 100644 --- a/src/gui/attributetable/qgsattributetabledelegate.cpp +++ b/src/gui/attributetable/qgsattributetabledelegate.cpp @@ -94,6 +94,18 @@ void QgsAttributeTableDelegate::setModelData( QWidget *editor, QAbstractItemMode if ( !eww ) return; + // This fixes https://issues.qgis.org/issues/16492 + QgsFeatureRequest request( fid ); + request.setFlags( QgsFeatureRequest::NoGeometry ); + request.setSubsetOfAttributes( QgsAttributeList( ) ); + QgsFeature feature; + vl->getFeatures( request ).nextFeature( feature ); + if ( ! feature.isValid( ) ) + { + // Model is out of sync (again!). + return; + } + newValue = eww->value(); if (( oldValue != newValue && newValue.isValid() ) || oldValue.isNull() != newValue.isNull() )