Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-02-07 12:27:11 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-02-07 12:28:33 +0300
commit937731dff1af4910dc94646904106432c14b2042 (patch)
treed2fb05a3b8f774e68df1e94dba2f380cd38d9701 /source/blender/editors/armature/editarmature_undo.c
parent075a1221907f33c8634cc6e38238f6729334c716 (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/armature/editarmature_undo.c')
-rw-r--r--source/blender/editors/armature/editarmature_undo.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/source/blender/editors/armature/editarmature_undo.c b/source/blender/editors/armature/editarmature_undo.c
index f88054f20c8..3e76a66e891 100644
--- a/source/blender/editors/armature/editarmature_undo.c
+++ b/source/blender/editors/armature/editarmature_undo.c
@@ -146,9 +146,11 @@ static bool armature_undosys_step_encode(struct bContext *C, struct Main *UNUSED
{
ArmatureUndoStep *us = (ArmatureUndoStep *)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;
@@ -168,12 +170,13 @@ static bool armature_undosys_step_encode(struct bContext *C, struct Main *UNUSED
static void armature_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(armature_undosys_poll(C));
-
ArmatureUndoStep *us = (ArmatureUndoStep *)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(armature_undosys_poll(C));
+
for (uint i = 0; i < us->elems_len; i++) {
ArmatureUndoStep_Elem *elem = &us->elems[i];
Object *obedit = elem->obedit_ref.ptr;