Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] Pass a copy of the feature to processFeature, not
the original layer's feature

Otherwise python processFeature implementations may return a
modified shallow copy of this feature, which means that the
test for modifications fails, since we're comparing against
the same feature which was modified.

Fixes some python algorithms do not modify features when used
in-place mode.
  • Loading branch information
nyalldawson committed Sep 21, 2018
1 parent 1b2d885 commit e2068b8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion python/plugins/processing/gui/AlgorithmExecutor.py
Expand Up @@ -227,7 +227,10 @@ def execute_in_place_run(alg, active_layer, parameters, context=None, feedback=N
field_idxs = range(len(active_layer.fields()))
feature_iterator = active_layer.getFeatures(QgsFeatureRequest(active_layer.selectedFeatureIds())) if parameters['INPUT'].selectedFeaturesOnly else active_layer.getFeatures()
for f in feature_iterator:
new_features = alg.processFeature(f, context, feedback)
# need a deep copy, because python processFeature implementations may return
# a shallow copy from processFeature
input_feature = QgsFeature(f)
new_features = alg.processFeature(input_feature, context, feedback)
new_features = make_features_compatible(new_features, active_layer)
if len(new_features) == 0:
active_layer.deleteFeature(f.id())
Expand Down

0 comments on commit e2068b8

Please sign in to comment.