13
0

libtemporal: when removing tempos/meters/musictime points, remove them from TempoMap::_points also

This commit is contained in:
Paul Davis 2021-02-07 11:23:37 -07:00
parent 982ccec7ab
commit 388fa1b894
2 changed files with 23 additions and 1 deletions

View File

@ -903,6 +903,7 @@ TempoMap::remove_tempo (TempoPoint const & tp)
return; return;
} }
_tempos.erase (t); _tempos.erase (t);
remove_point (tp);
reset_starting_at (sc); reset_starting_at (sc);
} }
@ -972,14 +973,32 @@ TempoMap::remove_bartime (MusicTimePoint const & tp)
superclock_t sc (tp.sclock()); superclock_t sc (tp.sclock());
MusicTimes::iterator m; MusicTimes::iterator m;
for (m = _bartimes.begin(); m != _bartimes.end() && m->sclock() < tp.sclock(); ++m); for (m = _bartimes.begin(); m != _bartimes.end() && m->sclock() < tp.sclock(); ++m);
if (m->sclock() != tp.sclock()) { if (m->sclock() != tp.sclock()) {
/* error ... no tempo point at the time of tp */ /* error ... no music time point at the time of tp */
return; return;
} }
_bartimes.erase (m); _bartimes.erase (m);
remove_point (tp);
reset_starting_at (sc); reset_starting_at (sc);
} }
void
TempoMap::remove_point (Point const & point)
{
Points::iterator p;
Point const * tpp (&point);
for (p = _points.begin(); p != _points.end(); ++p) {
if (&(*p) == tpp) {
// XXX need to fix this leak delete tpp;
_points.erase (p);
break;
}
}
}
void void
TempoMap::reset_starting_at (superclock_t sc) TempoMap::reset_starting_at (superclock_t sc)
{ {
@ -1466,6 +1485,7 @@ TempoMap::remove_meter (MeterPoint const & mp)
return; return;
} }
_meters.erase (m); _meters.erase (m);
remove_point (mp);
reset_starting_at (sc); reset_starting_at (sc);
} }

View File

@ -850,6 +850,8 @@ class LIBTEMPORAL_API TempoMap : public PBD::StatefulDestructible
void reset_starting_at (superclock_t); void reset_starting_at (superclock_t);
void reset_starting_at (Beats const &); void reset_starting_at (Beats const &);
void remove_point (Point const &);
void copy_points (TempoMap const & other); void copy_points (TempoMap const & other);
}; };