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:
authorBastien Montagne <bastien@blender.org>2021-02-05 00:03:39 +0300
committerBastien Montagne <bastien@blender.org>2021-02-05 00:03:39 +0300
commit94cf74afbb1329a9ff099e2ebd7f43ed8313f9ec (patch)
tree6859715425521345f93993ecdcf7182b060ac236 /source/blender/editors/undo
parent7d5640ee101e6b9ddbd9f534539ae939f68bfd9b (diff)
Cleanup/refactor: Undosys: Get rid of the magic values for undo direction.
Move `eUndoStepDir` to `BKE_undo_system.h` and use its values everywhere. Note that this also introduce the `STEP_INVALID` value in that enum. Finally, kept the matching struct members in some lower-level readfile code as an `int` to avoid having to include `BKE_undo_system.h` in a lot of unrelated files.
Diffstat (limited to 'source/blender/editors/undo')
-rw-r--r--source/blender/editors/undo/ed_undo.c11
-rw-r--r--source/blender/editors/undo/memfile_undo.c14
2 files changed, 7 insertions, 18 deletions
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index 0771d0254e8..baa178a6a94 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -70,15 +70,6 @@
/** We only need this locally. */
static CLG_LogRef LOG = {"ed.undo"};
-/**
- * \warning Values are used in #ED_undo_gpencil_step,
- * which should eventually be replaced with the undo-system.
- */
-enum eUndoStepDir {
- STEP_REDO = 1,
- STEP_UNDO = -1,
-};
-
/* -------------------------------------------------------------------- */
/** \name Generic Undo System Access
*
@@ -276,7 +267,7 @@ static int ed_undo_step_direction(bContext *C, enum eUndoStepDir step, ReportLis
* 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);
+ return ED_undo_gpencil_step(C, step);
}
wmWindowManager *wm = CTX_wm_manager(C);
diff --git a/source/blender/editors/undo/memfile_undo.c b/source/blender/editors/undo/memfile_undo.c
index eea0f29d295..51859b6a555 100644
--- a/source/blender/editors/undo/memfile_undo.c
+++ b/source/blender/editors/undo/memfile_undo.c
@@ -145,19 +145,18 @@ static int memfile_undosys_step_id_reused_cb(LibraryIDLinkCallbackData *cb_data)
static void memfile_undosys_step_decode(struct bContext *C,
struct Main *bmain,
UndoStep *us_p,
- int undo_direction,
+ const eUndoStepDir undo_direction,
bool UNUSED(is_final))
{
- BLI_assert(undo_direction != 0);
+ BLI_assert(undo_direction != STEP_INVALID);
bool use_old_bmain_data = true;
if (USER_EXPERIMENTAL_TEST(&U, use_undo_legacy)) {
use_old_bmain_data = false;
}
- else if (undo_direction > 0) {
- /* Redo case.
- * The only time we should have to force a complete redo is when current step is tagged as a
+ else if (undo_direction == STEP_REDO) {
+ /* The only time we should have to force a complete redo is when current step is tagged as a
* redo barrier.
* If previous step was not a memfile one should not matter here, current data in old bmain
* should still always be valid for unchanged data-blocks. */
@@ -165,9 +164,8 @@ static void memfile_undosys_step_decode(struct bContext *C,
use_old_bmain_data = false;
}
}
- else {
- /* Undo case.
- * Here we do not care whether current step is an undo barrier, since we are coming from
+ else if (undo_direction == STEP_UNDO) {
+ /* Here we do not care whether current step is an undo barrier, since we are coming from
* 'the future' we can still re-use old data. However, if *next* undo step
* (i.e. the one immediately in the future, the one we are coming from)
* is a barrier, then we have to force a complete undo.