Musescore 3.6 - Hidden staff clef changes from other parts appearing in top staff of visible system

• Jan 20, 2021 - 08:29
Reported version
S3 - Major


Firstly, thank you for the new 3.6 version. I've now been able to make some of my scores look amazing with the new vertical justification option.

And, I've noticed a bug when I've moved scores into the new vertical justification format.

When I've hidden empty staffs for the score, if there's been a clef change in a hidden part at the end of a system (X), the new clef for the part (now unhidden) in the next system (Y) sometimes appears in the top staff at the end of the previous system (X).

There are some examples in this score, which I moved into vertical justification:…

At the end of bar 8, a bass clef appears in the top (Oboe) part at the end of the bar. This is actually a bass clef change for the hidden Piano part, which appears in the next system.

Similarly, at the end of bar 74, a tenor clef appears in the top (Flute) part at the end of the bar. This is actually a tenor clef change for the hidden Bassoon part, which appears in the next system.

Now, I've a couple of workarounds
1. I could make courtesy clefs invisible - and that would also make visible staff clef changes for parts in both systems only appear in the next system too, which isn't ideal.
2. I could make each of these misplaced clefs invisible - and that would take time, which again isn't ideal.

Any ideas/suggestions would be most welcome.

Attachment Size
Stravinsky - AGON Exact Transcription.mscz 627.41 KB


Are you sure this is connected to the vertical justification option> The clef does not go away if I turn that option off. Also, it does go away if I remove the page break after measure 8 then add it back, but then reappears the next full layout, like on save.

However, I cannot so far make it appear in 3.5.2. I'm guessing the issue relates to changes made to improve rendering of clefs etc with respect to cutaway staves. I realize the piano isn't actually set up that way, but other staves are, and in any case, the code ends up being executed even when there is no cutaway staff involved.

Meanwhile we're continuing to investigate.

In reply to by Marc Sabatella

Thank you for looking into this. Yes, I believe you’re correct that it doesn’t seem to be specific to the new vertical alignment option. So it’ll be something within all the other updates in 3.6. I love the changes implemented in 3.6. Really impressed by the work that’s gone into it and I hope this little issue I’ve had will get sorted in time. For now it’s merely a minor annoyance to me. Grateful for your support.

See also #316321: Clef change at start of system on cutaway staff causes missing barline and extra staff lines. This is a rather more specific case where if the hidden staff with the clef change at the start of the system is a cutaway staff (not the case in your example, although it does contain staves with invisible measures), there is an additional glitch with extra staff liens being drawn and a missing barline.

Anyhow, thanks for identifying this and pinpointing the trigger. It was still quite the chase actually figuring out the solution, and obviously, still more to do, but a rather lesser problem.

Status PR created fixed

Fixed in branch 3.x, commit ad5720c872

_fix #315861: don't show clef changes on hidden staves


Issue is that a clef change at the end of a system
on a staff that is hidden
will still generate the clef and it will be displayed
on the top staff of the score.

The issue stems from the new isCutawayClef() function
returning true in many places where it does not need to.
Most importantly to this issue,
it's returning true for the hidden staff,
but it can also return true for staves that aren't cutaway.
And it incorrectly returns false for invisible staves
that do not happen to be empty.

There are two parts ot this fix.
One is improviing isCutawayClef() itself
to handle the correct cases of "empty" measures.
It isn't all measures with no notes;
it's all measures with no notes on cutaway staves,
but also all invisible measures whether they have notes or not.

Then, we also need to handle the the hidden staff issue.
This is done within scanElements(),
which needs to skip invisible staves.
It previously did this by checking if the measure was visible,
but that check was altered as part of the same change
that brought us these nice cutaway clefs.
So I have added that check explicitly.

The resulting code should handle all of these cases properly now,
and has the extra benefit of no longer executing most of isCutawayClef
for most measures on most staves,
which will protect against the sort of regressions we saw earlier
when this fucntion caused problems with scores that didn't even contain
cutaway staves or invisible measures._

Fix version