Deleting a staff with multi-staves instrument containing a note in cross-staff notation crashes the program

• Nov 30, 2020 - 16:47
Reported version
3.3
Type
Functional
Frequency
Once
Severity
S2 - Critical
Reproducibility
Always
Status
active
Regression
Yes
Workaround
Yes
Project

Steps to reproduce:

1) open https://musescore.com/user/13065016/scores/3038561

2) go into instruments

3) try to remove the bass clef

This crashes 100% of the time in v3.5.2, the latest dev build of 3.x, as well as the latest 4.x nightly.


Comments

Stack trace:
1 std::_Rb_tree, std::_Select1st>, std::less, std::allocator>>::empty stl_tree.h 1009 0x109686c
2 std::map::empty stl_map.h 464 0x107eac8
3 Ms::StaffTypeList::uniqueStaffType stafftypelist.h 40 0x1023afe
4 Ms::Staff::staffTypeForElement staff.cpp 1027 0xa9946e
5 Ms::Note::updateRelLine note.cpp 2674 0xa22a82
6 Ms::Note::updateAccidental note.cpp 2226 0xa20b05
7 Ms::Chord::cmdUpdateNotes chord.cpp 1768 0x92d970
8 Ms::Score::getNextMeasure layout.cpp 2910 0x9dd32a
9 Ms::Score::collectSystem layout.cpp 3842 0x9e2cc9
10 Ms::LayoutContext::collectPage layout.cpp 4635 0x9e849b
11 Ms::LayoutContext::layout layout.cpp 4953 0x9ea16c
12 Ms::Score::doLayoutRange layout.cpp 4941 0x9ea0cc
13 Ms::Score::update cmd.cpp 302 0x5329e8
14 Ms::Score::endCmd cmd.cpp 260 0x532686
15 Ms::MuseScore::editInstrList instrdialog.cpp 576 0x68c842
16 Ms::MuseScore::editInstrumentList musescore.cpp 7031 0x435b8b
17 Ms::MuseScore::cmd musescore.cpp 6240 0x431414
18 Ms::MuseScore::cmd musescore.cpp 6063 0x430628
19 Ms::MuseScore::qt_static_metacall moc_musescore.cpp 524 0x5e7da8
20 void doActivate(QObject *, int, void * *) 0x68b978bb
...

Title Crash in the latest 3.x development build when deleting an instrument Crash in MuseScore 3 (including latest 3.x development build) when deleting a staff (bass)n from an instrument (piano)
Frequency Many  
Regression No Yes
Reported version 3.x-dev 3.3

Does not crash in 2.3.2 (which that score stems from)
3.3.4 crashes in that too

Attachment Size
The_Little_Drummer_Boy.mscz 16.06 KB
Title Crash in MuseScore 3 (including latest 3.x development build) when deleting a staff (bass)n from an instrument (piano) Deleting a staff in multi-staves instrument containing a note in cross-staff notation crashes the program

To reproduce from scratch ( the problem is in the penultimate measure of the score attached in the initial post : there are two notes, one of which is almost hidden in the staff below, so one is in cross-staff notation)

1) New score for piano
2) From the top staff, whatever note or voice, use cross-staff notation to switch a note into the second staff, Bass clef
3) Press "I" -> Remove second staff

Result: crash

  • Note: ditto in the reverse case (cross-staff notation from Bass clef into staff Treble clef, and deletion of the staff Treble clef)
  • Test file, before step#2 : test cross staves.mscz

See (the beginning shows the lack of problem when no cross-staff notation used)

Video_2020-11-30_182527.gif

Title Deleting a staff in multi-staves instrument containing a note in cross-staff notation crashes the program Deleting a staff with multi-staves instrument containing a note in cross-staff notation crashes the program
Workaround No Yes

AAAAHRGL! I was explicitly looking for cross staff notes, as that was my initial gut feeling for being the culprit.
Thanks for spotting that little bugger

Easy workaround: delete that cross staff note

I guess we either need to disallow removing staves containing cross-staff notes, or find and fix up any cross staff notes when deleting them, or - perhaps the easiest, and maybe even most effective - just detect and fix this on the next layout (which appears to be when the crash is happening). The only downside I see to the last approach is, who knows what would happen if you have three staves and delete the middle one, I guess its cross staff notes would migrate to the bottom? Maybe that's fine.

Disallowing deletion of staves with cross-staff notes is doing the major part of the work already: detecting the cross-staff notes!. When we're there, we can as well preserve them

If you have 3 staves with cross-notes both above and below, the notes will actually be entered on the middle staff. I think the notes that were entered on the middle staff should be deleted.