diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-21 12:07:17 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-22 12:29:56 +0300 |
commit | 25f1c2b04e0d98587c88c5ea26b59650e5c2e3f7 (patch) | |
tree | c4e038cae798ff9c15fcee4fb54ffbb18295ed63 | |
parent | f24ca278e8f67e8cf3f3635b138089d8e53681af (diff) |
Add-ons: remove temporary disabling of use_global_undo
This can cause bugs where if the operator throws an exception, undo is not
properly enabled again. There have been maybe a dozen Blender bug reports
related to this. This could get worse now that we are autosaving preferences.
Some add-ons guard against this, but turning off undo should not be needed in
the first place. If the operator is set to do an undo push, any operators it
calls will automatically not do any undo pushes.
If this fail in some cases, it should be reported as a bug in Blender. I could
not find issues or a performance impact testing a few add-ons though.
Differential Revision: https://developer.blender.org/D4908
-rw-r--r-- | add_curve_extra_objects/add_curve_aceous_galore.py | 9 | ||||
-rw-r--r-- | add_curve_extra_objects/add_curve_spirofit_bouncespline.py | 12 | ||||
-rw-r--r-- | add_curve_extra_objects/add_curve_torus_knots.py | 9 | ||||
-rw-r--r-- | add_mesh_extra_objects/add_mesh_solid.py | 7 | ||||
-rw-r--r-- | ant_landscape/add_mesh_ant_landscape.py | 5 | ||||
-rw-r--r-- | ant_landscape/ant_functions.py | 14 | ||||
-rw-r--r-- | ant_landscape/mesh_ant_displace.py | 7 | ||||
-rw-r--r-- | curve_simplify.py | 7 | ||||
-rw-r--r-- | io_scene_ms3d/ms3d_export.py | 3 | ||||
-rw-r--r-- | io_scene_ms3d/ms3d_utils.py | 8 | ||||
-rw-r--r-- | mesh_bsurfaces.py | 14 | ||||
-rw-r--r-- | mesh_looptools.py | 36 | ||||
-rw-r--r-- | rigify/legacy/rig_ui_pitchipoy_template.py | 28 | ||||
-rw-r--r-- | rigify/legacy/rig_ui_template.py | 28 | ||||
-rw-r--r-- | rigify/legacy/ui.py | 7 | ||||
-rw-r--r-- | rigify/rig_ui_template.py | 28 | ||||
-rw-r--r-- | rigify/ui.py | 11 |
17 files changed, 30 insertions, 203 deletions
diff --git a/add_curve_extra_objects/add_curve_aceous_galore.py b/add_curve_extra_objects/add_curve_aceous_galore.py index 62ac823c..5b67dcad 100644 --- a/add_curve_extra_objects/add_curve_aceous_galore.py +++ b/add_curve_extra_objects/add_curve_aceous_galore.py @@ -1433,10 +1433,6 @@ class Curveaceous_galore(Operator, object_utils.AddObjectHelper): return context.scene is not None def execute(self, context): - # turn off undo - undo = context.preferences.edit.use_global_undo - context.preferences.edit.use_global_undo = False - # deal with 2D - 3D curve differences if self.ProfileType in ['Helix', 'Cycloid', 'Noise']: self.shape = '3D' @@ -1460,9 +1456,6 @@ class Curveaceous_galore(Operator, object_utils.AddObjectHelper): self.align_matrix = align_matrix(context, self.startlocation) main(context, self, self.align_matrix or Matrix()) - # restore pre operator undo state - context.preferences.edit.use_global_undo = undo - return {'FINISHED'} # Register @@ -1481,4 +1474,4 @@ def unregister(): unregister_class(cls) if __name__ == "__main__": - register()
\ No newline at end of file + register() diff --git a/add_curve_extra_objects/add_curve_spirofit_bouncespline.py b/add_curve_extra_objects/add_curve_spirofit_bouncespline.py index 5c35d2bc..8d4179ba 100644 --- a/add_curve_extra_objects/add_curve_spirofit_bouncespline.py +++ b/add_curve_extra_objects/add_curve_spirofit_bouncespline.py @@ -317,9 +317,6 @@ class SpiroFitSpline(Operator): "Active Object is not a Mesh. Operation Cancelled") return {'CANCELLED'} - #undo = context.preferences.edit.use_global_undo - #context.preferences.edit.use_global_undo = False - bpy.ops.object.select_all(action='DESELECT') r.seed(self.random_seed) @@ -357,7 +354,6 @@ class SpiroFitSpline(Operator): if self.auto_refresh is False: self.refresh = False - #context.preferences.edit.use_global_undo = undo return {'FINISHED'} @@ -585,9 +581,6 @@ class BounceSpline(Operator): if obj.type != 'MESH': return {'CANCELLED'} - #undo = context.preferences.edit.use_global_undo - #context.preferences.edit.use_global_undo = False - bpy.ops.object.select_all(action='DESELECT') r.seed(self.random_seed) @@ -622,7 +615,6 @@ class BounceSpline(Operator): if self.auto_refresh is False: self.refresh = False - #context.preferences.edit.use_global_undo = undo return {'FINISHED'} @@ -823,9 +815,6 @@ class CatenaryCurve(Operator): bpy.ops.object.select_all(action='DESELECT') - #undo = context.preferences.edit.use_global_undo - #context.preferences.edit.use_global_undo = False - r.seed(self.random_seed) points = catenary_curve( @@ -857,7 +846,6 @@ class CatenaryCurve(Operator): if self.auto_refresh is False: self.refresh = False - #context.preferences.edit.use_global_undo = undo return {'FINISHED'} diff --git a/add_curve_extra_objects/add_curve_torus_knots.py b/add_curve_extra_objects/add_curve_torus_knots.py index 8352ecfa..3b2b362c 100644 --- a/add_curve_extra_objects/add_curve_torus_knots.py +++ b/add_curve_extra_objects/add_curve_torus_knots.py @@ -711,16 +711,9 @@ class torus_knot_plus(Operator, AddObjectHelper): # update align matrix self.align_matrix = align_matrix(self, context) - # turn off undo - #undo = bpy.context.preferences.edit.use_global_undo - #bpy.context.preferences.edit.use_global_undo = False - # create the curve create_torus_knot(self, context) - # restore pre operator undo state - #bpy.context.preferences.edit.use_global_undo = undo - return {'FINISHED'} def invoke(self, context, event): @@ -744,4 +737,4 @@ def unregister(): unregister_class(cls) if __name__ == "__main__": - register()
\ No newline at end of file + register() diff --git a/add_mesh_extra_objects/add_mesh_solid.py b/add_mesh_extra_objects/add_mesh_solid.py index 98172d37..59e070df 100644 --- a/add_mesh_extra_objects/add_mesh_solid.py +++ b/add_mesh_extra_objects/add_mesh_solid.py @@ -449,10 +449,6 @@ class Solids(bpy.types.Operator): previousSetting = "" def execute(self, context): - # turn off undo for better performance (3-5x faster), also makes sure - # that mesh ops are undoable and entire script acts as one operator - bpy.context.preferences.edit.use_global_undo = False - # piece of code to make presets remain until parameters are changed if self.preset != "0": # if preset, set preset @@ -512,7 +508,4 @@ class Solids(bpy.types.Operator): object_data_add(context, mesh, operator=None) # object generation done - # turn undo back on - bpy.context.preferences.edit.use_global_undo = True - return {'FINISHED'} diff --git a/ant_landscape/add_mesh_ant_landscape.py b/ant_landscape/add_mesh_ant_landscape.py index bb2173d0..c80256d5 100644 --- a/ant_landscape/add_mesh_ant_landscape.py +++ b/ant_landscape/add_mesh_ant_landscape.py @@ -593,10 +593,6 @@ class AntAddLandscape(bpy.types.Operator): if not self.refresh: return {'PASS_THROUGH'} - # turn off undo - undo = bpy.context.preferences.edit.use_global_undo - bpy.context.preferences.edit.use_global_undo = False - # turn off 'Enter Edit Mode' use_enter_edit_mode = bpy.context.preferences.edit.use_enter_edit_mode bpy.context.preferences.edit.use_enter_edit_mode = False @@ -783,7 +779,6 @@ class AntAddLandscape(bpy.types.Operator): self.refresh = False # restore pre operator state - context.preferences.edit.use_global_undo = undo bpy.context.preferences.edit.use_enter_edit_mode = use_enter_edit_mode return {'FINISHED'} diff --git a/ant_landscape/ant_functions.py b/ant_landscape/ant_functions.py index 62fe4916..075c33b0 100644 --- a/ant_landscape/ant_functions.py +++ b/ant_landscape/ant_functions.py @@ -141,10 +141,6 @@ class AntLandscapeRefresh(bpy.types.Operator): def execute(self, context): - # turn off undo - undo = bpy.context.preferences.edit.use_global_undo - bpy.context.preferences.edit.use_global_undo = False - # ant object items obj = bpy.context.active_object @@ -177,9 +173,6 @@ class AntLandscapeRefresh(bpy.types.Operator): else: pass - # restore pre operator undo state - context.preferences.edit.use_global_undo = undo - return {'FINISHED'} # ------------------------------------------------------------ @@ -201,10 +194,6 @@ class AntLandscapeRegenerate(bpy.types.Operator): def execute(self, context): - # turn off undo - undo = bpy.context.preferences.edit.use_global_undo - bpy.context.preferences.edit.use_global_undo = False - view_layer = bpy.context.view_layer # ant object items obj = bpy.context.active_object @@ -328,9 +317,6 @@ class AntLandscapeRegenerate(bpy.types.Operator): new_ob.select_set(True) view_layer.objects.active = new_ob - # restore pre operator undo state - context.preferences.edit.use_global_undo = undo - return {'FINISHED'} diff --git a/ant_landscape/mesh_ant_displace.py b/ant_landscape/mesh_ant_displace.py index 3442711f..917cc34b 100644 --- a/ant_landscape/mesh_ant_displace.py +++ b/ant_landscape/mesh_ant_displace.py @@ -596,10 +596,6 @@ class AntMeshDisplace(bpy.types.Operator): if not self.refresh: return {'PASS_THROUGH'} - # turn off undo - undo = bpy.context.preferences.edit.use_global_undo - bpy.context.preferences.edit.use_global_undo = False - ob = context.object # Properties: @@ -725,7 +721,4 @@ class AntMeshDisplace(bpy.types.Operator): if self.auto_refresh is False: self.refresh = False - # restore pre operator undo state - context.preferences.edit.use_global_undo = undo - return {'FINISHED'} diff --git a/curve_simplify.py b/curve_simplify.py index 1518ed5f..ff42c878 100644 --- a/curve_simplify.py +++ b/curve_simplify.py @@ -574,20 +574,13 @@ class CURVE_OT_simplify(Operator): self.keepShort # 7 ] try: - global_undo = bpy.context.preferences.edit.use_global_undo - context.preferences.edit.use_global_undo = False - bpy.ops.object.mode_set(mode='OBJECT') obj = context.active_object curve_dimension = obj.data.dimensions main(context, obj, options, curve_dimension) - - context.preferences.edit.use_global_undo = global_undo except Exception as e: error_handlers(self, "curve.simplify", e, "Simplify Curves") - - context.preferences.edit.use_global_undo = global_undo return {'CANCELLED'} return {'FINISHED'} diff --git a/io_scene_ms3d/ms3d_export.py b/io_scene_ms3d/ms3d_export.py index 4fe31c00..bd5d2f2f 100644 --- a/io_scene_ms3d/ms3d_export.py +++ b/io_scene_ms3d/ms3d_export.py @@ -164,9 +164,6 @@ class Ms3dExporter(): blender_context.view_layer.objects.active \ = blender_context.selected_objects[0] - # restore pre operator undo state - blender_context.preferences.edit.use_global_undo = self.undo - is_valid, statistics = ms3d_model.is_valid() if self.options_verbose in Ms3dUi.VERBOSE_NORMAL: print() diff --git a/io_scene_ms3d/ms3d_utils.py b/io_scene_ms3d/ms3d_utils.py index 330c53bb..943d8708 100644 --- a/io_scene_ms3d/ms3d_utils.py +++ b/io_scene_ms3d/ms3d_utils.py @@ -97,11 +97,6 @@ def select_all(select): ############################################################################### def pre_setup_environment(porter, blender_context): - # inject undo to porter - # and turn off undo - porter.undo = blender_context.preferences.edit.use_global_undo - blender_context.preferences.edit.use_global_undo = False - # inject active_object to self porter.active_object = blender_context.view_layer.objects.active @@ -125,9 +120,6 @@ def post_setup_environment(porter, blender_context): blender_context.view_layer.objects.active \ = blender_context.selected_objects[0] - # restore pre operator undo state - blender_context.preferences.edit.use_global_undo = porter.undo - ############################################################################### def get_edge_split_modifier_add_if(blender_mesh_object): diff --git a/mesh_bsurfaces.py b/mesh_bsurfaces.py index 78ccfe4d..04139c25 100644 --- a/mesh_bsurfaces.py +++ b/mesh_bsurfaces.py @@ -3086,8 +3086,6 @@ class GPENCIL_OT_SURFSK_add_surface(Operator): self.main_object = bsurfaces_props.SURFSK_object_with_retopology self.main_object.select_set(True) bpy.context.view_layer.objects.active = self.main_object - - #bpy.context.preferences.edit.use_global_undo = False if not self.is_fill_faces: bpy.ops.wm.context_set_value(data_path='tool_settings.mesh_select_mode', @@ -3172,13 +3170,9 @@ class GPENCIL_OT_SURFSK_add_surface(Operator): bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN') - #bpy.context.preferences.edit.use_global_undo = self.initial_global_undo_state - return{'FINISHED'} def invoke(self, context, event): - #self.initial_global_undo_state = bpy.context.preferences.edit.use_global_undo - if bpy.ops.object.mode_set.poll(): bpy.ops.object.mode_set(mode='OBJECT') @@ -3199,7 +3193,6 @@ class GPENCIL_OT_SURFSK_add_surface(Operator): self.main_object_selected_verts_count = int(self.main_object.data.total_vert_sel) - #bpy.context.preferences.edit.use_global_undo = False bpy.ops.wm.context_set_value(data_path='tool_settings.mesh_select_mode', value='True, False, False') @@ -3401,8 +3394,6 @@ class GPENCIL_OT_SURFSK_add_surface(Operator): # Delete temporary strokes curve object bpy.ops.object.delete({"selected_objects": [self.temporary_curve]}) - #bpy.context.preferences.edit.use_global_undo = False - # If "Keep strokes" option is not active, delete original strokes curve object if (not self.stopping_errors and not self.keep_strokes) or self.is_crosshatch: bpy.ops.object.delete({"selected_objects": [self.original_curve]}) @@ -3423,8 +3414,6 @@ class GPENCIL_OT_SURFSK_add_surface(Operator): #bpy.ops.gpencil.surfsk_add_surface() self.execute(context) - #bpy.context.preferences.edit.use_global_undo = self.initial_global_undo_state - if not self.stopping_errors: return {"FINISHED"} else: @@ -3435,7 +3424,6 @@ class GPENCIL_OT_SURFSK_add_surface(Operator): created_faces_count = self.fill_with_faces(self.main_object) bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN') - #bpy.context.preferences.edit.use_global_undo = self.initial_global_undo_state if created_faces_count == 0: self.report({'WARNING'}, "There aren't any strokes attached to the object") @@ -3443,8 +3431,6 @@ class GPENCIL_OT_SURFSK_add_surface(Operator): else: return {"FINISHED"} - #bpy.context.preferences.edit.use_global_undo = self.initial_global_undo_state - if self.strokes_type == "EXTERNAL_NO_CURVE": self.report({'WARNING'}, "The secondary object is not a Curve.") return{"CANCELLED"} diff --git a/mesh_looptools.py b/mesh_looptools.py index 2b11465f..87c23383 100644 --- a/mesh_looptools.py +++ b/mesh_looptools.py @@ -747,8 +747,6 @@ def get_parallel_loops(bm_mod, loops): # gather initial data def initialise(): - global_undo = bpy.context.preferences.edit.use_global_undo - bpy.context.preferences.edit.use_global_undo = False object = bpy.context.active_object if 'MIRROR' in [mod.type for mod in object.modifiers if mod.show_viewport]: # ensure that selection is synced for the derived mesh @@ -760,7 +758,7 @@ def initialise(): bm.edges.ensure_lookup_table() bm.faces.ensure_lookup_table() - return(global_undo, object, bm) + return(object, bm) # move the vertices to their new locations @@ -830,14 +828,12 @@ def settings_write(self): # clean up and set settings back to original state -def terminate(global_undo): +def terminate(): # update editmesh cached data obj = bpy.context.active_object if obj.mode == 'EDIT': bmesh.update_edit_mesh(obj.data, loop_triangles=True, destructive=True) - bpy.context.preferences.edit.use_global_undo = global_undo - # ######################################## # ##### Bridge functions ################# @@ -3301,7 +3297,7 @@ class Bridge(Operator): def execute(self, context): # initialise - global_undo, object, bm = initialise() + object, bm = initialise() edge_faces, edgekey_to_edge, old_selected_faces, smooth = \ bridge_initialise(bm, self.interpolation) settings_write(self) @@ -3375,7 +3371,7 @@ class Bridge(Operator): bpy.ops.mesh.normals_make_consistent() # cleaning up - terminate(global_undo) + terminate() return{'FINISHED'} @@ -3484,7 +3480,7 @@ class Circle(Operator): def execute(self, context): # initialise - global_undo, object, bm = initialise() + object, bm = initialise() settings_write(self) # check cache to see if we can save time cached, single_loops, loops, derived, mapping = cache_read("Circle", @@ -3548,7 +3544,7 @@ class Circle(Operator): # cleaning up if derived: bm_mod.free() - terminate(global_undo) + terminate() return{'FINISHED'} @@ -3648,7 +3644,7 @@ class Curve(Operator): def execute(self, context): # initialise - global_undo, object, bm = initialise() + object, bm = initialise() settings_write(self) # check cache to see if we can save time cached, single_loops, loops, derived, mapping = cache_read("Curve", @@ -3692,7 +3688,7 @@ class Curve(Operator): # cleaning up if derived: bm_mod.free() - terminate(global_undo) + terminate() return{'FINISHED'} @@ -3780,7 +3776,7 @@ class Flatten(Operator): def execute(self, context): # initialise - global_undo, object, bm = initialise() + object, bm = initialise() settings_write(self) # check cache to see if we can save time cached, single_loops, loops, derived, mapping = cache_read("Flatten", @@ -3814,7 +3810,7 @@ class Flatten(Operator): move_verts(object, bm, False, move, lock, self.influence) # cleaning up - terminate(global_undo) + terminate() return{'FINISHED'} @@ -3989,7 +3985,7 @@ class GStretch(Operator): def execute(self, context): # initialise - global_undo, object, bm = initialise() + object, bm = initialise() settings_write(self) # check cache to see if we can save time @@ -4093,7 +4089,7 @@ class GStretch(Operator): # cleaning up if derived: bm_mod.free() - terminate(global_undo) + terminate() return{'FINISHED'} @@ -4157,7 +4153,7 @@ class Relax(Operator): def execute(self, context): # initialise - global_undo, object, bm = initialise() + object, bm = initialise() settings_write(self) # check cache to see if we can save time cached, single_loops, loops, derived, mapping = cache_read("Relax", @@ -4191,7 +4187,7 @@ class Relax(Operator): # cleaning up if derived: bm_mod.free() - terminate(global_undo) + terminate() return{'FINISHED'} @@ -4279,7 +4275,7 @@ class Space(Operator): def execute(self, context): # initialise - global_undo, object, bm = initialise() + object, bm = initialise() settings_write(self) # check cache to see if we can save time cached, single_loops, loops, derived, mapping = cache_read("Space", @@ -4317,7 +4313,7 @@ class Space(Operator): # cleaning up if derived: bm_mod.free() - terminate(global_undo) + terminate() return{'FINISHED'} diff --git a/rigify/legacy/rig_ui_pitchipoy_template.py b/rigify/legacy/rig_ui_pitchipoy_template.py index 2e64b743..2b4ef36c 100644 --- a/rigify/legacy/rig_ui_pitchipoy_template.py +++ b/rigify/legacy/rig_ui_pitchipoy_template.py @@ -541,12 +541,7 @@ class Rigify_Arm_FK2IK(bpy.types.Operator): return (context.active_object != None and context.mode == 'POSE') def execute(self, context): - use_global_undo = context.preferences.edit.use_global_undo - context.preferences.edit.use_global_undo = False - try: - fk2ik_arm(context.active_object, fk=[self.uarm_fk, self.farm_fk, self.hand_fk], ik=[self.uarm_ik, self.farm_ik, self.hand_ik]) - finally: - context.preferences.edit.use_global_undo = use_global_undo + fk2ik_arm(context.active_object, fk=[self.uarm_fk, self.farm_fk, self.hand_fk], ik=[self.uarm_ik, self.farm_ik, self.hand_ik]) return {'FINISHED'} @@ -571,12 +566,7 @@ class Rigify_Arm_IK2FK(bpy.types.Operator): return (context.active_object != None and context.mode == 'POSE') def execute(self, context): - use_global_undo = context.preferences.edit.use_global_undo - context.preferences.edit.use_global_undo = False - try: - ik2fk_arm(context.active_object, fk=[self.uarm_fk, self.farm_fk, self.hand_fk], ik=[self.uarm_ik, self.farm_ik, self.hand_ik, self.pole]) - finally: - context.preferences.edit.use_global_undo = use_global_undo + ik2fk_arm(context.active_object, fk=[self.uarm_fk, self.farm_fk, self.hand_fk], ik=[self.uarm_ik, self.farm_ik, self.hand_ik, self.pole]) return {'FINISHED'} @@ -602,12 +592,7 @@ class Rigify_Leg_FK2IK(bpy.types.Operator): return (context.active_object != None and context.mode == 'POSE') def execute(self, context): - use_global_undo = context.preferences.edit.use_global_undo - context.preferences.edit.use_global_undo = False - try: - fk2ik_leg(context.active_object, fk=[self.thigh_fk, self.shin_fk, self.foot_fk, self.mfoot_fk], ik=[self.thigh_ik, self.shin_ik, self.foot_ik, self.mfoot_ik]) - finally: - context.preferences.edit.use_global_undo = use_global_undo + fk2ik_leg(context.active_object, fk=[self.thigh_fk, self.shin_fk, self.foot_fk, self.mfoot_fk], ik=[self.thigh_ik, self.shin_ik, self.foot_ik, self.mfoot_ik]) return {'FINISHED'} @@ -635,12 +620,7 @@ class Rigify_Leg_IK2FK(bpy.types.Operator): return (context.active_object != None and context.mode == 'POSE') def execute(self, context): - use_global_undo = context.preferences.edit.use_global_undo - context.preferences.edit.use_global_undo = False - try: - ik2fk_leg(context.active_object, fk=[self.thigh_fk, self.shin_fk, self.mfoot_fk, self.foot_fk], ik=[self.thigh_ik, self.shin_ik, self.foot_ik, self.footroll, self.pole, self.mfoot_ik]) - finally: - context.preferences.edit.use_global_undo = use_global_undo + ik2fk_leg(context.active_object, fk=[self.thigh_fk, self.shin_fk, self.mfoot_fk, self.foot_fk], ik=[self.thigh_ik, self.shin_ik, self.foot_ik, self.footroll, self.pole, self.mfoot_ik]) return {'FINISHED'} diff --git a/rigify/legacy/rig_ui_template.py b/rigify/legacy/rig_ui_template.py index 5f384006..6cdd1c63 100644 --- a/rigify/legacy/rig_ui_template.py +++ b/rigify/legacy/rig_ui_template.py @@ -389,12 +389,7 @@ class Rigify_Arm_FK2IK(bpy.types.Operator): return (context.active_object is not None and context.mode == 'POSE') def execute(self, context): - use_global_undo = context.preferences.edit.use_global_undo - context.preferences.edit.use_global_undo = False - try: - fk2ik_arm(context.active_object, fk=[self.uarm_fk, self.farm_fk, self.hand_fk], ik=[self.uarm_ik, self.farm_ik, self.hand_ik]) - finally: - context.preferences.edit.use_global_undo = use_global_undo + fk2ik_arm(context.active_object, fk=[self.uarm_fk, self.farm_fk, self.hand_fk], ik=[self.uarm_ik, self.farm_ik, self.hand_ik]) return {'FINISHED'} @@ -419,12 +414,7 @@ class Rigify_Arm_IK2FK(bpy.types.Operator): return (context.active_object is not None and context.mode == 'POSE') def execute(self, context): - use_global_undo = context.preferences.edit.use_global_undo - context.preferences.edit.use_global_undo = False - try: - ik2fk_arm(context.active_object, fk=[self.uarm_fk, self.farm_fk, self.hand_fk], ik=[self.uarm_ik, self.farm_ik, self.hand_ik, self.pole]) - finally: - context.preferences.edit.use_global_undo = use_global_undo + ik2fk_arm(context.active_object, fk=[self.uarm_fk, self.farm_fk, self.hand_fk], ik=[self.uarm_ik, self.farm_ik, self.hand_ik, self.pole]) return {'FINISHED'} @@ -450,12 +440,7 @@ class Rigify_Leg_FK2IK(bpy.types.Operator): return (context.active_object is not None and context.mode == 'POSE') def execute(self, context): - use_global_undo = context.preferences.edit.use_global_undo - context.preferences.edit.use_global_undo = False - try: - fk2ik_leg(context.active_object, fk=[self.thigh_fk, self.shin_fk, self.foot_fk, self.mfoot_fk], ik=[self.thigh_ik, self.shin_ik, self.foot_ik, self.mfoot_ik]) - finally: - context.preferences.edit.use_global_undo = use_global_undo + fk2ik_leg(context.active_object, fk=[self.thigh_fk, self.shin_fk, self.foot_fk, self.mfoot_fk], ik=[self.thigh_ik, self.shin_ik, self.foot_ik, self.mfoot_ik]) return {'FINISHED'} @@ -482,12 +467,7 @@ class Rigify_Leg_IK2FK(bpy.types.Operator): return (context.active_object is not None and context.mode == 'POSE') def execute(self, context): - use_global_undo = context.preferences.edit.use_global_undo - context.preferences.edit.use_global_undo = False - try: - ik2fk_leg(context.active_object, fk=[self.thigh_fk, self.shin_fk, self.mfoot_fk], ik=[self.thigh_ik, self.shin_ik, self.foot_ik, self.footroll, self.pole, self.mfoot_ik]) - finally: - context.preferences.edit.use_global_undo = use_global_undo + ik2fk_leg(context.active_object, fk=[self.thigh_fk, self.shin_fk, self.mfoot_fk], ik=[self.thigh_ik, self.shin_ik, self.foot_ik, self.footroll, self.pole, self.mfoot_ik]) return {'FINISHED'} diff --git a/rigify/legacy/ui.py b/rigify/legacy/ui.py index 157b451c..1cc0c0eb 100644 --- a/rigify/legacy/ui.py +++ b/rigify/legacy/ui.py @@ -284,14 +284,10 @@ class Generate(bpy.types.Operator): import importlib importlib.reload(generate) - use_global_undo = context.preferences.edit.use_global_undo - context.preferences.edit.use_global_undo = False try: generate.generate_rig(context, context.object) except MetarigError as rig_exception: rigify_report_exception(self, rig_exception) - finally: - context.preferences.edit.use_global_undo = use_global_undo return {'FINISHED'} @@ -312,8 +308,6 @@ class Sample(bpy.types.Operator): def execute(self, context): if context.mode == 'EDIT_ARMATURE' and self.metarig_type != "": - use_global_undo = context.preferences.edit.use_global_undo - context.preferences.edit.use_global_undo = False try: rig = get_rig_type(self.metarig_type) create_sample = rig.create_sample @@ -322,7 +316,6 @@ class Sample(bpy.types.Operator): else: create_sample(context.active_object) finally: - context.preferences.edit.use_global_undo = use_global_undo bpy.ops.object.mode_set(mode='EDIT') return {'FINISHED'} diff --git a/rigify/rig_ui_template.py b/rigify/rig_ui_template.py index 6cd46f6a..cebed827 100644 --- a/rigify/rig_ui_template.py +++ b/rigify/rig_ui_template.py @@ -638,12 +638,7 @@ class Rigify_Arm_FK2IK(bpy.types.Operator): return (context.active_object != None and context.mode == 'POSE') def execute(self, context): - use_global_undo = context.preferences.edit.use_global_undo - context.preferences.edit.use_global_undo = False - try: - fk2ik_arm(context.active_object, fk=[self.uarm_fk, self.farm_fk, self.hand_fk], ik=[self.uarm_ik, self.farm_ik, self.hand_ik]) - finally: - context.preferences.edit.use_global_undo = use_global_undo + fk2ik_arm(context.active_object, fk=[self.uarm_fk, self.farm_fk, self.hand_fk], ik=[self.uarm_ik, self.farm_ik, self.hand_ik]) return {'FINISHED'} @@ -670,12 +665,7 @@ class Rigify_Arm_IK2FK(bpy.types.Operator): return (context.active_object != None and context.mode == 'POSE') def execute(self, context): - use_global_undo = context.preferences.edit.use_global_undo - context.preferences.edit.use_global_undo = False - try: - ik2fk_arm(context.active_object, fk=[self.uarm_fk, self.farm_fk, self.hand_fk], ik=[self.uarm_ik, self.farm_ik, self.hand_ik, self.pole, self.main_parent]) - finally: - context.preferences.edit.use_global_undo = use_global_undo + ik2fk_arm(context.active_object, fk=[self.uarm_fk, self.farm_fk, self.hand_fk], ik=[self.uarm_ik, self.farm_ik, self.hand_ik, self.pole, self.main_parent]) return {'FINISHED'} '''] @@ -708,12 +698,7 @@ class Rigify_Leg_FK2IK(bpy.types.Operator): return (context.active_object != None and context.mode == 'POSE') def execute(self, context): - use_global_undo = context.preferences.edit.use_global_undo - context.preferences.edit.use_global_undo = False - try: - fk2ik_leg(context.active_object, fk=[self.thigh_fk, self.shin_fk, self.foot_fk, self.mfoot_fk], ik=[self.thigh_ik, self.shin_ik, self.foot_ik, self.mfoot_ik]) - finally: - context.preferences.edit.use_global_undo = use_global_undo + fk2ik_leg(context.active_object, fk=[self.thigh_fk, self.shin_fk, self.foot_fk, self.mfoot_fk], ik=[self.thigh_ik, self.shin_ik, self.foot_ik, self.mfoot_ik]) return {'FINISHED'} @@ -742,12 +727,7 @@ class Rigify_Leg_IK2FK(bpy.types.Operator): return (context.active_object != None and context.mode == 'POSE') def execute(self, context): - use_global_undo = context.preferences.edit.use_global_undo - context.preferences.edit.use_global_undo = False - try: - ik2fk_leg(context.active_object, fk=[self.thigh_fk, self.shin_fk, self.mfoot_fk, self.foot_fk], ik=[self.thigh_ik, self.shin_ik, self.foot_ik, self.footroll, self.pole, self.mfoot_ik, self.main_parent]) - finally: - context.preferences.edit.use_global_undo = use_global_undo + ik2fk_leg(context.active_object, fk=[self.thigh_fk, self.shin_fk, self.mfoot_fk, self.foot_fk], ik=[self.thigh_ik, self.shin_ik, self.foot_ik, self.footroll, self.pole, self.mfoot_ik, self.main_parent]) return {'FINISHED'} '''] diff --git a/rigify/ui.py b/rigify/ui.py index c3c9f07d..0ec38791 100644 --- a/rigify/ui.py +++ b/rigify/ui.py @@ -755,14 +755,10 @@ class Generate(bpy.types.Operator): import importlib importlib.reload(generate) - use_global_undo = context.preferences.edit.use_global_undo - context.preferences.edit.use_global_undo = False try: generate.generate_rig(context, context.object) except MetarigError as rig_exception: rigify_report_exception(self, rig_exception) - finally: - context.preferences.edit.use_global_undo = use_global_undo return {'FINISHED'} @@ -813,8 +809,6 @@ class Sample(bpy.types.Operator): def execute(self, context): if context.mode == 'EDIT_ARMATURE' and self.metarig_type != "": - use_global_undo = context.preferences.edit.use_global_undo - context.preferences.edit.use_global_undo = False try: rig = rig_lists.rigs[self.metarig_type]["module"] create_sample = rig.create_sample @@ -823,7 +817,6 @@ class Sample(bpy.types.Operator): else: create_sample(context.active_object) finally: - context.preferences.edit.use_global_undo = use_global_undo bpy.ops.object.mode_set(mode='EDIT') return {'FINISHED'} @@ -1280,8 +1273,6 @@ class OBJECT_OT_ClearAnimation(bpy.types.Operator): def execute(self, context): - use_global_undo = context.preferences.edit.use_global_undo - context.preferences.edit.use_global_undo = False try: rig = context.object scn = context.scene @@ -1292,8 +1283,6 @@ class OBJECT_OT_ClearAnimation(bpy.types.Operator): return {'FINISHED'} clearAnimation(act, self.anim_type, names=get_limb_generated_names(rig)) - finally: - context.preferences.edit.use_global_undo = use_global_undo return {'FINISHED'} |