Crash when saving after deleting a staff from grand staff in score with parts

• Jan 19, 2016 - 07:12
Priority
critical
Status
closed
Component
Code
Tags
Category
bug report
Project

ac4819da45 and MuseScore 2.0.2

May be related to #91271: Crash on save after creating new part from score with connecting barlines with parts selected in bottom-to-top order

  • Create a score from the SATB + Piano template
  • Create all parts
  • Press i and delete the bass clef staff from piano
  • Press OK
  • Save the file

--> Crash on a qFatal...

#5 0x0000000100bb90ac in Ms::Staff::write(Ms::Xml&) const at /Users/lasconic/MuseScore/libmscore/staff.cpp:505
#6 0x0000000100afc144 in Ms::Part::write(Ms::Xml&) const at /Users/lasconic/MuseScore/libmscore/part.cpp:110
#7 0x0000000100b76258 in Ms::Score::write(Ms::Xml&, bool) at /Users/lasconic/MuseScore/libmscore/scorefile.cpp:214
#8 0x0000000100b765fc in Ms::Score::write(Ms::Xml&, bool) at /Users/lasconic/MuseScore/libmscore/scorefile.cpp:235
#9 0x0000000100b78516 in Ms::Score::saveFile(QIODevice*, bool, bool) at /Users/lasconic/MuseScore/libmscore/scorefile.cpp:679


Comments

I think this is a known problem, a duplicate, reported in various ways: eg: #63226: Crash on autosave after deleting staff from instrument in score with linked parts, or: #70226: Entering an articulation/ornament after the deletion of a linked staff in a file with part causes crash and others related.

Indeed, the main point for receive a crash is:
- after generating parts, remove a staff of an instrument containing two staves (piano, harp) or three staves (organ, harpsichord etc: in this case, you have to delete the last two staves to receive the crash)
- or, after generating parts, remove a linked staff.

And indeed, the workaround is to either not create the parts before deleting these staves, or either remove the parts (and recreate them after) before the removal of the staff.

Other examples with minimum scores:
Piano: Piano Template.mscz
Harp: Harp score.mscz
Organ: Organ score.mscz
Template Guitar + Tab: Guitar + Tablature template.mscz

1) Load these files above
2) Generate parts
3) Delete the second staff (the last two for organ)
4) Save
Result: crash

For guitar + Tab, the crash occurs one step after [ 4) Save 5) Enter a note] -> crash

If I understood correctly, this commit fixes the cases of staves removal for instruments with two or three staves (piano, organ etc.)
But not issues related to the deletion of a linked staff - after generating parts always :(

1) Guitar + Tablature template (or violin + linked violin etc.)
2) Generate parts
3) Delete Tab staff (second staff)
4) Enter a note (no necessary to save before, as described above in comment #2, my oblivion / error)
Result: crash

Edit: Of course, a linked staff is of a different nature (well, I guess!), but I thought that the creation of the parts before the deletion of a staff was the central point of these issues. Apparently not, or not only :(

As far as I know, there are two basic causes of crashes that relate to adding or removing staves in the presence of linked parts. One of these has to do with management of barlines and making sure they span the proper number of staves. I think this is what was fixed here. The other problem is more basic: when we remove a linked staff, each of the elements on the remaining staff still thinks it is linked to the corresponding element on the now-deleted staff. Which is basically just a crash waiting to happen. I think we probably have at least half a dozen issues reported that are just specific ways to get MuseScore to crash once it reaches that state with all these links to elements on deleted staves.