Crash on change duration (and other operations) after delete part and insert or delete measure
f51dc11 / Windows7
1) « My First Score » → change only the time signature to 2/4
2) Fill three measures by entering first a quarter note, then ten eighth notes
3) Generate parts -> Ok
4) Save under → Save → Close (you obtain this test file : test file.mscz )
5) Reload → Change time signature ie 4/4 instead of 2/4
6) File → Parts → Press "Delete" → Press "New all"→ Ok
7) Delete (Ctrl + Del) the first measure in main score. You are here :
8) Select the second eighth note
9) Change the value of this note eg to quarter note (or double-click on an arpeggio symbol in the palette)
Result : crash
Comments
To reproduce a "minimal" corruption from scratch (in playback eg), you have to:
1) add another time signature eg 6/4, and enter other notes under this timesig, in the first test file: test file added other timesig.mscz
2) Then, continue the same steps #3 to #7 -> Ditto, save the score before the crash
3) Continue steps #8 et #9
4) After the crash, reload the saved file and start playback in Part
Well, I can exactly reproduce this issue since May 2014 (image below produced with this nightly: 56177c3)
This reinforces I guess the idea that it is related to this one: #89401: Deletion of the first measure removes the time signature in parts
The question now is whether this pending fix (https://github.com/musescore/MuseScore/pull/2307) will solve partially, or totally, or not this issue?
It certainly does seem related, but unfortunately my fix for #89401: Deletion of the first measure removes the time signature in parts does not seem to fix this case. I will investigate further.
Turns out this is *not* related to the other bug. It's actually a more serious problem that will likely have many other effects unrelated to the time signature.
The actual crash comes from dereferencing a null pointer here:
https://github.com/musescore/MuseScore/blob/77e980d95d0aa40735a17eceb19…
"s" is null because, as far as I can tell, we are trying to find the corresponding note - on the "and" of beat one in the first measure - in the *already-deleted part*. But here is no note on the "and" of one, since that score never had its first measure deleted, so we are still looking at the original first measure.
The question is, why are we trying to mess with the already-deleted part? This stems from the fact that after deleting the part, the individual elements still have links. Upon adding a new part, there are now three sets of linked elements for each element, even though there are really only two valid elements (the one in the score and the one in the part). Each individual element still maintain links to the corresponding elements in the deleted part, and more relevant to this case, the list of linked staves still contains the deleted staff. It's actually the fact that the staff list still contains the staff in the deleted part that triggers the crash when lengthening a note. Other crashes could probably be triggered by the other bad links.
I've noticed this before, but for whatever reason it doens't cause problems all the time like one might expect - only on certain operations.
BTW, in step 3) above, you don't need to do the New All - the bug is not about the newly added part, but the deleted part. That is, just deleting the part is enough to trigger the bug; you don't need to add a new part to replace it. You also don't need to change the time signature. Here is a more direct series of steps:
1) my first score
2) measure 2, enter a single quarter note
3) file / parts, new all, ok
4) file / parks, delete, ok
5) insert measure before measure 2
6) select the rest on beat 2 of what is now measure 3
7) press "6" to change duration
Result: crash, same reason. The tremolog crash occurs in a different place in the code but for the exact same reason - we are trying to find the corresponding note in the already-deleted part.
The main cause is that when we delete parts we don't unlink staves.
I tried a fix https://github.com/musescore/MuseScore/pull/2397
Fixed in branch master, commit 8bf08c2328
fix #89636 fix #94911 fix #70226 fix #91351: unlink the right staves when deleting a part, or deleting a linked staff. Do not store several times the same staves in linkedStaves
second take
Fixed in branch master, commit c6ccf18398
Merge pull request #2397 from lasconic/fix-89636-and-more
fix #89636 fix #94911 fix #70226 fix #91351: unlink the right staves when deleting a part, or deleting a linked staff. Do not store several times the same staves in linkedStaves
Automatically closed -- issue fixed for 2 weeks with no activity.