Elements of grace notes in drumset incorrectly positioned, or shouldn't appear

• Dec 27, 2014 - 23:59
S4 - Minor

1. Open attached score (produced in 5c9b9da).

Result: Ledger lines appear at the grace note in bar 9 of drums.
Elements of grace notes in drumset incorrectly positioned, or shouldn't appear.png

Note: Doing something (moving a note) will correct the layout.

Using MuseScore 2.0 Nightly Build be05ea4 - Mac 10.7.5.


See also the attached example, in which a tremolo on a drum grace note is similarly positioned way below the staff at first, then fixes itself on first relayout.

The problem is that we are at one point setting the line for the note incorrectly. Note::updateRelLine() is setting it simply based on clef, not taking into consideration that this is a drum staff. But why are we calling updateRelLine() for grace notes on drum staves in the first place? I think the best place I think to fix this is here:


At this point, we are recomputing accidentals and line positions for notes within chords in response to something that might have affected this. Note::updateAccidentals() is not good to call for notes on drum staves. So we should be checking for that. What I don't know is if we need to be doing something different, like copying the code used for main notes in drum staves just below:


To be honest, I'm not sure I understand why even that code is needed. The line and head for drum notes are set elsewhere (eg, Measure::layoutCR0()) and shouldn't need to be updated at the drop of a hat the way ordinary notes might. It looks like this entire function was only added back in April, as part of:


Also, FWIW, I think the call to Score::cmdUpdateNotes() that is triggering all this for the scores in question was only added very recently, as part of this:


This all has to do with code that has been very fragile - concert pitch, tpc's, key sigs, and undo.

It seems to work to simply add a "&& staffGroup != StaffGroup::PERCUSSION" to the line I pointed out first ("if (gnb)") and the corresponding "if (gna)" section a little further down. It probably wouldn't hurt to copy the code to set line based on drumset. But I'm nervous about touching any of this.

Attachment Size
grace-drum-13.mscx 17.07 KB
Status (old) active patch (code needs review)

Despite my not being confident about all the possible interactions, here is a PR that implements the fix I mention above:


I don't see any obvious bad effects from not copying the line-setting code used for normal (non-grace-note) chords. I even tried commenting out that code for normal notes and didn't see obvious ill effects.