Skip to content
Permalink
Browse files
Only check for validity if attribute has changed
  • Loading branch information
elpaso committed May 12, 2017
1 parent 4f82b0b commit 2b6b495
Showing 1 changed file with 12 additions and 15 deletions.
@@ -94,25 +94,22 @@ 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() )
{
vl->beginEditCommand( tr( "Attribute changed" ) );
vl->changeAttributeValue( fid, fieldIdx, newValue, oldValue );
vl->endEditCommand();
// 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( ) )
{
vl->beginEditCommand( tr( "Attribute changed" ) );
vl->changeAttributeValue( fid, fieldIdx, newValue, oldValue );
vl->endEditCommand();
}
}
}

0 comments on commit 2b6b495

Please sign in to comment.