diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2013-09-17 16:11:00 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2013-09-17 16:11:00 +0400 |
commit | 40b5b665273eb84771f41dd4a60db98e2cb845f5 (patch) | |
tree | 6c44de0bb95878baca0599176b2a247f7e5e2b06 /source/blender/editors/sculpt_paint/paint_undo.c | |
parent | b35f1eaa841f561be37609de0435bc38db4db33b (diff) |
Fix #36748 Sculpting/image painting does not respect undo steps limit.
A simple oversight here, it should work as intended now.
Nice to have it functional for people who might hate dyntopo undo with a
passion.
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_undo.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_undo.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_undo.c b/source/blender/editors/sculpt_paint/paint_undo.c index e406d4f5c3b..50a79005ee3 100644 --- a/source/blender/editors/sculpt_paint/paint_undo.c +++ b/source/blender/editors/sculpt_paint/paint_undo.c @@ -124,6 +124,30 @@ static void undo_stack_push_end(UndoStack *stack) { UndoElem *uel; uintptr_t totmem, maxmem; + int totundo = 0; + + /* first limit to undo steps */ + uel = stack->elems.last; + + while (uel) { + totundo++; + if (totundo > U.undosteps) break; + uel = uel->prev; + } + + if (uel) { + UndoElem *first; + + /* in case the undo steps are zero, the current pointer will be invalid */ + if (uel == stack->current) + stack->current = NULL; + + do { + first = stack->elems.first; + undo_elem_free(stack, first); + BLI_freelinkN(&stack->elems, first); + } while (first != uel); + } if (U.undomemory != 0) { /* limit to maximum memory (afterwards, we can't know in advance) */ |