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

This commit is contained in:
Campbell Barton
2019-01-15 21:33:01 +11:00
parent e375685e06
commit 0b9a65151d
6 changed files with 9 additions and 24 deletions

View File

@@ -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)

View File

@@ -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);

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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)

View File

@@ -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();