From c6072589759db9f30fdde631907304f78f1566d8 Mon Sep 17 00:00:00 2001 From: Jesse Yurkovich Date: Sun, 4 Jun 2023 18:54:22 -0700 Subject: [PATCH] Fix #104670: Update Modifier Tools for removal of old context override --- space_view3d_modifier_tools.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/space_view3d_modifier_tools.py b/space_view3d_modifier_tools.py index ef3120729..9dcabb99d 100644 --- a/space_view3d_modifier_tools.py +++ b/space_view3d_modifier_tools.py @@ -34,23 +34,19 @@ class ApplyAllModifiers(Operator): is_select = True # copying context for the operator's override - contx = bpy.context.copy() - contx['object'] = obj + context_override = {'object': obj} modifiers = modifier_type(obj) for mod in modifiers[:]: - contx['modifier'] = mod + context_override['modifier'] = mod is_mod = True try: - bpy.ops.object.modifier_apply( - contx, - modifier=contx['modifier'].name - ) - - bpy.ops.object.gpencil_modifier_apply( - modifier=contx['modifier'].name - ) + with bpy.context.temp_override(**context_override): + if obj.type != 'GPENCIL': + bpy.ops.object.modifier_apply(modifier=mod.name) + else: + bpy.ops.object.gpencil_modifier_apply(modifier=mod.name) except: obj_name = getattr(obj, "name", "NO NAME") collect_names.append(obj_name) -- 2.30.2