[Bf-blender-cvs] [9ab4536218d] blender-v2.91-release: Outliner: use undo-group for outliner mode switching

Campbell Barton noreply at git.blender.org
Fri Oct 30 10:53:25 CET 2020


Commit: 9ab4536218d742351095181bb3f93d24491e6380
Author: Campbell Barton
Date:   Fri Oct 30 20:24:18 2020 +1100
Branches: blender-v2.91-release
https://developer.blender.org/rB9ab4536218d742351095181bb3f93d24491e6380

Outliner: use undo-group for outliner mode switching

Switching modes no longer adds multiple undo steps
from a user perspective.

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

M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_outliner/outliner_select.c

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

diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 5a789ee0b01..d961813d04a 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -2013,6 +2013,8 @@ static void outliner_draw_mode_column_toggle(uiBlock *block,
                             tip);
   UI_but_func_set(but, outliner_mode_toggle_fn, tselem, NULL);
   UI_but_flag_enable(but, UI_BUT_DRAG_LOCK);
+  /* Mode toggling handles it's own undo state because undo steps need to be grouped. */
+  UI_but_flag_disable(but, UI_BUT_UNDO);
 
   if (ID_IS_LINKED(&ob->id)) {
     UI_but_disable(but, TIP_("Can't edit external library data"));
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 01aaa3c04e0..c6b5f2e2d2b 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -77,6 +77,8 @@
 
 /**
  * \note changes to selection are by convention and not essential.
+ *
+ * \note Handles own undo push.
  */
 static void do_outliner_item_editmode_toggle(bContext *C, Scene *scene, Base *base)
 {
@@ -102,11 +104,14 @@ static void do_outliner_item_editmode_toggle(bContext *C, Scene *scene, Base *ba
   if (changed) {
     DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
     ED_outliner_select_sync_from_object_tag(C);
+    ED_undo_push(C, "Outliner Edit Mode Toggle");
   }
 }
 
 /**
  * \note changes to selection are by convention and not essential.
+ *
+ * \note Handles own undo push.
  */
 static void do_outliner_item_posemode_toggle(bContext *C, Scene *scene, Base *base)
 {
@@ -137,6 +142,7 @@ static void do_outliner_item_posemode_toggle(bContext *C, Scene *scene, Base *ba
   if (changed) {
     DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
     ED_outliner_select_sync_from_object_tag(C);
+    ED_undo_push(C, "Outliner Pose Mode Toggle");
   }
 }
 
@@ -148,10 +154,13 @@ static void do_outliner_item_posemode_toggle(bContext *C, Scene *scene, Base *ba
  *
  * If we didn't want to touch selection we could add an option to the operators
  * not to do multi-object editing.
+ *
+ * \note Handles own undo push.
  */
 static void do_outliner_item_mode_toggle_generic(bContext *C, TreeViewContext *tvc, Base *base)
 {
   const int active_mode = tvc->obact->mode;
+  ED_undo_group_begin(C);
 
   if (ED_object_mode_set(C, OB_MODE_OBJECT)) {
     Base *base_active = BKE_view_layer_base_find(tvc->view_layer, tvc->obact);
@@ -159,13 +168,14 @@ static void do_outliner_item_mode_toggle_generic(bContext *C, TreeViewContext *t
       BKE_view_layer_base_deselect_all(tvc->view_layer);
       BKE_view_layer_base_select_and_set_active(tvc->view_layer, base);
       DEG_id_tag_update(&tvc->scene->id, ID_RECALC_SELECT);
+      ED_undo_push(C, "Change Active");
 
-      /* XXX: Must add undo step between activation and setting mode to prevent an assert. */
-      ED_undo_push(C, "outliner mode toggle");
+      /* Operator call does undo push. */
       ED_object_mode_set(C, active_mode);
       ED_outliner_select_sync_from_object_tag(C);
     }
   }
+  ED_undo_group_end(C);
 }
 
 /* Toggle the item's interaction mode if supported */



More information about the Bf-blender-cvs mailing list