From 2cfc013b0cb7b76e7cf0448694dff2e3076f1a20 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 16 Jun 2022 10:18:32 -0600 Subject: [PATCH] temporal: fix loading tempo map from XML We need to clear out all 4 intrusive lists before we start, not just the 3 typed ones --- libs/temporal/tempo.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index 9411b6d390..119186dbe2 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -2462,6 +2462,15 @@ TempoMap::set_state (XMLNode const & node, int version) XMLNodeList const & children (node.children()); + /* XXX might be good to have a recovery mechanism in case setting + * things from XML fails. Not very likely, however. + */ + + _tempos.clear (); + _meters.clear (); + _bartimes.clear (); + _points.clear (); + for (XMLNodeList::const_iterator c = children.begin(); c != children.end(); ++c) { if ((*c)->name() == X_("Tempos")) { if (set_tempos_from_state (**c)) { @@ -2494,7 +2503,6 @@ TempoMap::set_music_times_from_state (XMLNode const& mt_node) XMLNodeList const & children (mt_node.children()); try { - _bartimes.clear (); for (XMLNodeList::const_iterator c = children.begin(); c != children.end(); ++c) { MusicTimePoint* mp = new MusicTimePoint (*this, **c); add_or_replace_bartime (mp); @@ -2514,11 +2522,16 @@ TempoMap::set_tempos_from_state (XMLNode const& tempos_node) bool ignore; try { - _tempos.clear (); + std::cerr << " before adding tempo, map is\n"; + dump (std::cerr); + for (XMLNodeList::const_iterator c = children.begin(); c != children.end(); ++c) { TempoPoint* tp = new TempoPoint (*this, **c); core_add_tempo (tp, ignore); core_add_point (tp); + + std::cerr << "Added a tempo " << *tp << " map now\n"; + dump (std::cerr); } } catch (...) { _tempos.clear (); /* remove any that were created */ @@ -2535,7 +2548,6 @@ TempoMap::set_meters_from_state (XMLNode const& meters_node) bool ignore; try { - _meters.clear (); for (XMLNodeList::const_iterator c = children.begin(); c != children.end(); ++c) { MeterPoint* mp = new MeterPoint (*this, **c); core_add_meter (mp, ignore);