diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-07-23 05:54:40 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-07-23 06:06:26 +0300 |
commit | 0a0e2dd8a2ce002b76d834c621766e8da3f1b678 (patch) | |
tree | 15fd2228f96628ea6ee6f808cc6a7bf0c58ce6b2 /source/blender/blenkernel/intern/undo_system.c | |
parent | 8c618371507fc95d51671d2f807e864adf1f4791 (diff) |
Fix T67040: Undo crashes after renaming
Correct fix that doesn't cause T67217.
Temporarily removing the excluded undo step broke memfile-undo
since freeing the undo steps needs to access other steps in
the list to merge shared chunks, see: memfile_undosys_step_free.
Pass the exclude step as an argument instead.
Diffstat (limited to 'source/blender/blenkernel/intern/undo_system.c')
-rw-r--r-- | source/blender/blenkernel/intern/undo_system.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c index d312dc0190b..8ea5b47de5f 100644 --- a/source/blender/blenkernel/intern/undo_system.c +++ b/source/blender/blenkernel/intern/undo_system.c @@ -311,13 +311,20 @@ static void undosys_stack_clear_all_last(UndoStack *ustack, UndoStep *us) } } -static void undosys_stack_clear_all_first(UndoStack *ustack, UndoStep *us) +static void undosys_stack_clear_all_first(UndoStack *ustack, UndoStep *us, UndoStep *us_exclude) { + if (us && us == us_exclude) { + us = us->prev; + } + if (us) { bool is_not_empty = true; UndoStep *us_iter; do { us_iter = ustack->steps.first; + if (us_iter == us_exclude) { + us_iter = us_iter->next; + } BLI_assert(us_iter != ustack->step_active); undosys_step_free_and_unlink(ustack, us_iter); undosys_stack_validate(ustack, is_not_empty); @@ -395,9 +402,7 @@ void BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size CLOG_INFO(&LOG, 1, "steps=%d, memory_limit=%zu", steps, memory_limit); UndoStep *us; -#ifdef WITH_GLOBAL_UNDO_KEEP_ONE UndoStep *us_exclude = NULL; -#endif /* keep at least two (original + other) */ size_t data_size_all = 0; size_t us_count = 0; @@ -427,23 +432,14 @@ void BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size /* Hack, we need to keep at least one BKE_UNDOSYS_TYPE_MEMFILE. */ if (us->type != BKE_UNDOSYS_TYPE_MEMFILE) { us_exclude = us->prev; - while (us_exclude && us->type != BKE_UNDOSYS_TYPE_MEMFILE) { + while (us_exclude && us_exclude->type != BKE_UNDOSYS_TYPE_MEMFILE) { us_exclude = us_exclude->prev; } - if (us_exclude) { - BLI_remlink(&ustack->steps, us_exclude); - } } #endif /* Free from first to last, free functions may update de-duplication info * (see #MemFileUndoStep). */ - undosys_stack_clear_all_first(ustack, us->prev); - -#ifdef WITH_GLOBAL_UNDO_KEEP_ONE - if (us_exclude) { - BLI_addhead(&ustack->steps, us_exclude); - } -#endif + undosys_stack_clear_all_first(ustack, us->prev, us_exclude); } } |