Skip to content

Commit e2068b8

Browse files
committedSep 21, 2018
[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.
1 parent 1b2d885 commit e2068b8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

‎python/plugins/processing/gui/AlgorithmExecutor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@ def execute_in_place_run(alg, active_layer, parameters, context=None, feedback=N
227227
field_idxs = range(len(active_layer.fields()))
228228
feature_iterator = active_layer.getFeatures(QgsFeatureRequest(active_layer.selectedFeatureIds())) if parameters['INPUT'].selectedFeaturesOnly else active_layer.getFeatures()
229229
for f in feature_iterator:
230-
new_features = alg.processFeature(f, context, feedback)
230+
# need a deep copy, because python processFeature implementations may return
231+
# a shallow copy from processFeature
232+
input_feature = QgsFeature(f)
233+
new_features = alg.processFeature(input_feature, context, feedback)
231234
new_features = make_features_compatible(new_features, active_layer)
232235
if len(new_features) == 0:
233236
active_layer.deleteFeature(f.id())

0 commit comments

Comments
 (0)
Please sign in to comment.