This PR changes the strategy for undo/redo when using edition commands. This change was needed:
to reduce processing time and memory requirements,
to avoid dependecy on any source format, and
to simplify and avoid maintenace.
In the old approach for undo/redo based on checkpoints, it was necessary to save the document state before applying a command. But in practice, this resulted in having to save the whole document (or part of it) in source format for every command.
The main problem of this approach was that the checkpoint format was LDP, but LDP doesn't support as many music notation elements as other supported formats, such as MusicXML, and thus, undo/redo didn't work for MusicXML. It also required a perfectly matched pair of LDP importer and exporter, that must be updated for every new supported feature, and this was a constant source of undo/redo bugs when more features are added to lomse.
A second problem was memory and processing time consumption: the checkpoint data (saving the whole document or parts of it in source format for each command) could consume a lot of memory for large documents. Also exporting and importing source format for every command requires excesive time for large documents.
This PR changes the strategy for undo/redo that now is based on saving an initial copy of the internal model and the issued edition commands. For restoring the state to any previous point, the internal model is restored from the copy (just replacing a pointer) and all commands until the desired one are re-played. Simple and perfect undo, very fast and with mínimal memory consumption. It also avoids undo/redo maintenace when developping more commands, and is valid for all source formats.
Changes
DocCmdExecuter: all methods related to undo/redo have been reviewed and fixed.
This PR changes the strategy for undo/redo when using edition commands. This change was needed:
In the old approach for undo/redo based on checkpoints, it was necessary to save the document state before applying a command. But in practice, this resulted in having to save the whole document (or part of it) in source format for every command.
The main problem of this approach was that the checkpoint format was LDP, but LDP doesn't support as many music notation elements as other supported formats, such as MusicXML, and thus, undo/redo didn't work for MusicXML. It also required a perfectly matched pair of LDP importer and exporter, that must be updated for every new supported feature, and this was a constant source of undo/redo bugs when more features are added to lomse.
A second problem was memory and processing time consumption: the checkpoint data (saving the whole document or parts of it in source format for each command) could consume a lot of memory for large documents. Also exporting and importing source format for every command requires excesive time for large documents.
This PR changes the strategy for undo/redo that now is based on saving an initial copy of the internal model and the issued edition commands. For restoring the state to any previous point, the internal model is restored from the copy (just replacing a pointer) and all commands until the desired one are re-played. Simple and perfect undo, very fast and with mínimal memory consumption. It also avoids undo/redo maintenace when developping more commands, and is valid for all source formats.
Changes
DocCmdExecuter
: all methods related to undo/redo have been reviewed and fixed.Other changes