Skip to content

Commit

Permalink
Fix AlgorithmExecutor.py for in-place editing constraints
Browse files Browse the repository at this point in the history
Followup of backport master PR #31750

Since in 3.4 we don't have createFeatures and the nice
cache for unique values.
  • Loading branch information
elpaso committed Sep 16, 2019
1 parent ce4915b commit 81056e6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions python/plugins/processing/gui/AlgorithmExecutor.py
Expand Up @@ -186,12 +186,11 @@ def execute_in_place_run(alg, parameters, context=None, feedback=None, raise_exc
old_ids = set([f.id() for f in active_layer.getFeatures(req)])
# If multiple new features were created, we need to pass
# them to createFeatures to manage constraints correctly
features_data = []
for f in new_features:
features_data.append(QgsVectorLayerUtils.QgsFeatureData(f.geometry(), dict(enumerate(f.attributes()))))
new_features = QgsVectorLayerUtils.createFeatures(active_layer, features_data, context.expressionContext())
if not active_layer.addFeatures(new_features):
raise QgsProcessingException(tr("Error adding processed features back into the layer."))
new_feature = QgsVectorLayerUtils.createFeature(active_layer, f.geometry(), dict(enumerate(f.attributes())), context.expressionContext())
if not active_layer.addFeatures([new_feature]):
raise QgsProcessingException(tr("Error adding processed features back into the layer."))

new_ids = set([f.id() for f in active_layer.getFeatures(req)])
new_feature_ids += list(new_ids - old_ids)

Expand Down

0 comments on commit 81056e6

Please sign in to comment.