From bd3fdaeb6798736f93ae3bf915261b5b1c7d1418 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 23 May 2022 11:26:57 -0600 Subject: [PATCH] clean up editor's set_ramped() and set_continuing() code Now that the libardour methods return bool, we can identify whether or not any change actually took place, and act appropriately. --- gtk2_ardour/editor_markers.cc | 74 ++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 32 deletions(-) diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index 1d779384f4..66c934a9a4 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -1635,23 +1635,28 @@ Editor::toggle_tempo_continues () MeterMarker* mm; dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm); - if (tm) { - begin_reversible_command (_("Clamp Tempo")); - - TempoMap::WritableSharedPtr tmap (TempoMap::write_copy()); - XMLNode &before = tmap->get_state(); - - reassociate_metric_markers (tmap); - Temporal::Tempo const & tempo (tm->tempo()); - - const_cast(tempo).set_continuing (!tempo.continuing()); - - XMLNode &after = tmap->get_state(); - _session->add_command (new Temporal::TempoCommand (_("change tempo clamp"), &before, &after)); - commit_reversible_command (); - - TempoMap::update (tmap); + if (!tm) { + return; } + + TempoMap::WritableSharedPtr tmap (TempoMap::write_copy()); + XMLNode &before = tmap->get_state(); + + reassociate_metric_markers (tmap); + Temporal::TempoPoint const & tempo (tm->tempo()); + + if (!tmap->set_continuing (const_cast(tempo), !tempo.continuing())) { + abort_tempo_map_edit (); + return; + } + + begin_reversible_command (_("Change Tempo Continue Behavior")); + + XMLNode &after = tmap->get_state(); + _session->add_command (new Temporal::TempoCommand (_("change tempo clamp"), &before, &after)); + commit_reversible_command (); + + TempoMap::update (tmap); } void @@ -1662,23 +1667,28 @@ Editor::ramp_to_next_tempo () MeterMarker* mm; dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm); - if (tm) { - - begin_reversible_command (_("ramp to next tempo")); - TempoMap::WritableSharedPtr tmap (TempoMap::write_copy()); - XMLNode &before = tmap->get_state(); - - reassociate_metric_markers (tmap); - Temporal::TempoPoint const & tempo (tm->tempo()); - - tmap->set_ramped (const_cast(tempo), !tempo.ramped()); - - XMLNode &after = tmap->get_state(); - _session->add_command (new Temporal::TempoCommand (_("changed tempo ramp"), &before, &after)); - commit_reversible_command (); - - TempoMap::update (tmap); + if (!tm) { + return; } + + TempoMap::WritableSharedPtr tmap (TempoMap::write_copy()); + XMLNode &before = tmap->get_state(); + + reassociate_metric_markers (tmap); + Temporal::TempoPoint const & tempo (tm->tempo()); + + if (!tmap->set_ramped (const_cast(tempo), !tempo.ramped())) { + abort_tempo_map_edit (); + return; + } + + begin_reversible_command (_("ramp to next tempo")); + + XMLNode &after = tmap->get_state(); + _session->add_command (new Temporal::TempoCommand (_("changed tempo ramp"), &before, &after)); + commit_reversible_command (); + + TempoMap::update (tmap); } void