From f4e4c11433416d2ee44a2f471af866d0f14a155b Mon Sep 17 00:00:00 2001
From: Bastien Montagne <montagne29@wanadoo.fr>
Date: Fri, 23 Jan 2015 14:42:43 +0100
Subject: [PATCH] Fix T43387: BSurfaces error disables global undo

Real ugly stupid error... :/
---
 mesh_bsurfaces.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/mesh_bsurfaces.py b/mesh_bsurfaces.py
index c0cb91e5d..4c572800f 100644
--- a/mesh_bsurfaces.py
+++ b/mesh_bsurfaces.py
@@ -2861,6 +2861,8 @@ class GPENCIL_OT_SURFSK_add_surface(bpy.types.Operator):
 
 
     def execute(self, context):
+        self.initial_global_undo_state = bpy.context.user_preferences.edit.use_global_undo
+
         bpy.context.user_preferences.edit.use_global_undo = False
 
         if not self.is_fill_faces:
@@ -2935,7 +2937,7 @@ class GPENCIL_OT_SURFSK_add_surface(bpy.types.Operator):
             bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
 
 
-            bpy.context.user_preferences.edit.use_global_undo = self.initial_global_undo_state
+        bpy.context.user_preferences.edit.use_global_undo = self.initial_global_undo_state
 
         return{'FINISHED'}
 
@@ -3200,6 +3202,8 @@ class GPENCIL_OT_SURFSK_add_surface(bpy.types.Operator):
 
             bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
 
+            bpy.context.user_preferences.edit.use_global_undo = self.initial_global_undo_state
+
             if created_faces_count == 0:
                 self.report({'WARNING'}, "There aren't any strokes.")
                 return {"CANCELLED"}
@@ -3207,9 +3211,9 @@ class GPENCIL_OT_SURFSK_add_surface(bpy.types.Operator):
                 return {"FINISHED"}
 
 
+        bpy.context.user_preferences.edit.use_global_undo = self.initial_global_undo_state
 
-
-        elif self.strokes_type == "EXTERNAL_NO_CURVE":
+        if self.strokes_type == "EXTERNAL_NO_CURVE":
             self.report({'WARNING'}, "The secondary object is not a Curve.")
             return{"CANCELLED"}
 
-- 
GitLab