diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-02-07 12:27:11 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-02-07 12:28:33 +0300 |
commit | 937731dff1af4910dc94646904106432c14b2042 (patch) | |
tree | d2fb05a3b8f774e68df1e94dba2f380cd38d9701 /source/blender/editors/metaball/editmball_undo.c | |
parent | 075a1221907f33c8634cc6e38238f6729334c716 (diff) |
Fix T61272: Undo fails to track multi-edit mode enter/exit
Objects leaving edit-mode weren't restored by edit-mode undo steps.
Diffstat (limited to 'source/blender/editors/metaball/editmball_undo.c')
-rw-r--r-- | source/blender/editors/metaball/editmball_undo.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/source/blender/editors/metaball/editmball_undo.c b/source/blender/editors/metaball/editmball_undo.c index c526edd7bd2..160b43b7065 100644 --- a/source/blender/editors/metaball/editmball_undo.c +++ b/source/blender/editors/metaball/editmball_undo.c @@ -156,9 +156,11 @@ static bool mball_undosys_step_encode(struct bContext *C, struct Main *UNUSED(bm { MBallUndoStep *us = (MBallUndoStep *)us_p; + /* Important not to use the 3D view when getting objects because all objects + * outside of this list will be moved out of edit-mode when reading back undo steps. */ ViewLayer *view_layer = CTX_data_view_layer(C); uint objects_len = 0; - Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len); + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, NULL, &objects_len); us->elems = MEM_callocN(sizeof(*us->elems) * objects_len, __func__); us->elems_len = objects_len; @@ -178,12 +180,13 @@ static bool mball_undosys_step_encode(struct bContext *C, struct Main *UNUSED(bm static void mball_undosys_step_decode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p, int UNUSED(dir)) { - /* TODO(campbell): undo_system: use low-level API to set mode. */ - ED_object_mode_set(C, OB_MODE_EDIT); - BLI_assert(mball_undosys_poll(C)); - MBallUndoStep *us = (MBallUndoStep *)us_p; + /* Load all our objects into edit-mode, clear everything else. */ + ED_undo_object_editmode_restore_helper(C, &us->elems[0].obedit_ref.ptr, us->elems_len, sizeof(*us->elems)); + + BLI_assert(mball_undosys_poll(C)); + for (uint i = 0; i < us->elems_len; i++) { MBallUndoStep_Elem *elem = &us->elems[i]; Object *obedit = elem->obedit_ref.ptr; |