Skip to content

Commit 660df4b

Browse files
committed
fix musescore#18425 - part containing key with more than 6 accidentals has to be PreferSharpFlat::NONE
1 parent fff51ed commit 660df4b

File tree

7 files changed

+33
-1
lines changed

7 files changed

+33
-1
lines changed

src/engraving/rw/read400/tread.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,11 @@ void TRead::read(KeySig* s, XmlReader& e, ReadContext& ctx)
12791279
if (sig.custom() && sig.customKeyDefs().empty()) {
12801280
sig.setMode(KeyMode::NONE);
12811281
}
1282+
// if there are more than 6 accidentals in transposing key, it cannot be PreferSharpFlat::AUTO
1283+
if (p && !s->concertPitch() && (sig.key() > 6 || sig.key() < -6)
1284+
&& p->preferSharpFlat() == PreferSharpFlat::AUTO && !p->instrument(s->tick())->transpose().isZero()) {
1285+
p->setPreferSharpFlat(PreferSharpFlat::NONE);
1286+
}
12821287

12831288
s->setKeySigEvent(sig);
12841289
}

src/engraving/rw/read410/tread.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,11 @@ void TRead::read(KeySig* s, XmlReader& e, ReadContext& ctx)
12841284
if (sig.custom() && sig.customKeyDefs().empty()) {
12851285
sig.setMode(KeyMode::NONE);
12861286
}
1287+
// if there are more than 6 accidentals in transposing key, it cannot be PreferSharpFlat::AUTO
1288+
if (p && !s->concertPitch() && (sig.key() > 6 || sig.key() < -6)
1289+
&& p->preferSharpFlat() == PreferSharpFlat::AUTO && !p->instrument(s->tick())->transpose().isZero()) {
1290+
p->setPreferSharpFlat(PreferSharpFlat::NONE);
1291+
}
12871292

12881293
s->setKeySigEvent(sig);
12891294
}

src/importexport/bb/internal/bb.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,10 @@ Err importBB(MasterScore* score, const QString& name)
561561
Interval v = staff->part()->instrument(tick)->transpose();
562562
if (!v.isZero() && !score->style().styleB(Sid::concertPitch)) {
563563
cKey = transposeKey(key, v);
564+
// if there are more than 6 accidentals in transposing key, it cannot be PreferSharpFlat::AUTO
565+
if ((key > 6 || key < -6) && staff->part()->preferSharpFlat() == PreferSharpFlat::AUTO) {
566+
staff->part()->setPreferSharpFlat(PreferSharpFlat::NONE);
567+
}
564568
}
565569
ke.setConcertKey(cKey);
566570
ke.setKey(key);

src/importexport/capella/internal/capella.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,8 +870,13 @@ static Fraction readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, const
870870
Key tKey = Key(o->signature);
871871
Key cKey = tKey;
872872
Interval v = score->staff(staffIdx)->part()->instrument(tick)->transpose();
873-
if (!v.isZero() && score->style().styleB(mu::engraving::Sid::concertPitch)) {
873+
if (!v.isZero() && !score->style().styleB(mu::engraving::Sid::concertPitch)) {
874874
cKey = transposeKey(tKey, v);
875+
// if there are more than 6 accidentals in transposing key, it cannot be PreferSharpFlat::AUTO
876+
Part* part = score->staff(staffIdx)->part();
877+
if ((tKey > 6 || tKey < -6) && part->preferSharpFlat() == PreferSharpFlat::AUTO) {
878+
part->setPreferSharpFlat(PreferSharpFlat::NONE);
879+
}
875880
}
876881
okey.setConcertKey(cKey);
877882
okey.setKey(tKey);

src/importexport/midi/internal/midiimport/importmidi.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ void MTrack::processMeta(int tick, const MidiEvent& mm)
334334
Interval v = staff->part()->instrument(t)->transpose();
335335
if (!v.isZero() && !cs->style().styleB(Sid::concertPitch)) {
336336
cKey = transposeKey(tKey, v);
337+
// if there are more than 6 accidentals in transposing key, it cannot be PreferSharpFlat::AUTO
338+
if ((tKey > 6 || tKey < -6) && staff->part()->preferSharpFlat() == PreferSharpFlat::AUTO) {
339+
staff->part()->setPreferSharpFlat(PreferSharpFlat::NONE);
340+
}
337341
}
338342
ke.setConcertKey(cKey);
339343
ke.setKey(tKey);

src/importexport/musicxml/internal/musicxml/importmxmlpass2.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3826,6 +3826,11 @@ void MusicXMLParserPass2::key(const QString& partId, Measure* measure, const Fra
38263826
Interval v = _pass1.getPart(partId)->instrument()->transpose();
38273827
if (!v.isZero() && !_score->style().styleB(Sid::concertPitch)) {
38283828
cKey = transposeKey(tKey, v);
3829+
// if there are more than 6 accidentals in transposing key, it cannot be PreferSharpFlat::AUTO
3830+
Part* part = _pass1.getPart(partId);
3831+
if ((tKey > 6 || tKey < -6) && part->preferSharpFlat() == PreferSharpFlat::AUTO) {
3832+
part->setPreferSharpFlat(PreferSharpFlat::NONE);
3833+
}
38293834
}
38303835
key.setConcertKey(cKey);
38313836
key.setKey(tKey);

src/importexport/ove/internal/importove.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,10 @@ void OveToMScore::convertSignatures()
841841
Interval v = staff.part()->instrument(tick)->transpose();
842842
if (!v.isZero() && !m_score->style().styleB(Sid::concertPitch)) {
843843
cKey = transposeKey(key, v);
844+
// if there are more than 6 accidentals in transposing key, it cannot be PreferSharpFlat::AUTO
845+
if ((key > 6 || key < -6) && staff.part()->preferSharpFlat() == PreferSharpFlat::AUTO) {
846+
staff.part()->setPreferSharpFlat(PreferSharpFlat::NONE);
847+
}
844848
}
845849
ke.setConcertKey(cKey);
846850
ke.setKey(key);

0 commit comments

Comments
 (0)