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.
This commit is contained in:
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user