浏览代码

crash prevention for bug in 4.5.0

it looks like attempting to access bpy_prop_array attributes in some
contexts can crash Blender 4.5.1 - I suspect this is because the
newly created node has not finished initializing its sockets
or something like that
anyhow this commit prevents it from crashing

Since I think the only case where it could result in a problem for the end-user is trying to group plain Matrix nodes
which are not useful for anything but testing, I judge that
it isn't a serious enough problem to work around.
Joseph Brandenburg 2 月之前
父节点
当前提交
b5ec2553c6
共有 1 个文件被更改,包括 11 次插入0 次删除
  1. 11 0
      utilities.py

+ 11 - 0
utilities.py

@@ -229,6 +229,17 @@ def do_relink(node, s, map, in_out='INPUT', parent_name = ''):
                 raise RuntimeError("Unhandled case in do_relink()")
                 raise RuntimeError("Unhandled case in do_relink()")
     elif get_string != "__extend__":
     elif get_string != "__extend__":
         if not s.is_output:
         if not s.is_output:
+            from bpy.app import version as bpy_version
+            if bpy_version >=(4,5,0): # VERSIONING
+                # for some reason, this is throwing an error now
+                from bpy.types import bpy_prop_array
+                if isinstance(val, bpy_prop_array):
+                    if in_out == "INPUT" and s.input == False:
+                        return # doesn't matter, this is a Matrix socket in a bone or something
+                    raise RuntimeError(
+                          f"Cannot set property in socket of type {s.bl_idname} due to bug in Blender: "
+                          f"{node.id_data.name}:{node.name}:{s.name} ")
+                    # TODO: report this weird bug!
             try:
             try:
                 s.default_value = val
                 s.default_value = val
             except (AttributeError, ValueError): # must be readonly or maybe it doesn't have a d.v.
             except (AttributeError, ValueError): # must be readonly or maybe it doesn't have a d.v.