From 7cdcb76815bb3f96b98f6443eecae35b22a236e7 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 30 Nov 2022 11:41:01 -0600 Subject: [PATCH] Cleanup: Remove node tree runtime fields `done` was only used in one place, and `is_updating` was never read. Generally we should avoid adding this sort of temporary data to longer lived structs. --- source/blender/blenkernel/BKE_node_runtime.hh | 5 ---- .../blender/editors/space_node/node_edit.cc | 23 ++++++++----------- .../editors/space_node/node_relationships.cc | 3 --- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/source/blender/blenkernel/BKE_node_runtime.hh b/source/blender/blenkernel/BKE_node_runtime.hh index 69e3b8915cc..ef32dcd8351 100644 --- a/source/blender/blenkernel/BKE_node_runtime.hh +++ b/source/blender/blenkernel/BKE_node_runtime.hh @@ -46,11 +46,6 @@ class bNodeTreeRuntime : NonCopyable, NonMovable { */ uint8_t runtime_flag = 0; - /** Flag to prevent re-entrant update calls. */ - short is_updating = 0; - /** Generic temporary flag for recursion check (DFS/BFS). */ - short done = 0; - /** Execution data. * * XXX It would be preferable to completely move this data out of the underlying node tree, diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index c6d1cc94c98..73d95f7af4b 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -2793,18 +2793,19 @@ static bool node_shader_script_update_poll(bContext *C) static bool node_shader_script_update_text_recursive(RenderEngine *engine, RenderEngineType *type, bNodeTree *ntree, - Text *text) + Text *text, + Set &done_trees) { bool found = false; - ntree->runtime->done = true; + done_trees.add_new(ntree); /* update each script that is using this text datablock */ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == NODE_GROUP) { bNodeTree *ngroup = (bNodeTree *)node->id; - if (ngroup && !ngroup->runtime->done) { - found |= node_shader_script_update_text_recursive(engine, type, ngroup, text); + if (ngroup && !done_trees.contains(ngroup)) { + found |= node_shader_script_update_text_recursive(engine, type, ngroup, text, done_trees); } } else if (node->type == SH_NODE_SCRIPT && node->id == &text->id) { @@ -2852,18 +2853,14 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op) Text *text = (Text *)CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data; if (text) { - /* clear flags for recursion check */ - FOREACH_NODETREE_BEGIN (bmain, ntree, id) { - if (ntree->type == NTREE_SHADER) { - ntree->runtime->done = false; - } - } - FOREACH_NODETREE_END; + + Set done_trees; FOREACH_NODETREE_BEGIN (bmain, ntree, id) { if (ntree->type == NTREE_SHADER) { - if (!ntree->runtime->done) { - found |= node_shader_script_update_text_recursive(engine, type, ntree, text); + if (!done_trees.contains(ntree)) { + found |= node_shader_script_update_text_recursive( + engine, type, ntree, text, done_trees); } } } diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index a18b5c83857..f37061e5efb 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -902,8 +902,6 @@ static void node_link_exit(bContext &C, wmOperator &op, const bool apply_links) bNodeTree &ntree = *snode.edittree; bNodeLinkDrag *nldrag = (bNodeLinkDrag *)op.customdata; - /* avoid updates while applying links */ - ntree.runtime->is_updating = true; for (bNodeLink *link : nldrag->links) { link->flag &= ~NODE_LINK_DRAGGED; @@ -929,7 +927,6 @@ static void node_link_exit(bContext &C, wmOperator &op, const bool apply_links) nodeRemLink(&ntree, link); } } - ntree.runtime->is_updating = false; ED_node_tree_propagate_change(&C, bmain, &ntree);