Certain operations add to undo stack and thus break redo

• Apr 26, 2017 - 14:25
S4 - Minor

Windows 10, GIT commit: 2839f55

Discovered while working on #97106: Crash when undo after save in a score with parts and courtesy key sig for 2.1. Basically, in any score that contains a courtesy element, a layout operation will add to the undo stack. For operations that we don't think of as modifying the score, this will seem surprising. Even if we add code to clean up the undo stack so there is no empty element remaining, the ability to redo will be gone. For example:

1) default untitled score
2) add key signature to beginning of second system, thus creating a courtesy signature at end of first system
3) add a note
4) undo
5) view Style / General, but don't make any changes - just hit Esc
6) redo

Result: nothing, even after multiple presses. You can't get that note back you added at step 4, because the mere viewing of Style / General.

It's normal that actual doing an edit of any kind - something that modifies your score - would affect the undo stack in this way. But we don't expect merely viewing a dialog to do this. Other operations that don't seem like edits but that trigger layout operations and thus have this effect include:

- Measure Properties
- Edit / Instruments

There may be others as well.

Not sure of the status for master, but if there is any way to make layout not be destructive - to not require an undo context and to perform undoable operations - that seems like it would be nice. Right now, I guess we need this to add/remove courtesy elements.