[Bf-blender-cvs] [0a0e2dd8a2c] master: Fix T67040: Undo crashes after renaming
Campbell Barton
noreply at git.blender.org
Tue Jul 23 05:17:32 CEST 2019
Commit: 0a0e2dd8a2ce002b76d834c621766e8da3f1b678
Author: Campbell Barton
Date: Tue Jul 23 12:54:40 2019 +1000
Branches: master
https://developer.blender.org/rB0a0e2dd8a2ce002b76d834c621766e8da3f1b678
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.
===================================================================
M source/blender/blenkernel/intern/undo_system.c
===================================================================
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);
}
}
More information about the Bf-blender-cvs
mailing list