[Bf-blender-cvs] [a0029a678f5] master: Cleanup/refactor: Remove logically broken code from GPencil undo.

Bastien Montagne noreply at git.blender.org
Thu Jan 14 12:02:56 CET 2021


Commit: a0029a678f55798d31261070b69d10b2a7395e99
Author: Bastien Montagne
Date:   Thu Jan 14 11:34:00 2021 +0100
Branches: master
https://developer.blender.org/rBa0029a678f55798d31261070b69d10b2a7395e99

Cleanup/refactor: Remove logically broken code from GPencil undo.

`ED_undo_gpencil_step` only support valid undo step direction, passing
step name here is useless and only add confusion to what works or not.

Undo by step name or step index is fully not supported by GPencil undo
mode currently.

Note that since GPencil undo mode does not seem to ever be used anyway,
this is not an urgent issue in practice, but this needs to be cleaned up
at some point. See also T84703.

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

M	source/blender/editors/gpencil/gpencil_undo.c
M	source/blender/editors/include/ED_gpencil.h
M	source/blender/editors/undo/ed_undo.c

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

diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c
index 10d15c8afbc..d9bc77c8715 100644
--- a/source/blender/editors/gpencil/gpencil_undo.c
+++ b/source/blender/editors/gpencil/gpencil_undo.c
@@ -61,28 +61,22 @@ int ED_gpencil_session_active(void)
   return (BLI_listbase_is_empty(&undo_nodes) == false);
 }
 
-int ED_undo_gpencil_step(bContext *C, int step, const char *name)
+int ED_undo_gpencil_step(bContext *C, const int step)
 {
   bGPdata **gpd_ptr = NULL, *new_gpd = NULL;
 
   gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
 
   if (step == -1) { /* undo */
-    // printf("\t\tGP - undo step\n");
     if (cur_node->prev) {
-      if (!name || STREQ(cur_node->name, name)) {
-        cur_node = cur_node->prev;
-        new_gpd = cur_node->gpd;
-      }
+      cur_node = cur_node->prev;
+      new_gpd = cur_node->gpd;
     }
   }
   else if (step == 1) {
-    // printf("\t\tGP - redo step\n");
     if (cur_node->next) {
-      if (!name || STREQ(cur_node->name, name)) {
-        cur_node = cur_node->next;
-        new_gpd = cur_node->gpd;
-      }
+      cur_node = cur_node->next;
+      new_gpd = cur_node->gpd;
     }
   }
 
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index 1b7caf27ecf..19cec4c0f62 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -213,7 +213,7 @@ bool ED_gpencil_anim_copybuf_paste(struct bAnimContext *ac, const short copy_mod
 
 /* ------------ Grease-Pencil Undo System ------------------ */
 int ED_gpencil_session_active(void);
-int ED_undo_gpencil_step(struct bContext *C, int step, const char *name);
+int ED_undo_gpencil_step(struct bContext *C, const int step);
 
 /* ------------ Grease-Pencil Armature ------------------ */
 bool ED_gpencil_add_armature(const struct bContext *C,
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index d15f6d33acd..d29e9779130 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -77,7 +77,7 @@ static CLG_LogRef LOG = {"ed.undo"};
 enum eUndoStepDir {
   STEP_REDO = 1,
   STEP_UNDO = -1,
-  /** Only used when the undo name is passed to #ed_undo_step_impl. */
+  /** Only used when the undo step name or index is passed to #ed_undo_step_impl. */
   STEP_NONE = 0,
 };
 
@@ -207,8 +207,12 @@ static int ed_undo_step_impl(
 
   /* TODO(campbell): undo_system: use undo system */
   /* grease pencil can be can be used in plenty of spaces, so check it first */
+  /* FIXME: This gpencil undo effectively only supports the one step undo/redo, undo based on name
+   * or index is fully not implemented.
+   * FIXME: However, it seems to never be used in current code (`ED_gpencil_session_active` seems
+   * to always return false). */
   if (ED_gpencil_session_active()) {
-    return ED_undo_gpencil_step(C, (int)step, undoname);
+    return ED_undo_gpencil_step(C, (int)step);
   }
   if (area && (area->spacetype == SPACE_VIEW3D)) {
     Object *obact = CTX_data_active_object(C);



More information about the Bf-blender-cvs mailing list