[Interest] QUndoStack
Bob Hood
bhood2 at comcast.net
Fri Jun 24 17:52:35 CEST 2016
On 6/24/2016 9:42 AM, Alan Ezust wrote:
> There is another thread on this very subject from last week:
>
> http://lists.qt-project.org/pipermail/interest/2016-June/023114.html
> http://lists.qt-project.org/pipermail/interest/2016-June/023116.html
>
> I agree with you, the QUndoStack design is really odd and the need to
> execute commands while pushing (in my view) makes it less flexible than it
> could be. I wonder if we will hear from anyone who likes this design?
It has been my experience that this is the typical design of an Undo system.
You invoke redo() as you inject the undo action into the stack, effectively
killing two birds with one stone. You don't push an action onto the stack
unless it has actually been applied. If the Undo stack did not apply the
action, there's no contract in place to guarantee that the action has been, or
will be, applied in another context. A subsequent undo() on an action that
was never applied means you might (in the best case) corrupt the application's
data.
It's an effective design, requiring less code, and guaranteeing a valid stack
state.
Just my $0.02.
More information about the Interest
mailing list