Skip to content

Commit

Permalink
Fix #317425: Corruption/crash after repeating a 256th note or smaller.
Browse files Browse the repository at this point in the history
Resolves: https://musescore.org/en/node/317425.

In the MIME data for a StaffList, the starting tick and tick length are encoded as integers, which is not sufficient when dealing with durations shorter than 1/128th. But there is really no reason for this, since ticks are stored internally as Fractions, and Fractions can be converted to and from strings without any loss in precision.
  • Loading branch information
mattmcclinch committed Feb 12, 2021
1 parent 84f6aa7 commit 476a7dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions libmscore/paste.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ bool Score::pasteStaff(XmlReader& e, Segment* dst, int dstStaff, Fraction scale)
break;
}
}
Fraction tickStart = Fraction::fromTicks(e.intAttribute("tick", 0));
tickLen = Fraction::fromTicks(e.intAttribute("len", 0));
Fraction tickStart = Fraction::fromString(e.attribute("tick", "0"));
tickLen = Fraction::fromString(e.attribute("len", "0"));
Fraction oTickLen = tickLen;
tickLen *= scale;
int staffStart = e.intAttribute("staff", 0);
Expand Down
4 changes: 2 additions & 2 deletions libmscore/select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,10 +813,10 @@ QByteArray Selection::staffMimeData() const
Fraction ticks = tickEnd() - tickStart();
int staves = staffEnd() - staffStart();
if (!MScore::testMode) {
xml.stag(QString("StaffList version=\"" MSC_VERSION "\" tick=\"%1\" len=\"%2\" staff=\"%3\" staves=\"%4\"").arg(tickStart().ticks()).arg(ticks.ticks()).arg(staffStart()).arg(staves));
xml.stag(QString("StaffList version=\"" MSC_VERSION "\" tick=\"%1\" len=\"%2\" staff=\"%3\" staves=\"%4\"").arg(tickStart().toString()).arg(ticks.toString()).arg(staffStart()).arg(staves));
}
else {
xml.stag(QString("StaffList version=\"2.00\" tick=\"%1\" len=\"%2\" staff=\"%3\" staves=\"%4\"").arg(tickStart().ticks()).arg(ticks.ticks()).arg(staffStart()).arg(staves));
xml.stag(QString("StaffList version=\"2.00\" tick=\"%1\" len=\"%2\" staff=\"%3\" staves=\"%4\"").arg(tickStart().toString()).arg(ticks.toString()).arg(staffStart()).arg(staves));
}
Segment* seg1 = _startSegment;
Segment* seg2 = _endSegment;
Expand Down

0 comments on commit 476a7dc

Please sign in to comment.