Concert Pitch toggle transposes keys incorrectly when C major is involved

• Dec 20, 2014 - 00:04
Type
Functional
Severity
S3 - Major
Status
closed
Project

Ubuntu 14.04, GIT commit: 1f5915e

Several different ways to trigger different aspects of this. First is straightforward, second is more fun to watch :-)

First scenario:

1) new score for flute and Bb clarinet, key of C (concert)
2) press Concert Pitch repeatedly

Result: the first time it works correctly - clarinet goes to C major. It then *stays* C major as you continue to toggle. Any notes on the staff transpose correctly; just the key signature does not.

Second scenario

1) new score for alto saxophone & tenor saxophone, key of C (concert)
2) press Concert Pitch repeatedly

Result: first time (concert pitch on), all is well - both instruments go to C. Second time (off), alto sax goes back to A as it should, but tenor sax remains in C (wrong). Next time (on), alto goes to C as it should, now tenor goes to Bb (wrong). Next time (off), both go to C, but this is incorrect - concert pitch is *off*. Next time (on), alto goes to Eb (wrong), tenor remains in C (correct). Next time (off), alto goes to C (wrong), tenor to D (correct). Next time (on), both are in C - the first time they've both been correct since the intial press. At that point the cycle repeats.

This bug only seems to happen if there are mutliple staves involved and at some point at least one of them is in C.


Comments

I think I see the problem - because we are removing initial* "C" key signatures, Score::transposeKeys() is seeing the "hole" at tick 0 and just continuing - but at that point it has already set createKey to false. Moving that assignment a little later seems to fix this.

*Actually, we aren't just removing *initial* "C" key signatures; we are removing *all* C key signatures. We can't remove mid-score changes to "C"; otherwise the naturals won't show. Which leads to the following corollary bug:

1) new score for Bb clarinet, key G (concert)
2) add a key change to C (concert) somewhere after the first measure
3) toggle Concert Pitch repeatedly

Result: At first press, the key change goes away and never comes back.

These are two distinct bugs, but the fix is going to be in this same section of code, so I will submit a single PR.