diff --git a/importexport/musicxml/importmxmlpass2.cpp b/importexport/musicxml/importmxmlpass2.cpp index cfb693fcc4f44..6c6b331b0d564 100644 --- a/importexport/musicxml/importmxmlpass2.cpp +++ b/importexport/musicxml/importmxmlpass2.cpp @@ -130,18 +130,19 @@ void MusicXmlLyricsExtend::addLyric(Lyrics* const lyric) // lastChordTicks //--------------------------------------------------------- -// find the duration of the chord starting at or after s in track and ending at tick +// find the duration of the chord starting at or after s and ending at tick -static Fraction lastChordTicks(const Segment* s, const int track, const Fraction& tick) +static Fraction lastChordTicks(const Segment* s, const Fraction& tick) { while (s && s->tick() < tick) { - Element* el = s->element(track); - if (el && el->isChordRest()) { - ChordRest* cr = static_cast(el); - if (cr->tick() + cr->actualTicks() == tick) - return cr->actualTicks(); + for (Element* el : s->elist()) { + if (el && el->isChordRest()) { + ChordRest* cr = static_cast(el); + if (cr->tick() + cr->actualTicks() == tick) + return cr->actualTicks(); + } } - s = s->nextCR(track, true); + s = s->nextCR(-1, true); } return Fraction(0,1); } @@ -163,7 +164,7 @@ void MusicXmlLyricsExtend::setExtend(const int no, const int track, const Fracti ChordRest* const par = static_cast(el); if ((no == -1 && par->track() == track) || (l->no() == no && track2staff(par->track()) == track2staff(track))) { - Fraction lct = lastChordTicks(l->segment(), track, tick); + Fraction lct = lastChordTicks(l->segment(), tick); if (lct > Fraction(0,1)) { // set lyric tick to the total length from the lyric note // plus all notes covered by the melisma minus the last note length