[Bf-blender-cvs] [dd260d2f035] master: Fix T102554: Crash when Use Nodes is enabled

Omar Emara noreply at git.blender.org
Thu Nov 17 10:13:14 CET 2022


Commit: dd260d2f03530f5ce8aa01140e63419bb3239c82
Author: Omar Emara
Date:   Thu Nov 17 11:12:41 2022 +0200
Branches: master
https://developer.blender.org/rBdd260d2f03530f5ce8aa01140e63419bb3239c82

Fix T102554: Crash when Use Nodes is enabled

Blender crashes when enabling Use Nodes after the viewport compositor is
already enabled.

This happens because the active viewer key is not yet initialized for the
node tree at this point, which eventually leads to a nullptr.

This patch fixes that by returning the root context in case the active
viewer key is not yet initialized.

===================================================================

M	source/blender/compositor/realtime_compositor/intern/scheduler.cc

===================================================================

diff --git a/source/blender/compositor/realtime_compositor/intern/scheduler.cc b/source/blender/compositor/realtime_compositor/intern/scheduler.cc
index 0d3cce7af39..e343765735d 100644
--- a/source/blender/compositor/realtime_compositor/intern/scheduler.cc
+++ b/source/blender/compositor/realtime_compositor/intern/scheduler.cc
@@ -60,6 +60,12 @@ static const DTreeContext *find_active_context_recursive(const DTreeContext *con
  * instance of the node group. */
 static const DTreeContext *find_active_context(const DerivedNodeTree &tree)
 {
+  /* If the active viewer key is NODE_INSTANCE_KEY_NONE, that means it is not yet initialized and
+   * we return the root context in that case. See the find_active_context_recursive function. */
+  if (tree.root_context().btree().active_viewer_key.value == NODE_INSTANCE_KEY_NONE.value) {
+    return &tree.root_context();
+  }
+
   /* The root context has an instance key of NODE_INSTANCE_KEY_BASE by definition. */
   return find_active_context_recursive(&tree.root_context(), NODE_INSTANCE_KEY_BASE);
 }



More information about the Bf-blender-cvs mailing list