Skip to content

Commit

Permalink
Fix GH#19082: Write location before spanner end on score end
Browse files Browse the repository at this point in the history
Backport of musescore#20107
  • Loading branch information
miiizen authored and Jojo-Schmitz committed Nov 22, 2023
1 parent 8035c16 commit be80549
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions libmscore/spanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,26 @@ void Spanner::writeSpannerStart(XmlWriter& xml, const Element* current, int trac
void Spanner::writeSpannerEnd(XmlWriter& xml, const Element* current, int track, Fraction tick) const
{
Fraction frac = fraction(xml, current, tick);
if (frac == score()->endTick()) {
// Write a location tag if the spanner ends on the last tick of the score
Location spannerEndLoc = Location::absolute();
spannerEndLoc.setFrac(frac);
spannerEndLoc.setMeasure(0);
spannerEndLoc.setTrack(track);
spannerEndLoc.setVoice(track2voice(track));
spannerEndLoc.setStaff(staffIdx());

Location prevLoc = Location::absolute();
prevLoc.setFrac(xml.curTick());
prevLoc.setMeasure(0);
prevLoc.setTrack(track);
prevLoc.setVoice(track2voice(track));
prevLoc.setStaff(staffIdx());

spannerEndLoc.toRelative(prevLoc);
if (spannerEndLoc.frac() != Fraction(0, 1))
spannerEndLoc.write(xml);
}
SpannerWriter w(xml, current, this, track, frac, false);
w.write();
}
Expand Down

0 comments on commit be80549

Please sign in to comment.