Explorar o código

UI: error popup for Schema solve internal prepare phase

Joseph Brandenburg hai 6 meses
pai
achega
4cbcb13f62
Modificáronse 3 ficheiros con 13 adicións e 8 borrados
  1. 5 4
      readtree.py
  2. 7 3
      schema_solve.py
  3. 1 1
      xForm_containers.py

+ 5 - 4
readtree.py

@@ -419,7 +419,6 @@ def parse_tree(base_tree):
     prWhite("Number of Nodes: %s" % (len(kept_nc)))
     return kept_nc
 
-
 def switch_mode(mode='OBJECT', objects = []):
     active = None
     if objects:
@@ -433,14 +432,16 @@ def switch_mode(mode='OBJECT', objects = []):
 
 def execution_error_cleanup(node, exception, switch_objects = [] ):
     from bpy import  context
+    ui_sig = None
     if node:
+        ui_sig = node.ui_signature
         # TODO: see about zooming-to-node.
         base_tree = node.base_tree
         tree = base_tree
         try:
             pass
             space = context.space_data
-            for name in node.signature[1:]:
+            for name in ui_sig[1:]:
                 for n in tree.nodes: n.select = False
                 n = tree.nodes[name]
                 n.select = True
@@ -452,12 +453,12 @@ def execution_error_cleanup(node, exception, switch_objects = [] ):
         finally:
             def error_popup_draw(self, context):
                 self.layout.label(text=f"Error: {exception}")
-                self.layout.label(text=f"see node: {node.signature[1:]}.")
+                self.layout.label(text=f"see node: {ui_sig[1:]}.")
             context.window_manager.popup_menu(error_popup_draw, title="Error", icon='ERROR')
     switch_mode(mode='OBJECT', objects=switch_objects)
     for ob in switch_objects:
         ob.data.pose_position = 'POSE'
-    prRed(f"Error: {exception} in node {node}")
+    prRed(f"Error: {exception} in node {ui_sig}")
     return exception
 
 def execute_tree(nodes, base_tree, context, error_popups = False):

+ 7 - 3
schema_solve.py

@@ -438,10 +438,14 @@ class SchemaSolver:
         # and in fact, I could skip this in some cases, and should investigate if profiling reveals a slowdown here.
         forbidden=set()
         # forbid some nodes - they aren't necessary to solve the schema & cause problems.
+        from .readtree import execution_error_cleanup
         while unprepared:
             nc = unprepared.pop()
             if sum([dep.prepared for dep in nc.hierarchy_dependencies]) == len(nc.hierarchy_dependencies):
-                nc.bPrepare()
+                try:
+                    nc.bPrepare()
+                except Exception as e:
+                    execution_error_cleanup(nc, e)
                 if nc.node_type == 'DUMMY_SCHEMA':
                     self.solve_nested_schema(nc)
             elif nc.node_type == 'DUMMY_SCHEMA' and not self.test_is_sub_schema(nc):
@@ -652,9 +656,9 @@ class SchemaSolver:
             from .base_definitions import GraphError
             for o in self.node.outputs:
                 if o.is_linked:
-                    raise GraphError(f"ERROR: Schema {self.signature} has a length"
+                    raise GraphError(f"ERROR: Schema {self} has a length"
                                      " of 0 but other nodes depend on it.")
-            print (f"WARN: Schema {self.signature} has a length of 0 or less and will not expand.")
+            print (f"WARN: Schema {self} has a length of 0 or less and will not expand.")
             return {} # just don't do anything - it's OK to have a noop schema if it doesn't have dependencies.
         for index in range(self.solve_length):
             self.index = index

+ 1 - 1
xForm_containers.py

@@ -302,7 +302,7 @@ class xFormBone(xFormNode):
         if (not isinstance(bContext, bpy.types.Context)):
             raise RuntimeError("Incorrect context")
         if not (xF := self.bGetParentArmature()):
-            raise RuntimeError("Could not create edit bone: ", name, " from node:", self.signature, " Reason: No armature object to add bone to.")
+            raise RuntimeError("Could not create edit bone: ", name, " from node:", self, " Reason: No armature object to add bone to.")
 
         matrix = self.parameters['Matrix']
         length = matrix[3][3]