Fix: Add window to shader editor context override

The copy_node_graph() method checks for a "window" key in the context
override, but get_shader_editor_context() wasn't providing it. This
caused the function to return early, preventing external styles from
loading.

Updated get_shader_editor_context() to include the window when the
screen differs from the current context, following the same pattern
used in get_viewport_context().
This commit is contained in:
Ryan Schultz
2025-12-27 09:59:47 -06:00
parent 7fcdec0a4c
commit d69b4927a2
+11 -6
View File
@@ -382,17 +382,22 @@ class Blender(bonsai.core.tool.Blender):
assert isinstance(space, bpy.types.SpaceNodeEditor)
if space.tree_type == "ShaderNodeTree":
context_override = {"area": area, "space": space, "screen": screen}
# Add window if screen differs from current context
context = bpy.context
if context and context.screen != screen:
window = next(
(w for w in context.window_manager.windows if w.screen == screen),
None
)
if window:
context_override["window"] = window
return context_override
@classmethod
def copy_node_graph(cls, material_to: bpy.types.Material, material_from: bpy.types.Material) -> None:
temp_override = cls.get_shader_editor_context()
if (
not temp_override
or any(k not in temp_override for k in ("area", "space", "screen"))
or temp_override.get("window") is None
):
return
shader_editor = temp_override["space"]
# remove all nodes from the current material