瀏覽代碼

Fix? infinite Loop from Socket Update

this commit prevents an infinite loop caused by
adding/removing a link causing
schema nodes' socket updates to trigger infinity updates
I am not smart enough to figure this out right now.
but I think I have fixed it
Joseph Brandenburg 4 周之前
父節點
當前提交
3d5816e006
共有 1 個文件被更改,包括 13 次插入 和 3 次删除
  1. 13 3
      socket_definitions.py

+ 13 - 3
socket_definitions.py

@@ -470,9 +470,19 @@ def default_update(ui_socket, context, do_execute=True):
     # if it is a Schema Node, it will fail the checks below -- but we need it to update the tree.
     from .base_definitions import SchemaUINode
     if isinstance(ui_socket.node, SchemaUINode):
-        node_tree.update_tree(context, force = True)
-        prPurple(f"Executing tree after socket change: {ui_socket.node.name}:{ui_socket.name}")
-        node_tree.execute_tree(context)
+        # This was causing infinite loops before checking for is_updating
+        # It seems to be happening when adding/removing links that are in schema trees
+        # even if they are not connected to the schema node
+        # I suspect that this completely disables this feature... whatever. TODO checc this
+        if ui_socket.node.is_updating: return
+        updating = ui_socket.node.is_updating
+        ui_socket.node.is_updating=True
+        try:
+            node_tree.update_tree(context, force = True)
+            prPurple(f"Executing tree after socket change: {ui_socket.node.name}:{ui_socket.name}")
+            node_tree.execute_tree(context)
+        finally:
+            ui_socket.node.is_updating=updating
         return
     if hasattr(ui_socket.node, "initialized"):
         if not ui_socket.node.initialized: return