Skip to content

Commit c8bf6db

Browse files
committedOct 2, 2018
[processing] Give progress reports/allow cancelation in in-place mode
1 parent 66f2272 commit c8bf6db

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@ def execute_in_place_run(alg, active_layer, parameters, context=None, feedback=N
124124
raise QgsProcessingException(tr("Selected algorithm and parameter configuration are not compatible with in-place modifications."))
125125
field_idxs = range(len(active_layer.fields()))
126126
feature_iterator = active_layer.getFeatures(QgsFeatureRequest(active_layer.selectedFeatureIds())) if parameters['INPUT'].selectedFeaturesOnly else active_layer.getFeatures()
127-
for f in feature_iterator:
127+
step = 100 / len(active_layer.selectedFeatureIds()) if active_layer.selectedFeatureIds() else 1
128+
for current, f in enumerate(feature_iterator):
129+
feedback.setProgress(current * step)
130+
if feedback.isCanceled():
131+
break
132+
128133
# need a deep copy, because python processFeature implementations may return
129134
# a shallow copy from processFeature
130135
input_feature = QgsFeature(f)

0 commit comments

Comments
 (0)
Please sign in to comment.