[Potlatch-dev] Introducing Magic Roundabout tool
Steve Bennett
stevagewp at gmail.com
Wed Mar 2 10:22:17 GMT 2011
On Sun, Feb 27, 2011 at 5:17 AM, Dave Stubbs <osm.list at randomjunk.co.uk> wrote:
> The way to do what you want is to make your own action and perform the
> changes in the doAction method.
>
> ie:
> Create action X
> Add to main undo stack
> x.doAction:
> create, push and execute action A
> create, push and execute action B
> create, push and execute action C
>
> x.undoAction:
> pop and undo C
> pop and undo B
> pop and undo A
I've just had a go at implementing this (r25482). A few issues I've run into:
1) actions and actionsDone are declared private (so I change to protected)
2) doAction() gets called for redo, as well as the first do, which is
bad for performance. I found a way around this, but the class isn't
really set up for this method.
3) Public methods like push() and clearActions() don't belong on a
child of CompositeUndoableAction (or at least, a specific, rather than
generic, child).
4) I don't really understand what this kind of action is doing in Halcyon.
My overall feeling, having done this, is that there really wasn't much
benefit in making this an action, and the value of the additional
encapsulation is marginal. And I'm still not convinced that the "push
now, execute later" contract is the best (or even, only possible) one.
But hey, I've learnt something about the undo system.
Steve
More information about the Potlatch-dev
mailing list