From c9c2ecfd45174846bcfb8e3892c73315f9497a9e Mon Sep 17 00:00:00 2001 From: JoshQuake Date: Fri, 14 Jun 2024 14:57:29 -0700 Subject: [PATCH] fixed context override solved overriding context. If it can be optimized, feel free. --- ue2rigify/core/utilities.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/ue2rigify/core/utilities.py b/ue2rigify/core/utilities.py index 470c9b5a..e6ac803a 100644 --- a/ue2rigify/core/utilities.py +++ b/ue2rigify/core/utilities.py @@ -698,19 +698,15 @@ def toggle_expand_in_outliner(state=2): :param int state: 1 will expand all collections, 2 will collapse them. """ - try: - for area in bpy.context.screen.areas: - if area.type == 'OUTLINER': - override = {'area': area} - bpy.ops.outliner.show_hierarchy( - override_context=override, - execution_context='INVOKE_DEFAULT' - ) + area = next(a for a in bpy.context.screen.areas if a.type == 'OUTLINER') + + for area in bpy.context.screen.areas: + if area.type == 'OUTLINER': + with bpy.context.temp_override(area=area): + bpy.ops.outliner.show_hierarchy('INVOKE_DEFAULT') for i in range(state): - bpy.ops.outliner.expanded_toggle(override_context=override) - area.tag_redraw() - except RuntimeError as error: - print(error) + bpy.ops.outliner.expanded_toggle() + area.tag_redraw() def focus_on_selected():