'Create key signature for all systems' doesn't work correctly

• Dec 4, 2016 - 00:24
Reported version
3.0
Type
Functional
Severity
S5 - Suggestion
Status
closed
Project

MuseScore 3.0 (12/03/2016 - v1722)

The latest build of 3.0, along with many past builds, have this bug where the 'Create key signature for all systems' setting doesn't work. Go to Format>General Style>Page and at the bottom you will see this setting. You're able to enable it, it just doesn't do its function. I'll attach a score so that others can see.

Attachment Size
Jazz Big Band Template.mscz 16.45 KB

Comments

Works fine here, using 'My First Score' but indeed now when using a Jazz Big Band or Jazz Combo template
Does work with Closed Score SATB + Piano template, also with the Jazz Lead Sheat template

Title 'Create key signature for all systems' doesn't work when using a Jazz template 'Create key signature for all systems' doesn't work correctly

I can reproduce issues using "My First Score". Add a key signature to measure 1, no key signatures occur on subsequent systems until something forces a relayout.

Or, create a score from scratch, for a transposing instrument (say, Bb trumpet) and a concert pitch clarinet (say, trombone), key of C. You get a key signature for the first system only.

There is a patch to force a re-layout of the entire area affected by the addition of a key signature. This patch also fixes the bug where a key change to C major / A minor is not evident if it does not happen at the beginning of the system.

The crash has very little to do with this option, but toggling it will certainly trigger the crash.

The crash occurs when Bracket::_braceSymbol is used to access the _symbols array. This causes an index-out-of-range error, because Bracket::_braceSymbol has not been initialized. This can be solved by adding the line

_braceSymbol = SymId::brace;

to the constructor for the Bracket class. Crash averted. But there is another issue here. There is supposed to be a brace connecting the two Piano staves on each page. In fact, the brace is there, but we can't see it. There is code that allows MuseScore to draw its own brace if using Emmentaler or Gonville. It is easy enough to enable this code if using MuseJazz. But it would be better to try to get the brace to draw itself correctly.

The brace does not draw itself correctly because Bracket::_magx is never set to a usable value, because Bracket::setSpan() is no longer used. Bracket::width() can calculate the correct value for _magx like this:

_magx = span() + ((span() - 1) * score()->styleS(Sid::akkoladeDistance).val() / 4.0);

But Bracket::width() cannot modify the value of _magx because it is a const function. However, it can do this:

qreal __magx = span() + ((span() - 1) * score()->styleS(Sid::akkoladeDistance).val() / 4.0);

and use the value of __magx in the calculation of the width of the bracket. Because Bracket::layout() is not a const function, it can modify the value of _magx, and if it does, then the bracket will be displayed.

Of course, Bracket::setSpan() also performed the task of choosing the appropriate symbol for the brace based on the number of staves it spans. This could be done in Bracket::layout(), or we could go back to using Bracket::setSpan().