Page MenuHome

ed_undo refactor: split/remove `ed_undo_step_impl`.
ClosedPublic

Authored by Bastien Montagne (mont29) on Jan 14 2021, 4:25 PM.

Details

Summary

This function was doing too many things, with behaviors fairly different
depending on its input parameters. This was making the code fragile and
hard to follow.

Split it in three:

  • ed_undo_step_pre does the common actions before we actually undo data.
  • ed_undo_step_post does the common actions after we have undone/redone data.

Then, ed_undo_step_direction, ed_undo_step_by_name and
ed_undo_step_by_index do their actual specific actions, with their own
logic.

Note: Since the actual behavior of those three funtions is fairly
different (the first only undo/redo one effective step, the second is only
supposed to undo before given named step, and the third actually
undo/redo until given indexed step become active), we could also find
better names for those. right now, it sounds like they are doing the
same thing, with just different ways to specify the target step.

Note: This is part of on-going refactor work on undo system, see T83806.

Diff Detail

Repository
rB Blender

Event Timeline

Bastien Montagne (mont29) requested review of this revision.Jan 14 2021, 4:25 PM
Bastien Montagne (mont29) created this revision.

@Campbell Barton (campbellbarton) am gonna commit this if you don't want to review it... I know you said on chat that you were not happy with that split, but for me it makes much more sense than previous code already, and is mandatory step towards fixing sculpt undo issue. So I'd rather not see this delayed forever, having to dive back into that code and wrap my head around it every other week because I have to wait for reviews in-between is not really helpful.

While I don't especially like splitting the functions, alternatives could still be investigated after this commit.

If the refactor helps with other changes, +1.

This revision is now accepted and ready to land.Jan 25 2021, 3:55 PM

While I don't especially like splitting the functions, alternatives could still be investigated after this commit.

Indeed!

If the refactor helps with other changes, +1.

Thanks.