From 855d8d3fa4bf212c8e035213c298fa232597214a Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 5 Jun 2023 15:16:15 +0200 Subject: [PATCH] Fix #88010: Undo system did not respect memory limit. Code was plainfully buggy, early-out check in `BKE_undosys_stack_limit_steps_and_memory` was plainfully wrong. Also added some more logging for memory limiting code. --- source/blender/blenkernel/intern/undo_system.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/undo_system.cc b/source/blender/blenkernel/intern/undo_system.cc index 1fce7d6500c..c2bffa423d4 100644 --- a/source/blender/blenkernel/intern/undo_system.cc +++ b/source/blender/blenkernel/intern/undo_system.cc @@ -384,7 +384,7 @@ UndoStep *BKE_undosys_stack_init_or_active_with_type(UndoStack *ustack, const Un void BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size_t memory_limit) { UNDO_NESTED_ASSERT(false); - if ((steps == -1) && (memory_limit != 0)) { + if ((steps == -1) && (memory_limit == 0)) { return; } @@ -398,6 +398,12 @@ void BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size if (memory_limit) { data_size_all += us->data_size; if (data_size_all > memory_limit) { + CLOG_INFO(&LOG, + 1, + "At step %zu: data_size_all=%zu >= memory_limit=%zu", + us_count, + data_size_all, + memory_limit); break; } } @@ -411,6 +417,8 @@ void BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size } } + CLOG_INFO(&LOG, 1, "Total steps %zu: data_size_all=%zu", us_count, data_size_all); + if (us) { #ifdef WITH_GLOBAL_UNDO_KEEP_ONE /* Hack, we need to keep at least one BKE_UNDOSYS_TYPE_MEMFILE. */