Skip to content

Commit

Permalink
Fix crash when trying to re-load a layer from processing results
Browse files Browse the repository at this point in the history
into the project when that layer already exists in the project

Fixes qgis#53576
Fixes qgis#53729
  • Loading branch information
nyalldawson committed Jul 13, 2023
1 parent 07d2c24 commit edab380
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions python/plugins/processing/gui/Postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,16 @@ def handleAlgorithmResults(alg: QgsProcessingAlgorithm,
# Load layer to layer tree root or to a specific group
results_group = get_layer_tree_results_group(details, context)

map_layer = context.temporaryLayerStore().takeMapLayer(layer)
details.project.addMapLayer(map_layer, False)

# we don't add the layer to the tree yet -- that's done
# later, after we've sorted all added layers
layer_tree_layer = create_layer_tree_layer(map_layer, details)
added_layers.append((results_group, layer_tree_layer))
# note here that we may not retrieve an owned layer -- eg if the
# output layer already exists in the destination project
owned_map_layer = context.temporaryLayerStore().takeMapLayer(layer)
if owned_map_layer:
details.project.addMapLayer(owned_map_layer, False)

# we don't add the layer to the tree yet -- that's done
# later, after we've sorted all added layers
layer_tree_layer = create_layer_tree_layer(owned_map_layer, details)
added_layers.append((results_group, layer_tree_layer))

if details.postProcessor():
# we defer calling the postProcessor set in the context
Expand Down

0 comments on commit edab380

Please sign in to comment.