Editing a note and revert to two staves after deleting one leads to a crash

• Dec 11, 2018 - 09:04
Reported version
3.0
Priority
P0 - Critical
Type
Functional
Frequency
Once
Severity
S2 - Critical
Reproducibility
Always
Status
closed
Regression
No
Workaround
No
Project

I've been trying to find a simple example, but I think this will do:

open the file
type i (to go to the instrument panel)
click on the top clarinet instrument
click on remove
click on OK
in the bass line, click on the first note
type a (to change the note to an A)
type ctrl-Z (to undo)
type ctrl-Z (to undo)

Musescore now consistently crashes.

Attachment Size
Emmanuel - big 3.mscz 32.18 KB

Comments

Title Crash after delete of Bb instrument, edit in Bass line, and then undo Editing a note and revert to two staves after deleting one leads to a crash
Frequency Many Once
Severity S3 - Major S2 - Critical
Type Graphical (UI) Functional

Confirmed with OS: Windows 7 SP 1 (6.1), Arch.: x86_64, MuseScore version (64-bit): 3.0.0.4421, revision: dc5e1d7

Steps, from scratch (and test file: test.mscz )

1) New score for two instruments -> enter a note in second staff
2) "I"
3) Remove first instrument -> Ok
4) Select the note and type another note (or press arrow up one time)
5) Undo twice
Result: crash

See:

Video.gif

Status PR created fixed

Fixed in branch master, commit 586e026fd4

fix #279827: maintain selection state in UndoMacro instead of using SaveState entries

As undo/redo may change score state and lead to elements destruction
selection must be reset prior to undo/redo operation. In order to be
able to restore (single) selection correctly we have to save info on
selection before it gets reset - and before committing any undo/redo
operation which may change it. Restoring selection makes sense only
after the operation ends.
The same, generally, applies to InputState with the exception that
it is not strictly necessary to reset it.

In order to do that at least two options are available:
1) Use two SaveState entries instead of one in each command stored
directly in undo stack: start and end entries.
2) Make undo commands stored directly in undo stack maintain state
themselves.

This commit implements the second option by introducing UndoMacro
class which replaces previously used single SaveState entries and
helps to resolve the issues mentioned above.