Browse Source

guard updating with bool for schema interface nodes

failing to guard the update caused unwanted connections in
versioning, because the nodes were allowed to update
outside of the normal user interaction
Joseph Brandenburg 3 months ago
parent
commit
48e7e0a3d1
2 changed files with 38 additions and 3 deletions
  1. 1 0
      base_definitions.py
  2. 37 3
      schema_definitions.py

+ 1 - 0
base_definitions.py

@@ -280,6 +280,7 @@ class MantisUINode:
             
             
 class SchemaUINode(MantisUINode):
 class SchemaUINode(MantisUINode):
     mantis_node_library='.schema_containers'
     mantis_node_library='.schema_containers'
+    is_updating:BoolProperty(default=False)
     @classmethod
     @classmethod
     def poll(cls, ntree):
     def poll(cls, ntree):
         return (ntree.bl_idname in ['SchemaTree'])
         return (ntree.bl_idname in ['SchemaTree'])

+ 37 - 3
schema_definitions.py

@@ -29,6 +29,7 @@ def TellClasses():
 # - check what happens when these get plugged into each other
 # - check what happens when these get plugged into each other
 # - probably disallow all or most of these connections in insert_link or update
 # - probably disallow all or most of these connections in insert_link or update
 
 
+
 class SchemaIndex(Node, SchemaUINode):
 class SchemaIndex(Node, SchemaUINode):
     '''The current index of the schema execution'''
     '''The current index of the schema execution'''
     bl_idname = 'SchemaIndex'
     bl_idname = 'SchemaIndex'
@@ -54,6 +55,9 @@ class SchemaArrayInput(Node, SchemaUINode):
         self.update()
         self.update()
 
 
     def update(self):
     def update(self):
+        if self.is_updating:
+            return
+        self.is_updating = True
         # self.initialized = False
         # self.initialized = False
         socket_maps = get_socket_maps(self)
         socket_maps = get_socket_maps(self)
         if socket_maps is None:
         if socket_maps is None:
@@ -69,6 +73,7 @@ class SchemaArrayInput(Node, SchemaUINode):
         if len(self.inputs)<1 or self.inputs[-1].bl_idname not in ["WildcardSocket"]:
         if len(self.inputs)<1 or self.inputs[-1].bl_idname not in ["WildcardSocket"]:
             self.outputs.new('WildcardSocket', '', identifier='__extend__')
             self.outputs.new('WildcardSocket', '', identifier='__extend__')
         # self.initialized = True
         # self.initialized = True
+        self.is_updating = False
 
 
 class SchemaArrayInputAll(Node, SchemaUINode):
 class SchemaArrayInputAll(Node, SchemaUINode):
     '''Array Inputs'''
     '''Array Inputs'''
@@ -82,7 +87,10 @@ class SchemaArrayInputAll(Node, SchemaUINode):
         self.update()
         self.update()
 
 
     def update(self):
     def update(self):
-        # self.initialized = False
+        if self.is_updating:
+            return
+        self.is_updating = True
+        self.initialized = False
         socket_maps = get_socket_maps(self)
         socket_maps = get_socket_maps(self)
         if socket_maps is None:
         if socket_maps is None:
             return
             return
@@ -96,6 +104,8 @@ class SchemaArrayInputAll(Node, SchemaUINode):
             do_relink(self, None, output_map, in_out='OUTPUT', parent_name='Array' )
             do_relink(self, None, output_map, in_out='OUTPUT', parent_name='Array' )
         if len(self.inputs)<1 or self.inputs[-1].bl_idname not in ["WildcardSocket"]:
         if len(self.inputs)<1 or self.inputs[-1].bl_idname not in ["WildcardSocket"]:
             self.outputs.new('WildcardSocket', '', identifier='__extend__')
             self.outputs.new('WildcardSocket', '', identifier='__extend__')
+        self.initialized = True
+        self.is_updating = False
 
 
 class SchemaArrayInputGet(Node, SchemaUINode):
 class SchemaArrayInputGet(Node, SchemaUINode):
     '''Array Inputs'''
     '''Array Inputs'''
@@ -111,7 +121,10 @@ class SchemaArrayInputGet(Node, SchemaUINode):
         self.update()
         self.update()
 
 
     def update(self):
     def update(self):
-        # self.initialized = False
+        if self.is_updating:
+            return
+        self.is_updating = True
+        self.initialized = False
         socket_maps = get_socket_maps(self)
         socket_maps = get_socket_maps(self)
         if socket_maps is None:
         if socket_maps is None:
             return
             return
@@ -125,7 +138,8 @@ class SchemaArrayInputGet(Node, SchemaUINode):
             do_relink(self, None, output_map, in_out='OUTPUT', parent_name='Array' )
             do_relink(self, None, output_map, in_out='OUTPUT', parent_name='Array' )
         if len(self.inputs)<1 or self.inputs[-1].bl_idname not in ["WildcardSocket"]:
         if len(self.inputs)<1 or self.inputs[-1].bl_idname not in ["WildcardSocket"]:
             self.outputs.new('WildcardSocket', '', identifier='__extend__')
             self.outputs.new('WildcardSocket', '', identifier='__extend__')
-        # self.initialized = True
+        self.initialized = True
+        self.is_updating = False
 
 
 class SchemaArrayOutput(Node, SchemaUINode):
 class SchemaArrayOutput(Node, SchemaUINode):
     '''Array Inputs'''
     '''Array Inputs'''
@@ -139,6 +153,9 @@ class SchemaArrayOutput(Node, SchemaUINode):
         self.update()
         self.update()
 
 
     def update(self):
     def update(self):
+        if self.is_updating:
+            return
+        self.is_updating = True
         self.initialized = False
         self.initialized = False
         socket_maps = get_socket_maps(self)
         socket_maps = get_socket_maps(self)
         if socket_maps is None:
         if socket_maps is None:
@@ -156,6 +173,7 @@ class SchemaArrayOutput(Node, SchemaUINode):
         for s in self.outputs:
         for s in self.outputs:
             s.input= True
             s.input= True
         self.initialized = True
         self.initialized = True
+        self.is_updating = False
 
 
 class SchemaConstInput(Node, SchemaUINode):
 class SchemaConstInput(Node, SchemaUINode):
     '''Constant Inputs'''
     '''Constant Inputs'''
@@ -169,6 +187,9 @@ class SchemaConstInput(Node, SchemaUINode):
         self.update()
         self.update()
 
 
     def update(self):
     def update(self):
+        if self.is_updating:
+            return
+        self.is_updating = True
         self.initialized = False
         self.initialized = False
         socket_maps = get_socket_maps(self)
         socket_maps = get_socket_maps(self)
         if socket_maps is None:
         if socket_maps is None:
@@ -184,6 +205,7 @@ class SchemaConstInput(Node, SchemaUINode):
         if len(self.inputs)<1 or self.inputs[-1].bl_idname not in ["WildcardSocket"]:
         if len(self.inputs)<1 or self.inputs[-1].bl_idname not in ["WildcardSocket"]:
             self.outputs.new('WildcardSocket', '', identifier='__extend__')
             self.outputs.new('WildcardSocket', '', identifier='__extend__')
         self.initialized = True
         self.initialized = True
+        self.is_updating = False
 
 
 
 
 
 
@@ -199,6 +221,9 @@ class SchemaConstOutput(Node, SchemaUINode):
         self.update()
         self.update()
 
 
     def update(self):
     def update(self):
+        if self.is_updating:
+            return
+        self.is_updating = True
         self.initialized = False
         self.initialized = False
         socket_maps = get_socket_maps(self)
         socket_maps = get_socket_maps(self)
         if socket_maps is None:
         if socket_maps is None:
@@ -219,6 +244,7 @@ class SchemaConstOutput(Node, SchemaUINode):
             s.input= True
             s.input= True
         
         
         self.initialized = True
         self.initialized = True
+        self.is_updating = False
 
 
 
 
 
 
@@ -234,6 +260,9 @@ class SchemaOutgoingConnection(Node, SchemaUINode):
         self.update()
         self.update()
 
 
     def update(self):
     def update(self):
+        if self.is_updating:
+            return
+        self.is_updating = True
         self.initialized = False
         self.initialized = False
         socket_maps = get_socket_maps(self)
         socket_maps = get_socket_maps(self)
         if socket_maps is None:
         if socket_maps is None:
@@ -251,6 +280,7 @@ class SchemaOutgoingConnection(Node, SchemaUINode):
         for s in self.outputs:
         for s in self.outputs:
             s.input= True
             s.input= True
         self.initialized = True
         self.initialized = True
+        self.is_updating = False
 
 
 
 
 
 
@@ -266,6 +296,9 @@ class SchemaIncomingConnection(Node, SchemaUINode):
         self.update()
         self.update()
 
 
     def update(self):
     def update(self):
+        if self.is_updating:
+            return
+        self.is_updating = True
         self.initialized = False
         self.initialized = False
         socket_maps = get_socket_maps(self)
         socket_maps = get_socket_maps(self)
         if socket_maps is None:
         if socket_maps is None:
@@ -281,6 +314,7 @@ class SchemaIncomingConnection(Node, SchemaUINode):
         if len(self.inputs)<1 or self.inputs[-1].bl_idname not in ["WildcardSocket"]:
         if len(self.inputs)<1 or self.inputs[-1].bl_idname not in ["WildcardSocket"]:
             self.outputs.new('WildcardSocket', '', identifier='__extend__')
             self.outputs.new('WildcardSocket', '', identifier='__extend__')
         self.initialized = True
         self.initialized = True
+        self.is_updating = False
 
 
 
 
 for cls in TellClasses():
 for cls in TellClasses():