[Bf-extensions-cvs] [39780841] master: Add-ons: remove temporary disabling of use_global_undo
Brecht Van Lommel
noreply at git.blender.org
Wed May 22 11:33:13 CEST 2019
Commit: 39780841434444cbc9af51b34270713a09f937d9
Author: Brecht Van Lommel
Date: Wed May 22 11:31:03 2019 +0200
Branches: master
https://developer.blender.org/rBAC39780841434444cbc9af51b34270713a09f937d9
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_advanced_objects_menu/make_struts.py
M add_dimension.py
===================================================================
diff --git a/add_advanced_objects_menu/make_struts.py b/add_advanced_objects_menu/make_struts.py
index 547fb2f5..f9eda055 100644
--- a/add_advanced_objects_menu/make_struts.py
+++ b/add_advanced_objects_menu/make_struts.py
@@ -562,18 +562,14 @@ class Struts(Operator):
return obj is not None and obj.type == "MESH"
def execute(self, context):
- store_undo = bpy.context.preferences.edit.use_global_undo
- bpy.context.preferences.edit.use_global_undo = False
keywords = self.as_keywords()
try:
create_struts(self, context, **keywords)
- bpy.context.preferences.edit.use_global_undo = store_undo
return {"FINISHED"}
except Exception as e:
- bpy.context.preferences.edit.use_global_undo = store_undo
self.report({"WARNING"},
"Make Struts could not be performed. Operation Cancelled")
print("\n[mesh.generate_struts]\n{}".format(e))
diff --git a/add_dimension.py b/add_dimension.py
index b716584f..e459a70e 100644
--- a/add_dimension.py
+++ b/add_dimension.py
@@ -2655,17 +2655,10 @@ class Dimension(bpy.types.Operator):
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.context.view_layer.update()
- # turn off undo
- undo = bpy.context.preferences.edit.use_global_undo
- bpy.context.preferences.edit.use_global_undo = False
-
# main function
self.align_matrix = align_matrix(context, self.Dimension_startlocation)
main(self, self.align_matrix)
- # restore pre operator undo state
- bpy.context.preferences.edit.use_global_undo = undo
-
return {'FINISHED'}
##### INVOKE #####
More information about the Bf-extensions-cvs
mailing list