Эх сурвалжийг харах

Fix: Leaving a node group causes all same-tree nodes to update

previously it was possible for node-groups to be left un-updated.
Attempts were made to prevent the tree from executing during the update, although for some reason it still is.
Joseph Brandenburg 8 сар өмнө
parent
commit
6fb2c9b0b2
2 өөрчлөгдсөн 30 нэмэгдсэн , 3 устгасан
  1. 19 2
      ops_nodegroup.py
  2. 11 1
      utilities.py

+ 19 - 2
ops_nodegroup.py

@@ -158,9 +158,26 @@ class MantisEditGroup(Operator):
                 return {"FINISHED"}
         elif len(path) > 1:
             path.pop()
-            path[0].node_tree.display_update(context)
             # get the active node in the current path
-            path[len(path)-1].node_tree.nodes.active.update() # call update to force the node group to check if its tree has changed
+            active = path[len(path)-1].node_tree.nodes.active
+            from .base_definitions import node_group_update
+            active.is_updating = True
+            node_group_update(active, force = True)
+            active.is_updating = False
+            base_tree = path[0].node_tree
+            base_tree.do_live_update = False
+            # call update to force the node group to check if its tree has changed
+            # now we need to loop through the tree and update all node groups of this type.
+            from .utilities import get_all_nodes_of_type
+            for g in get_all_nodes_of_type(base_tree, "MantisNodeGroup"):
+                if g.node_tree == active.node_tree:
+                    g.is_updating = False
+                    node_group_update(g, force = True)
+                    g.is_updating = True
+            path[0].node_tree.display_update(context)
+            base_tree.do_live_update = True
+            return {"FINISHED"}
+
         return {"CANCELLED"}
 
 class ExecuteNodeTree(Operator):

+ 11 - 1
utilities.py

@@ -431,7 +431,6 @@ def get_all_dependencies(nc):
     from .base_definitions import GraphError
     """ Given a NC, find all dependencies for the NC as a dict of nc.signature:nc"""
     nodes = []
-    can_descend = True
     check_nodes = [nc]
     while (len(check_nodes) > 0):
         node = check_nodes.pop()
@@ -440,6 +439,17 @@ def get_all_dependencies(nc):
             if new_node in nodes: raise GraphError() 
             nodes.append(new_node)
     return nodes
+                
+def get_all_nodes_of_type(base_tree, bl_idname):
+    nodes = []
+    check_nodes = list(base_tree.nodes)
+    while (len(check_nodes) > 0):
+        node = check_nodes.pop()
+        if node.bl_idname in bl_idname:
+            nodes.append(node)
+        if hasattr(node, "node_tree"):
+            check_nodes.extend(list(node.node_tree.nodes))
+    return nodes
             
 ##################################################################################################
 # misc