Fix handling of codas

This commit is contained in:
Matthias Neeracher 2011-09-04 22:21:58 +02:00
parent 273ee8ee73
commit 8eaa0fb1a5

View File

@ -1756,8 +1756,8 @@ VLSong::iterator::iterator(const VLSong & song, bool end)
bool repeat;
fMeasure = 0;
if (fSong.fCoda > 0
&& !fSong.DoesEndRepeat(fMeasure)
&& !fSong.DoesEndEnding(fMeasure, &repeat)
&& !fSong.DoesEndRepeat(fSong.fCoda)
&& !fSong.DoesEndEnding(fSong.fCoda, &repeat)
)
fStatus.push_back(Repeat(fMeasure, 2));
AdjustStatus();
@ -1791,12 +1791,17 @@ void VLSong::iterator::AdjustStatus()
} else if (!repeat) {
fStatus.pop_back();
}
if (fSong.fCoda > 0 && fMeasure==fSong.fGoToCoda)
if (fStatus.size() && fStatus.back().fVolta == fStatus.back().fTimes-1) {
fMeasure = fSong.fCoda;
if (fSong.fCoda > 0 && fMeasure==fSong.fGoToCoda) {
for (size_t repeat = 0; repeat < fStatus.size(); ++repeat)
if (fStatus[repeat].fVolta != fStatus[repeat].fTimes-1)
goto notAtCoda;
fStatus.clear();
fMeasure = fSong.fCoda;
return;
}
return;
notAtCoda:
;
}
if (fMeasure == fSong.CountMeasures()-fSong.EmptyEnding()
|| (fSong.fCoda > 0 && fMeasure == fSong.fCoda)
)