Parcourir la source

Fix: ensure autogen nodes are always unique

this bit of code is used by Schema, where previously held
assumptions about its safety no longer apply...
hence: extremely confusing bug that took >10 hours to find the source of

without this uuid signature and the (mostly redndant) check to see
if the node already exists, it is possible to generate nodes
which rely on the nodes that are now shadowed by new nodes.
thus, these nodes never execute because their dependencies
can never be resolved - since the nodes they depend on are no longer
in the parsed tree.

The pattern the error follows is: within a schema, only the most recent nodes in the schema execute. Older nodes are left behind
and cause the tree to fail without detecting a specific error.
Joseph Brandenburg il y a 5 mois
Parent
commit
40c11e20ff
1 fichiers modifiés avec 8 ajouts et 3 suppressions
  1. 8 3
      readtree.py

+ 8 - 3
readtree.py

@@ -117,9 +117,14 @@ def make_connections_to_ng_dummy(base_tree, tree_path_names, local_nc, all_nc, n
             continue # it isn't a real input so I don't think it is good to check it.
         to_s = inp.identifier
         if not inp.is_linked: # make an autogenerated NC for the inputs of the group node
-            signature = ("MANTIS_AUTOGENERATED", *tree_path_names, np.name, inp.name, inp.identifier)
-            nc_from = autogen_node(base_tree, inp, signature, nc_to.mContext)
-            if nc_from:
+            # This can be run inside schema. Make it unique with uuid() to be safe.
+            from uuid import uuid4
+            signature = ("MANTIS_AUTOGENERATED", *tree_path_names, np.name, inp.name, inp.identifier, str(uuid4()))
+            nc_from = all_nc.get(signature) # creating this without checking and
+            #  using UUID signature leads to TERRIBLE CONFUSING BUGS.
+            if nc_from is None: 
+                nc_from = autogen_node(base_tree, inp, signature, nc_to.mContext)
+            if nc_from: # autogen can fail and we should catch it.
                 from .node_container_common import get_socket_value
                 nc_from.parameters = {inp.name:get_socket_value(inp)}
                 local_nc[signature] = nc_from; all_nc[signature] = nc_from