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.
This commit is contained in:
parent
8cdd701b45
commit
a0029a678f
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue