Bungee wrote:
It should happen in a background thread which gets triggered by a timer.
Just a short story to illustrate my point: CorelDraw has autosave which was enabled (every five minutes).
CorelDraw took four minutes to load the image.
It took nine minutes to draw it (complex image, slow PC, old version of CorelDraw).
And seven to autosave.
Presto: Endless loop.
So do it in the background and make sure it doesn't disturb the user or, even better, save the undo-buffer in a kind of log file. This way, you can have a video of the drawing how it was done (redraw while you load the file), too and saving the changes takes almost no time, especially when you choose a format where you can simply append to the existing file.
It sould also be possible for the user to disable the feature, for exactly the reasons above!
Well, it should not be possible to get an endless loop like that no matter how you set the values. The best solution would be a background thread which gets triggered, makes a copy of the current drawing, saves it and then listenes for the next event (dropping all those which happened in the meantime).
Of course, the save-the-undo solution would be better (I think that's what Vim does) but that depends on the structure of objects on the undo stack. If the structure is very simple, it might be possible to write a generator which creates the object savers from the source so you would get a couple of cool possibilities almost for free.