Fix error loading external shader styles

Mentioned in logs from #5820
Turned out, `area.spaces` also contain all other spaces this area used (e.g. it used be view3d before it became a nodegraph) leading to errors. Simplifying it with `area.spaces.active`.
This commit is contained in:
Andrej730
2024-12-04 16:58:13 +05:00
parent 00a509aa0b
commit bb441ade3f
+5 -4
View File
@@ -323,10 +323,11 @@ class Blender(bonsai.core.tool.Blender):
for screen in bpy.data.screens: for screen in bpy.data.screens:
for area in screen.areas: for area in screen.areas:
if area.type == "NODE_EDITOR": if area.type == "NODE_EDITOR":
for space in area.spaces: space = area.spaces.active
if space.tree_type == "ShaderNodeTree": assert isinstance(space, bpy.types.SpaceNodeEditor)
context_override = {"area": area, "space": space, "screen": screen} if space.tree_type == "ShaderNodeTree":
return context_override context_override = {"area": area, "space": space, "screen": screen}
return context_override
@classmethod @classmethod
def copy_node_graph(cls, material_to: bpy.types.Material, material_from: bpy.types.Material) -> None: def copy_node_graph(cls, material_to: bpy.types.Material, material_from: bpy.types.Material) -> None: