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

• Dec 27, 2014 - 23:59
Type
Functional
Severity
S4 - Minor
Status
closed
Project

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.


Comments

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:

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

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:

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

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:

https://github.com/musescore/MuseScore/commit/5fb40769fae34602de8c3836a…

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:

https://github.com/musescore/MuseScore/commit/df7ff007e8ff8536d6ea258b8…

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:

https://github.com/musescore/MuseScore/pull/1583

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.