Fix drawing activation if drawing properties are using temp window #5791

This commit is contained in:
Andrej730
2024-11-25 18:07:26 +05:00
parent 7475a8f989
commit dd0355c539
2 changed files with 11 additions and 1 deletions
+10
View File
@@ -285,9 +285,19 @@ class Blender(bonsai.core.tool.Blender):
when in real life you can have a couple of those but should work for the most cases.
"""
area = cls.get_view3d_area()
assert area
region = next(region for region in area.regions if region.type == "WINDOW")
space = next(space for space in area.spaces if space.type == "VIEW_3D")
context_override = {"area": area, "region": region, "space_data": space}
# Need to override screen and window if area is from a different window.
screen: bpy.types.Scene = area.id_data
context = bpy.context
assert context
if context.screen != screen:
context_override["screen"] = screen
window = next(window for window in context.window_manager.windows if window.screen == screen)
context_override["window"] = window
return context_override
@classmethod
+1 -1
View File
@@ -1889,7 +1889,7 @@ class Drawing(bonsai.core.tool.Drawing):
subcontexts.append(context_filter)
# Hide everything first, then selectively show. This is significantly faster.
with bpy.context.temp_override(area=next(a for a in bpy.context.screen.areas if a.type == "VIEW_3D")):
with bpy.context.temp_override(**tool.Blender.get_viewport_context()):
bpy.ops.object.hide_view_set(unselected=False)
bpy.ops.object.hide_view_set(unselected=True)