revamping the undo infrastructure in Dia


The current state of the Undo/Redo infrastructure in Dia seriously
lacks maintenance. A quick search for "undo" in bugs showed up some
long-standing bugs, fixing which would require a lot of work and some
fresh thinking. Here's a summary, sorted by what I think is more

Bugs that highlight problems in the core:
Undo does not restore size of automatically resized shapes
change diagram background colour should be undoable
properties dialog creates empty undo actions when no properties are changed

Bugs that are just enhancements and/or will get fixed as a side-effect:
Undo & redo menu labels need detail I.e. "Undo move", "Undo delete"
properties dialog should have a button to undo all changes made while
interacting with the dialog

And here's my take on how Undo/Redo needs improvement:

1) The _Change struct in app/undo.h should have a facility to track
side-effects. For example, when changing a text-object results in a
resizing of the object, the resize should be recorded as a side-effect
of the main text-related Change.

2) Every function that modifies an object in any way needs to be
tracked down, and rewritten to suitably return a Change object. For
example, there is one place where obj->ops->move() is called simply
with the intention that is best described as

Also there is a hidden problem with the way the properties dialog
tracks undo history. It records the previous state of _all_ known
properties, whether or not they are changed. This can lead to
scalability problems if we dare to think of huge groups of objects
with a huge list of properties. Also, this cannot handle side-effects
to the object that do not involve properties. For example, changing
the font of a text object changes its size, but this is not tracked by

This can only be fixed if the Undo/Redo infrastructure guarantees that
side-effects are efficiently handled elsewhere. But the improvements
required for Undo are quite extensive, and would require lots of
planning as well as sufficient blessings from the gods of Dia.

Research Scholar, Department of CSE, IIT Bombay

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]