A score creation with two instruments and linked staves is corrupted immediatly after entering a note

• Jun 20, 2015 - 15:57
Type
Functional
Severity
S2 - Critical
Status
closed
Project

Nightly 37e54f6 / Windows7

First reported: https://musescore.org/en/node/66051

1) Via the wizard, create a score for flute. Or open this file (arrived before step 4): flute score.mscz
2 ) Add a linked staff
3) Repeat steps #1 et #2 to add a second flute score with a linked staff

4) Note input mode -> entering a note in the top staff

Result: corruption (the rests in the second flute score disappears). After save-reload, ditto, with a warning.


Comments

It seems the issue occurs only when adding both guitars at once (as opposed to adding one, completing the wizard, then going back and adding the other). It also doesn;t not fail if another instrument is added between the two.

The issue is that the rests are all linked, even though the staves themselves are not.

After checking, I can say that the issue appears on March 3

- This Nighlty on March 1 (no nighlty on March 2) works: 1d90b26
With result as expected:
result march1.jpg

- Not this one, on March 3: 2dcd7b9
With result (corrupted score)
result march3.jpg

There is a lot of commits on this day, but commits involved with score creation and linked staves, I see this one, first: https://github.com/musescore/MuseScore/commit/e4926366e61c923d487b5abd8…
Or, the two followings (less likely?) :
- https://github.com/musescore/MuseScore/commit/2dcd7b980f20183daeb7ecd5c…
- https://github.com/musescore/MuseScore/commit/7d2e05d34abff3e7327be9597…

Good call! The issue occurs with this particular section of code:

https://github.com/musescore/MuseScore/blob/bf8dc84d4c98f3fe66cb3c55e6b…

Here, we are adding rests and trying to see if we can link the rest from the previous staff. We are going and doing the link if the staff we are adding is linked, but we aren't checking that it is linked *to the previous staff*. So when we add the top staff for the second guitar, we link it to the rest from the previous staff rather than creating a new rest.

Interestingly, the same thing doesn't occur if you add staves later in via Edit / Instruments, even if you follow the same steps. The code there works entirely differently.

This relates to the big change to how scores are created from templates. I checked, and before that change, there was additional loop and test that checked for staff->primaryStaff(). Simply changing staff->linkedStaves() (returns true if staff has any links) to !staff->primaryStaff() (true is this staff is linked but is not the first of the set) solves the problem. Not sure if it's the best solution, but I'll investigate more later.