Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion source/score/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,17 @@ SystemUtils::getSurroundingBarlines(const System &system, int position)
current_bar = system.getPreviousBarline(position);

const Barline *next_bar = system.getNextBarline(position);
assert(next_bar);

// If playback lands exactly on (or past) the system's end barline -- which
// can happen via repeats/directions/alternate endings -- there is no
// strictly-later barline. Fall back to the end barline for both; callers
// treat the empty [current, next) range as no events and advance to the
// next system. Likewise guard current_bar in case position precedes all
// barlines.
if (!next_bar)
next_bar = &system.getBarlines().back();
if (!current_bar)
current_bar = &system.getBarlines().front();

return { *current_bar, *next_bar };
}