Add limit to UndoRedo #8073
dcuny
started this conversation in
General Discussions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, there's no way to limit the size of the
UndoRedo
stack.For applications with a very large
UndoRedo
history, this can prove problematic.Currently, the only way to control the
UndoRedo
stack is to check the size of the stack withUndoRedo::get_history_count()
, and clear the entire stack withUndoRedo::clear_history()
.However, this is an all-or-nothing sort of approach.
If
UndoRedo::_pop_history_tail()
were exposed, it would be simple enough to implement at the user level, although there seems to be some finessing of the maintaining theRedo
actions on the stack that I don't understand, which is why I'm posting this under Discussion and not Proposal.It looks like a routine to clip the history stack could be implemented by writing a variant of
clear_history()
:A cleaner approach might be to add this code block to the end of
UndoRedo::commit_action
. This would check the size of the history automatically.For this to happen, it would also require adding a
stack_limit
attribute to the class, where0
would indicate no limit and the default behavior.Since changing the constructor is likely to be disruptive to existing code, I'd also suggest adding a
UndoRedo::set_stack_limit()
method.Beta Was this translation helpful? Give feedback.
All reactions