mirror of
https://github.com/qgis/QGIS.git
synced 2025-05-03 00:03:15 -04:00
[processing] Give progress reports/allow cancelation in in-place mode
This commit is contained in:
parent
66f2272be0
commit
c8bf6db363
@ -124,7 +124,12 @@ def execute_in_place_run(alg, active_layer, parameters, context=None, feedback=N
|
|||||||
raise QgsProcessingException(tr("Selected algorithm and parameter configuration are not compatible with in-place modifications."))
|
raise QgsProcessingException(tr("Selected algorithm and parameter configuration are not compatible with in-place modifications."))
|
||||||
field_idxs = range(len(active_layer.fields()))
|
field_idxs = range(len(active_layer.fields()))
|
||||||
feature_iterator = active_layer.getFeatures(QgsFeatureRequest(active_layer.selectedFeatureIds())) if parameters['INPUT'].selectedFeaturesOnly else active_layer.getFeatures()
|
feature_iterator = active_layer.getFeatures(QgsFeatureRequest(active_layer.selectedFeatureIds())) if parameters['INPUT'].selectedFeaturesOnly else active_layer.getFeatures()
|
||||||
for f in feature_iterator:
|
step = 100 / len(active_layer.selectedFeatureIds()) if active_layer.selectedFeatureIds() else 1
|
||||||
|
for current, f in enumerate(feature_iterator):
|
||||||
|
feedback.setProgress(current * step)
|
||||||
|
if feedback.isCanceled():
|
||||||
|
break
|
||||||
|
|
||||||
# need a deep copy, because python processFeature implementations may return
|
# need a deep copy, because python processFeature implementations may return
|
||||||
# a shallow copy from processFeature
|
# a shallow copy from processFeature
|
||||||
input_feature = QgsFeature(f)
|
input_feature = QgsFeature(f)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user