From acfc8f2cc699c4792e47ef9714ec1bd6092c46c7 Mon Sep 17 00:00:00 2001 From: Omar Emara Date: Mon, 10 Feb 2025 13:09:03 +0100 Subject: [PATCH] Fix #134293: Compositor crash after adding view layer The compositor crashes when the active viewer layers is deleted and replaced by a new layer. That's because the depsgraph of the compositor still references the old view layer. To fix this, we need to update the view layer of the compositor if it changed since it was last created. Pull Request: https://projects.blender.org/blender/blender/pulls/134326 --- source/blender/editors/space_node/node_edit.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index 59730fadd98..683b180e2a4 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -248,6 +248,12 @@ static void compo_initjob(void *cjv) DEG_debug_name_set(compositor_runtime.preview_depsgraph, "COMPOSITOR"); } + /* Update the viewer layer of the compositor since it changed since the depsgraph was created. */ + if (DEG_get_input_view_layer(compositor_runtime.preview_depsgraph) != view_layer) { + DEG_graph_replace_owners(compositor_runtime.preview_depsgraph, bmain, scene, view_layer); + DEG_graph_tag_relations_update(compositor_runtime.preview_depsgraph); + } + cj->compositor_depsgraph = compositor_runtime.preview_depsgraph; DEG_graph_build_for_compositor_preview(cj->compositor_depsgraph, cj->ntree);