Skip to content
Permalink
Browse files

More efficient field calculator iteration

  • Loading branch information
nyalldawson committed Oct 15, 2018
1 parent 0db9f05 commit 9f3b90775a7c5ba54f2a0e77d14568f4d7867df3
Showing with 7 additions and 0 deletions.
  1. +4 −0 src/app/qgsattributetabledialog.cpp
  2. +3 −0 src/app/qgsfieldcalculator.cpp
@@ -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;
@@ -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() );

0 comments on commit 9f3b907

Please sign in to comment.
You can’t perform that action at this time.