Looking at staff properties changes clef of instruments with multiple staves

• Nov 14, 2018 - 12:51
Reported version
3.0
Priority
P1 - High
Type
Functional
Frequency
Once
Severity
S2 - Critical
Reproducibility
Always
Status
closed
Regression
Yes
Workaround
No
Project

came up in https://musescore.org/en/node/278224

New score, bass clef
rightclick into staff, staff properties
OK (without chaning anything

--> bass clef turned into treble clef


Comments

Loading the piano seems to not load the clefs properly, I think. This in turn activates this line of code which decides that one staff of piano must be treble. I added <clef staff="1">F</clef> to 02-Bass_Clef.mscx in the instrument tag and the bug went away. However, when I add a piano and take away the treble clef staff and repeat the above steps, the issue is still there. I haven't been able to replicate it with any individual staff instruments (e.g. cello).

the bass clef template issue would be very easy to fix then, I could just add it to https://github.com/musescore/MuseScore/pull/4249, as that deals with template, just let me know.

Edit: actually it should be just <clef>F</clef>, that staff="1" doesn't survive a save . And the same trick indeed doesn't work for the grand staff template, there it rets removes, as being the default anyway

It would fix the template, but the issue would still exist for piano in general--and possibly any other multi staff instruments (are there any others?)

yes, several more, organ for examlpe

The real fix might be, in case of an empty clef (if (_clefType.empty())), to look at/for the default clef?

Title Just looking at staff properties changes clef Looking at staff properties changes clef of instruments with multiple staves

Just checked. It affects all multi-stave instruments. Also, pipe organ that has the octave lower F clef will change to a regular F clef if the treble clef is missing.

Nope. Take pipe organ, remove the middle bass clef, follow the above steps on the bass clef down an octave. It switches to a regular one.

I looked a bit further. Here is what happens:
1. The template has no clefs loaded. So, it uses the default of stave 1 == treble. The original cause of the issue.
2. Any other instrument loads all the clefs even if not all the staves are loaded. Therefore there is a mismatch between cleftype and staffidx. This causes all the other issues (I think)

Status active PR created

I had the idea of only updating the clef if the instrument changed. However, it seems the Instrument == operator will always return false if you open and close the staff properties. (See https://github.com/musescore/MuseScore/blob/master/mscore/editstaff.cpp… ) It returns false on the comparison of channels--code here. Regardless, I've seemed to circumvent the issue by doing a more manual comparison.

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

This also handles the bass clef template. I don't see the clef listed in other templates, either. But, this should work as long as the instrument isn't changing. If it does, then it should react the same way as before (correctly this time).

Status PR created fixed

Fixed in branch master, commit 80333371f6

Fix #278230 (again): Looking at staff properties changes clef of instruments with multiple staves
Bug still existed if part name was changed.
It exclusively should change when the instrument changes.