@@ -96,6 +96,8 @@ QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator( QgsVectorLayerFeat
96
96
97
97
prepareExpressions ();
98
98
99
+ mHasVirtualAttributes = !mFetchJoinInfo .isEmpty () || !mExpressionFieldInfo .isEmpty ();
100
+
99
101
// by default provider's request is the same
100
102
mProviderRequest = mRequest ;
101
103
@@ -211,9 +213,11 @@ bool QgsVectorLayerFeatureIterator::fetchFeature( QgsFeature& f )
211
213
f.setFields ( &mSource ->mFields );
212
214
213
215
// update attributes
214
- updateChangedAttributes ( f );
216
+ if ( mSource ->mHasEditBuffer )
217
+ updateChangedAttributes ( f );
215
218
216
- addVirtualAttributes ( f );
219
+ if ( mHasVirtualAttributes )
220
+ addVirtualAttributes ( f );
217
221
218
222
// update geometry
219
223
// TODO[MK]: FilterRect check after updating the geometry
@@ -311,7 +315,8 @@ void QgsVectorLayerFeatureIterator::useAddedFeature( const QgsFeature& src, QgsF
311
315
312
316
f.setAttributes ( src.attributes () );
313
317
314
- addVirtualAttributes ( f );
318
+ if ( mHasVirtualAttributes )
319
+ addVirtualAttributes ( f );
315
320
}
316
321
317
322
@@ -351,7 +356,8 @@ bool QgsVectorLayerFeatureIterator::fetchNextChangedAttributeFeature( QgsFeature
351
356
352
357
updateChangedAttributes ( f );
353
358
354
- addVirtualAttributes ( f );
359
+ if ( mHasVirtualAttributes )
360
+ addVirtualAttributes ( f );
355
361
356
362
if ( mRequest .filterType () == QgsFeatureRequest::FilterExpression )
357
363
{
@@ -404,7 +410,8 @@ void QgsVectorLayerFeatureIterator::useChangedAttributeFeature( QgsFeatureId fid
404
410
QgsFeatureIterator fi = mSource ->mProviderFeatureSource ->getFeatures ( request );
405
411
if ( fi.nextFeature ( tmp ) )
406
412
{
407
- updateChangedAttributes ( tmp );
413
+ if ( mHasVirtualAttributes )
414
+ updateChangedAttributes ( tmp );
408
415
f.setAttributes ( tmp.attributes () );
409
416
}
410
417
}
@@ -732,9 +739,11 @@ bool QgsVectorLayerFeatureIterator::nextFeatureFid( QgsFeature& f )
732
739
QgsFeatureIterator fi = mSource ->mProviderFeatureSource ->getFeatures ( mProviderRequest );
733
740
if ( fi.nextFeature ( f ) )
734
741
{
735
- updateChangedAttributes ( f );
742
+ if ( mSource ->mHasEditBuffer )
743
+ updateChangedAttributes ( f );
736
744
737
- addVirtualAttributes ( f );
745
+ if ( mHasVirtualAttributes )
746
+ addVirtualAttributes ( f );
738
747
739
748
return true ;
740
749
}
0 commit comments