From 388fa1b894294c7a08e00da72bc0a0b527325d85 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 7 Feb 2021 11:23:37 -0700 Subject: [PATCH] libtemporal: when removing tempos/meters/musictime points, remove them from TempoMap::_points also --- libs/temporal/tempo.cc | 22 +++++++++++++++++++++- libs/temporal/temporal/tempo.h | 2 ++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index ab562b315d..ffa814df8e 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -903,6 +903,7 @@ TempoMap::remove_tempo (TempoPoint const & tp) return; } _tempos.erase (t); + remove_point (tp); reset_starting_at (sc); } @@ -972,14 +973,32 @@ TempoMap::remove_bartime (MusicTimePoint const & tp) superclock_t sc (tp.sclock()); MusicTimes::iterator m; for (m = _bartimes.begin(); m != _bartimes.end() && m->sclock() < tp.sclock(); ++m); + 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; } + _bartimes.erase (m); + remove_point (tp); 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 TempoMap::reset_starting_at (superclock_t sc) { @@ -1466,6 +1485,7 @@ TempoMap::remove_meter (MeterPoint const & mp) return; } _meters.erase (m); + remove_point (mp); reset_starting_at (sc); } diff --git a/libs/temporal/temporal/tempo.h b/libs/temporal/temporal/tempo.h index a0fb693303..249270c0a9 100644 --- a/libs/temporal/temporal/tempo.h +++ b/libs/temporal/temporal/tempo.h @@ -850,6 +850,8 @@ class LIBTEMPORAL_API TempoMap : public PBD::StatefulDestructible void reset_starting_at (superclock_t); void reset_starting_at (Beats const &); + void remove_point (Point const &); + void copy_points (TempoMap const & other); };