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:
authorCampbell Barton <ideasman42@gmail.com>2019-07-23 05:54:40 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-07-24 17:17:53 +0300
commit33acb752b350681ee928abcebca3d91e37ea0ab3 (patch)
treee044897ea20c37bfb2e4cf5a0613768e85f712d3
parent66b7fea5769db2c0842d56e55c2d8482e60d399c (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.
-rw-r--r--source/blender/blenkernel/intern/undo_system.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c
index 2d0a482d223..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;
@@ -430,20 +435,11 @@ void BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size
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);
}
}