From b6b1aec50e0fdbfe72eddf9744effcb25d8a4dd7 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 15 May 2023 19:26:17 +0200 Subject: [PATCH] Fix selection after region duplicate (amend cfca2d2a) --- gtk2_ardour/editor_ops.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index d9ab4eae51..de78a0c8ff 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -5315,6 +5315,7 @@ Editor::duplicate_some_regions (RegionSelection& regions, float times) return; } + std::vector cl; std::shared_ptr playlist; PlaylistSet playlists; // list of unique playlists affected by duplication RegionSelection sel = regions; // clear (below) may clear the argument list if its the current region selection @@ -5358,8 +5359,7 @@ Editor::duplicate_some_regions (RegionSelection& regions, float times) TimeAxisView& tv = (*i)->get_time_axis_view(); RouteTimeAxisView* rtv = dynamic_cast (&tv); - latest_regionviews.clear (); - sigc::connection c = rtv->view()->RegionViewAdded.connect (sigc::mem_fun(*this, &Editor::collect_new_region_view)); + cl.push_back (rtv->view()->RegionViewAdded.connect (sigc::mem_fun(*this, &Editor::collect_new_region_view))); /* XXX problem arew here. When duplicating audio regions, the * next one must be positioned 1 sample after the end of the @@ -5390,14 +5390,17 @@ Editor::duplicate_some_regions (RegionSelection& regions, float times) playlist->duplicate (r, position, span, times); - c.disconnect (); - - foo.insert (foo.end(), latest_regionviews.begin(), latest_regionviews.end()); } for (PlaylistSet::iterator p = playlists.begin(); p != playlists.end(); ++p) { + latest_regionviews.clear (); (*p)->thaw (); (*p)->rdiff_and_add_command (_session); + foo.insert (foo.end(), latest_regionviews.begin(), latest_regionviews.end()); + } + + for (auto& c: cl) { + c.disconnect (); } if (!foo.empty()) {