Commit: 0b9a65151d9fc0c7e4ec273da7e4bcc3b09a6d18
Author: Campbell Barton
Date:   Tue Jan 15 21:33:01 2019 +1100
Branches: master
https://developer.blender.org/rB0b9a65151d9fc0c7e4ec273da7e4bcc3b09a6d18

Fix T60410: Crash adjusting torus w/ enter edit-mode preference

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

M       release/scripts/modules/bpy_extras/object_utils.py
M       source/blender/editors/include/ED_util.h
M       source/blender/editors/undo/memfile_undo.c
M       source/blender/editors/util/ed_util.c
M       source/blender/windowmanager/intern/wm_files.c
M       source/blender/windowmanager/intern/wm_init_exit.c

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

diff --git a/release/scripts/modules/bpy_extras/object_utils.py 
b/release/scripts/modules/bpy_extras/object_utils.py
index 5e8f497d1a0..df6feff4591 100644
--- a/release/scripts/modules/bpy_extras/object_utils.py
+++ b/release/scripts/modules/bpy_extras/object_utils.py
@@ -133,23 +133,6 @@ def object_data_add(context, obdata, operator=None, 
name=None):
     obj_new.select_set(True)
     obj_new.matrix_world = add_object_align_init(context, operator)
 
-    # XXX
-    # caused because entering edit-mode does not add a empty undo slot!
-    if context.preferences.edit.use_enter_edit_mode:
-        if not (obj_act and
-                obj_act.mode == 'EDIT' and
-                obj_act.type == obj_new.type):
-
-            _obdata = bpy.data.meshes.new(name)
-            obj_act = bpy.data.objects.new(_obdata.name, _obdata)
-            obj_act.matrix_world = obj_new.matrix_world
-            scene_collection.objects.link(obj_act)
-            layer.objects.active = obj_act
-            bpy.ops.object.mode_set(mode='EDIT')
-            # need empty undo step
-            bpy.ops.ed.undo_push(message="Enter Editmode")
-    # XXX
-
     if obj_act and obj_act.mode == 'EDIT' and obj_act.type == obj_new.type:
         bpy.ops.mesh.select_all(action='DESELECT')
         obj_act.select_set(True)
diff --git a/source/blender/editors/include/ED_util.h 
b/source/blender/editors/include/ED_util.h
index 05131d103fc..e4d70a99e98 100644
--- a/source/blender/editors/include/ED_util.h
+++ b/source/blender/editors/include/ED_util.h
@@ -39,7 +39,7 @@ struct Main;
 
 /* ed_util.c */
 void ED_editors_init(struct bContext *C);
-void ED_editors_exit(struct Main *bmain);
+void ED_editors_exit(struct Main *bmain, bool do_undo_system);
 bool ED_editors_flush_edits(struct Main *bmain, bool for_render);
 
 void ED_spacedata_id_remap(struct ScrArea *sa, struct SpaceLink *sl, struct ID 
*old_id, struct ID *new_id);
diff --git a/source/blender/editors/undo/memfile_undo.c 
b/source/blender/editors/undo/memfile_undo.c
index 2470acef9aa..1560c414c42 100644
--- a/source/blender/editors/undo/memfile_undo.c
+++ b/source/blender/editors/undo/memfile_undo.c
@@ -38,8 +38,7 @@
 
 #include "ED_object.h"
 #include "ED_undo.h"
-#include "ED_render.h"
-
+#include "ED_util.h"
 
 #include "../blenloader/BLO_undofile.h"
 
@@ -82,6 +81,9 @@ static bool memfile_undosys_step_encode(struct bContext *C, 
UndoStep *us_p)
 
 static void memfile_undosys_step_decode(struct bContext *C, UndoStep *us_p, 
int UNUSED(dir))
 {
+       struct Main *bmain = CTX_data_main(C);
+       ED_editors_exit(bmain, false);
+
        MemFileUndoStep *us = (MemFileUndoStep *)us_p;
        BKE_memfile_undo_decode(us->data, C);
 
diff --git a/source/blender/editors/util/ed_util.c 
b/source/blender/editors/util/ed_util.c
index 30021d6a0c9..720b8357a12 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -157,14 +157,14 @@ void ED_editors_init(bContext *C)
 }
 
 /* frees all editmode stuff */
-void ED_editors_exit(Main *bmain)
+void ED_editors_exit(Main *bmain, bool do_undo_system)
 {
        if (!bmain) {
                return;
        }
 
        /* frees all editmode undos */
-       if (G_MAIN->wm.first) {
+       if (do_undo_system && G_MAIN->wm.first) {
                wmWindowManager *wm = G_MAIN->wm.first;
                /* normally we don't check for NULL undo stack, do here since 
it may run in different context. */
                if (wm->undo_stack) {
diff --git a/source/blender/windowmanager/intern/wm_files.c 
b/source/blender/windowmanager/intern/wm_files.c
index 379bd56a9c2..120bf65efa1 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -184,7 +184,7 @@ static void wm_window_match_init(bContext *C, ListBase 
*wmlist)
         *     (see T47632), so for now just handling this specific case here. 
*/
        CTX_wm_menu_set(C, NULL);
 
-       ED_editors_exit(G_MAIN);
+       ED_editors_exit(G_MAIN, true);
 }
 
 static void wm_window_substitute_old(wmWindowManager *oldwm, wmWindowManager 
*wm, wmWindow *oldwin, wmWindow *win)
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c 
b/source/blender/windowmanager/intern/wm_init_exit.c
index e3587c2c965..2a99d06e9f9 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -483,7 +483,7 @@ void WM_exit_ext(bContext *C, const bool do_python)
        /* all non-screen and non-space stuff editors did, like editmode */
        if (C) {
                Main *bmain = CTX_data_main(C);
-               ED_editors_exit(bmain);
+               ED_editors_exit(bmain, true);
        }
 
        ED_undosys_type_free();

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to