New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix GH#16363: Accidentals in chord symbols rendered incorrectly when using custom XML file #22541
base: master
Are you sure you want to change the base?
Conversation
6e1b355
to
9cf11c6
Compare
bdab1b0
to
0690feb
Compare
src/engraving/dom/chordlist.cpp
Outdated
if (!code.startsWith(u"0x") && !code.startsWith(u"0") && !code.startsWith('&') && !code.endsWith(';')) { | ||
// fix broken chord lists, see https://github.com/musescore/MuseScore/issues/16363 | ||
code = u"0x" + code; | ||
} | ||
bool ok = true; | ||
char32_t val = code.toUInt(&ok, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If code.startsWith('&')
is true, then this would fail anyway. Does this case occur at all?
If not, let's not check for it, because that only makes the code noisy
If yes, we should add proper handling for that case.
However, I'm not very confident whether I like this approach; it means that our String::number
method behaves differently from QString::number
, which seems a potential source of confusion.
Wouldn't the problem be fixed instantly if you do
char32_t val = code.toUInt(&ok, 0); | |
char32_t val = code.toUInt(&ok, 16); |
and drop all other changes? Or is it not certain that it will be a base16 number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
code.startsWith('&')
is true, then this would fail anyway. Does this case occur at all? If not, let's not check for it, because that only makes the code noisy If yes, we should add proper handling for that case.
We don't have full control over the content of a chords.xml, it could contain ♭
(@MarcSabatella even recommeded the latter in the issue as a workaround, #16363 (comment)).
The toUInt(..., 0)
would fail on it (as would a toUInt(..., 16)
), but return the string unchanged, as far as I understand.
Be generous in what you accept, but strict in what you generate ;-) (and that's why toUInt(..., 0)
exists)
However, I'm not very confident whether I like this approach; it means that our
String::number
method behaves differently fromQString::number
, which seems a potential source of confusion. Wouldn't the problem be fixed instantly if you do
...
and drop all other changes? Or is it not certain that it will be a base16 number?
The problem isn't that toUInt()
doesn't return a hex number, but that this number as a string doesn't look like one to the writer because of the missing "0x".
Also, as said above, it might be an octal number od a string with an HTML entity, we don't have full control over the content of these files.
But we can leave the String::number() as it was and just do it like in the 1st commit and prepend the "0x" there,
after all we do know though that we write as hex there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can understand your concerns reg. different behavoir of String::number()
vs. QString::number()
, so reverted that 2nd commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And we may not need the read fix at all, as save/close/open fixes the issue too, its just nice to have, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW: this would work too:
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, base);
And it does read that ♭
too, not a ©
though, toUInt()
(or rather rather std::strtol()
) probably just ignores all the non-alpha-numerical chars and (rightfully) interprets the rest as decimal.
24cee54
to
7fcc2b6
Compare
…using custom XML file
7fcc2b6
to
8b69c04
Compare
Came up again in https://musescore.org/en/node/364348 |
Resolves: #16363