Skip to content

Commit

Permalink
Fix GH#16363: Accidentals in chord symbols rendered incorrectly when …
Browse files Browse the repository at this point in the history
…using custom XML file
  • Loading branch information
Jojo-Schmitz committed Apr 24, 2024
1 parent 8526264 commit 24cee54
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/engraving/dom/chordlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1685,8 +1685,13 @@ void ChordList::read(XmlReader& e)
String code = e.attribute("code");
String symClass = e.attribute("class");
if (!code.empty()) {
int base = 0; // guess, based on content
if (!code.startsWith(u"0") && !(code.startsWith(u"&#") && code.endsWith(u";"))) {
// fix broken chord lists, see https://github.com/musescore/MuseScore/issues/16363
base = 16; // force hex
}
bool ok = true;
char32_t val = code.toUInt(&ok, 0);
char32_t val = code.toUInt(&ok, base);
if (!ok) {
cs.code = 0;
cs.value = code;
Expand Down Expand Up @@ -1780,7 +1785,8 @@ void ChordList::write(XmlWriter& xml) const
if (s.code.isNull()) {
xml.tag("sym", { { "name", s.name }, { "value", s.value } });
} else {
xml.tag("sym", { { "name", s.name }, { "code", String::number(s.code.unicode(), 16) } });
// write hex numbers with a "0x" prefix, so they can convert back properly on read
xml.tag("sym", { { "name", s.name }, { "code", u"0x" + String::number(s.code.unicode(), 16) } });
}
}
}
Expand Down

0 comments on commit 24cee54

Please sign in to comment.