diff options
author | Bastien Montagne <bastien@blender.org> | 2021-02-05 00:03:39 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-02-05 00:03:39 +0300 |
commit | 94cf74afbb1329a9ff099e2ebd7f43ed8313f9ec (patch) | |
tree | 6859715425521345f93993ecdcf7182b060ac236 /source/blender/blenloader/intern/readfile.c | |
parent | 7d5640ee101e6b9ddbd9f534539ae939f68bfd9b (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/blenloader/intern/readfile.c')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 2192e9a378f..a63d95c1823 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -94,6 +94,7 @@ #include "BKE_report.h" #include "BKE_scene.h" #include "BKE_screen.h" +#include "BKE_undo_system.h" #include "BKE_workspace.h" #include "DRW_engine.h" @@ -1294,12 +1295,12 @@ static ssize_t fd_read_from_memfile(FileData *filedata, seek += readsize; if (r_is_memchunck_identical != NULL) { /* `is_identical` of current chunk represents whether it changed compared to previous undo - * step. this is fine in redo case (filedata->undo_direction > 0), but not in undo case, - * where we need an extra flag defined when saving the next (future) step after the one we - * want to restore, as we are supposed to 'come from' that future undo step, and not the - * one before current one. */ - *r_is_memchunck_identical &= filedata->undo_direction > 0 ? chunk->is_identical : - chunk->is_identical_future; + * step. this is fine in redo case, but not in undo case, where we need an extra flag + * defined when saving the next (future) step after the one we want to restore, as we are + * supposed to 'come from' that future undo step, and not the one before current one. */ + *r_is_memchunck_identical &= filedata->undo_direction == STEP_REDO ? + chunk->is_identical : + chunk->is_identical_future; } } while (totread < size); @@ -2400,11 +2401,12 @@ static int direct_link_id_restore_recalc(const FileData *fd, /* Tags that were set between the target state and the current state, * that we need to perform again. */ - if (fd->undo_direction < 0) { + if (fd->undo_direction == STEP_UNDO) { /* Undo: tags from target to the current state. */ recalc |= id_current->recalc_up_to_undo_push; } else { + BLI_assert(fd->undo_direction == STEP_REDO); /* Redo: tags from current to the target state. */ recalc |= id_target->recalc_up_to_undo_push; } |