[Bf-extensions-cvs] [25f1c2b0] master: Add-ons: remove temporary disabling of use_global_undo

Brecht Van Lommel noreply at git.blender.org
Wed May 22 11:30:38 CEST 2019


Commit: 25f1c2b04e0d98587c88c5ea26b59650e5c2e3f7
Author: Brecht Van Lommel
Date:   Tue May 21 11:07:17 2019 +0200
Branches: master
https://developer.blender.org/rBA25f1c2b04e0d98587c88c5ea26b59650e5c2e3f7

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

===================================================================

M	add_curve_extra_objects/add_curve_aceous_galore.py
M	add_curve_extra_objects/add_curve_spirofit_bouncespline.py
M	add_curve_extra_objects/add_curve_torus_knots.py
M	add_mesh_extra_objects/add_mesh_solid.py
M	ant_landscape/add_mesh_ant_landscape.py
M	ant_landscape/ant_functions.py
M	ant_landscape/mesh_ant_displace.py
M	curve_simplify.py
M	io_scene_ms3d/ms3d_export.py
M	io_scene_ms3d/ms3d_utils.py
M	mesh_bsurfaces.py
M	mesh_looptools.py
M	rigify/legacy/rig_ui_pitchipoy_template.py
M	rigify/legacy/rig_ui_template.py
M	rigify/legacy/ui.py
M	rigify/rig_ui_template.py
M	rigify/ui.py

===================================================================

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_

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list