Skip to content

Commit

Permalink
Only check for validity if attribute has changed
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed May 12, 2017
1 parent 1eaf03d commit 5134791
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/gui/attributetable/qgsattributetabledelegate.cpp
Expand Up @@ -93,25 +93,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();
}
}
}

Expand Down

0 comments on commit 5134791

Please sign in to comment.