Skip to content

Commit

Permalink
Avoid deprecated assignment past the end of QString
Browse files Browse the repository at this point in the history
https://doc.qt.io/qt-5/qstring.html#operator-5b-5d says this about
QCharRef QString::operator[](int position):

"Before Qt 5.14 it was possible to use this operator to access a
character at an out-of-bounds position in the string, and then assign
to such a position, causing the string to be automatically
resized. These behaviors are deprecated, and will be changed in a
future version of Qt."
  • Loading branch information
orivej authored and vpereverzev committed Dec 22, 2020
1 parent 61f4287 commit 5a03ffe
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions libmscore/chordlist.cpp
Expand Up @@ -487,7 +487,7 @@ bool ParsedChord::parse(const QString& s, const ChordList* cl, bool syntaxOnly,
#endif
int lastLeadingToken;
int len = s.size();
int i, j;
int i;
int thirdKey = 0, seventhKey = 0;
bool susChord = false;
QList<HDegree> hdl;
Expand All @@ -509,12 +509,12 @@ bool ParsedChord::parse(const QString& s, const ChordList* cl, bool syntaxOnly,
#endif
lastLeadingToken = _tokenList.size();
// get quality
for (j = 0, tok1 = "", tok1L = "", initial = ""; i < len; ++i, ++j) {
for (tok1 = "", tok1L = "", initial = ""; i < len; ++i) {
// up to first (non-zero) digit, paren, or comma
if (extensionDigits.contains(s[i]) || special.contains(s[i]))
break;
tok1[j] = s[i];
tok1L[j] = s[i].toLower();
tok1.push_back(s[i]);
tok1L.push_back(s[i].toLower());
if (tok1L == "m" || major.contains(tok1L) || minor.contains(tok1L) || diminished.contains(tok1L) || augmented.contains(tok1L))
initial = tok1;
}
Expand Down Expand Up @@ -617,10 +617,10 @@ bool ParsedChord::parse(const QString& s, const ChordList* cl, bool syntaxOnly,
#endif
lastLeadingToken = _tokenList.size();
// get extension - up to first non-digit other than comma or slash
for (j = 0, tok1 = ""; i < len; ++i, ++j) {
for (tok1 = ""; i < len; ++i) {
if (!s[i].isDigit() && s[i] != ',' && s[i] != '/')
break;
tok1[j] = s[i];
tok1.push_back(s[i]);
}
_extension = tok1;
if (_quality == "") {
Expand Down Expand Up @@ -789,11 +789,11 @@ bool ParsedChord::parse(const QString& s, const ChordList* cl, bool syntaxOnly,
_xmlParens = "yes";
}
// get first token - up to first digit, paren, or comma
for (j = 0, tok1 = "", tok1L = "", initial = ""; i < len; ++i, ++j) {
for (tok1 = "", tok1L = "", initial = ""; i < len; ++i) {
if (s[i].isDigit() || special.contains(s[i]))
break;
tok1[j] = s[i];
tok1L[j] = s[i].toLower();
tok1.push_back(s[i]);
tok1L.push_back(s[i].toLower());
if (mod2.contains(tok1L))
initial = tok1;
}
Expand All @@ -820,12 +820,12 @@ bool ParsedChord::parse(const QString& s, const ChordList* cl, bool syntaxOnly,
while (i < len && s[i] == ' ')
++i;
// get second token - a number <= 13
for (j = 0, tok2 = ""; i < len; ++i) {
for (tok2 = ""; i < len; ++i) {
if (!s[i].isDigit())
break;
if (j == 1 && (tok2[0] != '1' || s[i] > '3'))
if (tok2.size() == 1 && (tok2[0] != '1' || s[i] > '3'))
break;
tok2[j++] = s[i];
tok2.push_back(s[i]);
}
tok2L = tok2.toLower();
// re-attach "add"
Expand Down

1 comment on commit 5a03ffe

@lvinken
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I correct in assuming the fixes issue #312946 ?

Please sign in to comment.