From cdf98a1bd7cff14dcbeacf6c98a77ebd1ad94807 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 16 Jun 2022 22:09:53 -0600 Subject: [PATCH] tempo display: when the tempo map changes, avoid unnecessary work If the initial tempo marker is referencing a point in the new map, assume that all markers have already been associated with the map. --- gtk2_ardour/editor_tempodisplay.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc index ec96466293..7c0e806363 100644 --- a/gtk2_ardour/editor_tempodisplay.cc +++ b/gtk2_ardour/editor_tempodisplay.cc @@ -450,6 +450,24 @@ Editor::tempo_map_changed () { TempoMap::SharedPtr current_map = TempoMap::fetch (); reassociate_metric_markers (current_map); + /* If the tempo map was changed by something other than the Editor, we + * will need to reassociate all visual elements used for tempo display + * with the new map. + */ + + if (!tempo_marks.empty()) { + /* a little awkward using shared_ptr::get() but better than every + * point in the map holding a shared_ptr ref to the map that owns it. + */ + + if (&tempo_marks.front()->point().map() != current_map.get()) { + std::cerr << "Map changed, need marker reassoc; point using " << &tempo_marks.front()->point().map() << " vs. " << current_map.get() << std::endl; + reassociate_metric_markers (current_map); + } else { + std::cerr << "Map changed, no reassoc reqd\n"; + } + } + tempo_map_visual_update (); }