[processing] Fix alg. postprocessing regression failing to add all but one output to the project #60624
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This fixes a regression caused by #59850 whereas only one output is ever added into the currently open project.
The long story short here is that python garbage collects output layers who's ownership is transferred on this line:
owned_map_layer = context.temporaryLayerStore().takeMapLayer(layer)
A way to workaround this is to add the owned_map_layer to the added_layers array of tuple to avoid the layer being deleted.
@nyalldawson , @ptitjano , open to better alternatives if there are any, but we should definitively not ship 3.42 with that regression in.