From 4a8d925b2ed892264933aca8aa8f7ae34d2516ac Mon Sep 17 00:00:00 2001 From: Rodrigo Oliva Date: Wed, 27 Nov 2019 17:30:04 +0100 Subject: [PATCH] Only delete last commands in the undostack if the new command in not obsolete --- src/widgets/util/qundostack.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/widgets/util/qundostack.cpp b/src/widgets/util/qundostack.cpp index dbe01e4ad80..7c659a36116 100644 --- a/src/widgets/util/qundostack.cpp +++ b/src/widgets/util/qundostack.cpp @@ -648,8 +648,9 @@ void QUndoStack::push(QUndoCommand *cmd) } else { if (d->index > 0) cur = d->command_list.at(d->index - 1); - while (d->index < d->command_list.size()) - delete d->command_list.takeLast(); + if (!cmd->isObsolete()) + while (d->index < d->command_list.size()) + delete d->command_list.takeLast(); if (d->clean_index > d->index) d->clean_index = -1; // we've deleted the clean state }