From 6bc2261575be1689c3b187d4176292265737d44d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 9 Jan 2026 10:51:07 -0700 Subject: [PATCH] temporal: fix incorrect logic in TempoMap::fill_grid_by_walking() If walking the grid by bar, but points are closer than that, we could end up with the wrong TempoMetric being used to compute various time domain conversions (which tends to leads to abort()). This small change makes sure that we keep looking for more points if we have not yet reached the next grid point (e.g. bar). --- libs/temporal/tempo.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index 9a6a883532..23c18f3fc8 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -3140,6 +3140,8 @@ TempoMap::fill_grid_by_walking (TempoMapPoints& ret, Points::const_iterator& p_i DEBUG_TRACE (DEBUG::Grid, string_compose ("pre-check overrun of next point with bbt @ %1 audio %2 point %3\n", bbt, start, *p)); + find_next_point: + bool reset = false; if (!mtp) { @@ -3300,6 +3302,16 @@ TempoMap::fill_grid_by_walking (TempoMapPoints& ret, Points::const_iterator& p_i } + if (p != _points.end() && p->bbt() < bbt) { + /* We reached a point that didn't coincide with the one + we were looking at, but we have not yet reached the BBT + value for the next grid point. Go back and run the + "find next point" loop again. + */ + mtp = dynamic_cast (&*p); + goto find_next_point; + } + DEBUG_TRACE (DEBUG::Grid, string_compose ("reset done, bbt now at %1 with metric %2, get superclock\n", bbt, metric)); start = metric.superclock_at (bbt);