Crash on autosave after deleting staff from instrument in score with linked parts

• Jun 1, 2015 - 02:51
Type
Functional
Severity
S2 - Critical
Status
closed
Project

To reproduce, create a new score that includes an instrument of more than one staff (say, piano). Go to File -> Parts… -> New All. In the main score, go to Edit -> Instruments… and delete one of the staves from the piano. Go the corresponding part. All looks well. The crash does not happen right away, but rather a few seconds after you click in the multimeasure rest.


Comments

Can reproduce, with MuseScore 2.0.1 and the latest build on Windows 7, thought at first I could not, as those 'few seconds' did take quite long to pass ;-)

Error message:

Fatal: bad _barLineSpan 2 for staff 0 (nstaves 1) (...\MuseScore\libmscore\staff.cpp:495, void Ms::Staff::write(Ms::Xml&) const)

I had to wait quite a while for the crash, but it happened. It has nothing to do with the clicking, I believe - it is triggered by the auto-save.

The bug is related to #57136: Adding new staff to existing instrument does not appear in linked part. We need to figure out what we really want to support in terms of adding/removing staves from instruments involved in parts. EIther disallow the operations, make the operations link fully in both score and parts, or define some sort of semantics for how things should work if we decide to allow different numbers of staves for an instrument in score versus part. I can see all sorts of complications with the last idea, FWIW. For example, what if you had one staff for piano in the score, two in the aprt (or vice versa), then tried to use cross staff notation?

Title Crash shortly after deleting staff from instrument in score with linked parts Crash on autosave after deleting staff from instrument in score with linked parts

Here it is what is happening in this case with current build ( 48f066c8f ):
when the staff is removed at line 305 of mscore\instrdialog.cpp:
rootScore->cmdRemoveStaff(sidx);
it removes also all the linked staves, at line 2515 of libmscore\score.cpp:
undoRemoveStaff(staff);
(shouldn't it be lscore->undoRemoveStaff(staff);?)
then, after a recent fix, inside instrdialog.cpp it checks and validates the barlinespan and bracketspan for all the staves of the rootscore, at lines 412 -475, but this is not done for the child score in the part.
The non-updated value of barlinespan is apparently what is causing the crash at a qFatal check inside libmscore\staff.cpp during writing.

If we decide to keep the current behavior (i.e. the staff in the part is removed when it is removed in the root score), a possible solution could be to make lines 412-475 of instrdialog.cpp into a function of score.cpp acting on the score and call this validating function inside cmdremovestaff for both the root and the part scores.