Key signatures displayed incorrectly after clef change

• Apr 8, 2019 - 18:17
Reported version
3.0
Priority
P1 - High
Type
Functional
Frequency
Once
Severity
S3 - Major
Reproducibility
Always
Status
closed
Regression
No
Workaround
No
Project

This is an issue on both 3.0.5 and master:

1) default score, or a new score from treble template with enough measures for at least two systems
2) add key signature to first measure
3) add bass clef to second measure

Result: key signature displayed incorrectly on second & subsequent systems, as if the clef change didn't happen Fixes itself on next relayout, but then Undo then leaves the new keysig in place on the old clef.


Comments

The problem seems to be that in KeySig::layout(), we are looking to see if we can find a clef at the same tick, and we find the clef just to the left of us, which hasn't been updated yet - keysigs are laid out before clefs in addSystemHeader().

We could consider changing that order, but that could have unknown consequences. Better might be to not do this "check same tick" thing at all, and just fall through to the next chunk of code that uses the cleflist instead. That too might fail in some case I'm not thinking of offhand - either way, thorough testing would be required.

Here's the PR where the check for clefs was added, some discussion in the threads there that should give some good insight into things to watch out for: https://github.com/musescore/MuseScore/pull/3694

Status active PR created

Marc's idea of laying out clefs before keysigs in addSystemHeader() seems like the way to go, since the header clef comes before the key signature anyway, and the display of the key signature depends on the header clef being correct. I just tested it and it solves the issue. I can't think of any problems that would be caused by correcting the layout order of these two elements.

PR is here: https://github.com/musescore/MuseScore/pull/4942.

Fix version
3.1.0