13
0

use Editor::reassociate_metric_markers() before performing edits on tempo map

The objects referenced by markers point to the copy of the map held by the per-thread ptr. But
the edits must be done on a writable copy of the map. ::reassociate_metric_markers() fixes
the references to use the writable copy, so that when we pass references to the objects in the map
to the writable copy, it will find them and modify them (rather then ones in the previous
generation of the tempo map)
This commit is contained in:
Paul Davis 2021-11-15 21:26:23 -07:00
parent d61fc1e871
commit fd5594f831

View File

@ -1501,12 +1501,12 @@ Editor::toggle_tempo_type ()
dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm); dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
if (tm) { if (tm) {
Temporal::TempoPoint & tempo = tm->tempo();
begin_reversible_command (_("set tempo to constant")); begin_reversible_command (_("set tempo to constant"));
TempoMap::SharedPtr tmap (TempoMap::write_copy()); TempoMap::SharedPtr tmap (TempoMap::write_copy());
reassociate_metric_markers (tmap); reassociate_metric_markers (tmap);
Temporal::TempoPoint & tempo = tm->tempo();
XMLNode &before = tmap->get_state(); XMLNode &before = tmap->get_state();
@ -1533,9 +1533,8 @@ Editor::toggle_tempo_clamped ()
TempoMap::SharedPtr tmap (TempoMap::write_copy()); TempoMap::SharedPtr tmap (TempoMap::write_copy());
XMLNode &before = tmap->get_state(); XMLNode &before = tmap->get_state();
Temporal::Tempo & tempo (tm->tempo());
reassociate_metric_markers (tmap); reassociate_metric_markers (tmap);
Temporal::Tempo & tempo (tm->tempo());
tempo.set_clamped (!tempo.clamped()); tempo.set_clamped (!tempo.clamped());
@ -1562,9 +1561,10 @@ Editor::ramp_to_next_tempo ()
XMLNode &before = tmap->get_state(); XMLNode &before = tmap->get_state();
reassociate_metric_markers (tmap); reassociate_metric_markers (tmap);
Temporal::TempoPoint & tempo (tm->tempo()); Temporal::TempoPoint & tempo (tm->tempo());
tmap->set_ramped (tempo, !tempo.ramped()); tmap->set_ramped (tempo, !tempo.ramped());
XMLNode &after = tmap->get_state(); XMLNode &after = tmap->get_state();
_session->add_command (new MementoCommand<Temporal::TempoMap> (new Temporal::TempoMap::MementoBinder(), &before, &after)); _session->add_command (new MementoCommand<Temporal::TempoMap> (new Temporal::TempoMap::MementoBinder(), &before, &after));
commit_reversible_command (); commit_reversible_command ();