Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
More efficient field calculator iteration
  • Loading branch information
nyalldawson committed Oct 15, 2018
1 parent 0db9f05 commit 9f3b907
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/app/qgsattributetabledialog.cpp
Expand Up @@ -536,6 +536,10 @@ void QgsAttributeTableDialog::runFieldCalculation( QgsVectorLayer *layer, const

QgsField fld = layer->fields().at( fieldindex );

QSet< QString >referencedColumns = exp.referencedColumns();
referencedColumns.insert( fld.name() ); // need existing column value to store old attribute when changing field values
request.setSubsetOfAttributes( referencedColumns, layer->fields() );

//go through all the features and change the new attributes
QgsFeatureIterator fit = layer->getFeatures( request );
QgsFeature feature;
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgsfieldcalculator.cpp
Expand Up @@ -281,6 +281,9 @@ void QgsFieldCalculator::accept()
emptyAttribute = QVariant( field.type() );

QgsFeatureRequest req = QgsFeatureRequest().setFlags( useGeometry ? QgsFeatureRequest::NoFlags : QgsFeatureRequest::NoGeometry );
QSet< QString > referencedColumns = exp.referencedColumns();
referencedColumns.insert( field.name() ); // need existing column value to store old attribute when changing field values
req.setSubsetOfAttributes( referencedColumns, mVectorLayer->fields() );
if ( mOnlyUpdateSelectedCheckBox->isChecked() )
{
req.setFilterFids( mVectorLayer->selectedFeatureIds() );
Expand Down

0 comments on commit 9f3b907

Please sign in to comment.