#1003 Undo/redo flaw

jchempaint-primary
open
Goglepox
5
2012-10-31
2009-10-26
Mark Rijnbeek
No

With respect to the new undo/redo framework the following is noticed: new objects are created in the redo method. This can break the redo.
Example:
AddAtom.redo() creates a new Atom, ie. a new object. AddBond.redo() adds a Bond betwen two atoms. These two atoms (atom objects) are fixed in the class.
Now do this: Create two atoms, link them with a bond. Fine so far. Undo all three actions. Redo the add atom. You get two new atom objects. Redo the add
bond. It adds a bond between the old atoms, this is incorrect.

Possible solution is either to change things to identify objects by something like IDs, which you make immutable or you must make sure that your undo/redo
methods only add/remove objects from/to the model, which stay unchanged. This is actually the main reason why the old code had a separate code for doing
the first action and then the undo/redo. Of course it can be done in the new design, but then one needs to do the creation of object in the constructor or
so.

Discussion