diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2019-03-20 20:42:02 -0700 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2019-03-20 20:42:02 -0700 |
commit | df90dbd7bba983b0103e8e13d6642398bf7e170e (patch) | |
tree | 3d99eb7210e2a1f0dfa82a9eb90b9b39842a98bf /gtk2_ardour/duplicate_routes_dialog.cc | |
parent | 2c7b6328240ad8e551a05cb608b035c9e8c0cd16 (diff) |
sort track selection into presentation order before duplicating.
This ensures that new tracks appear in the correct order (#7549)
Diffstat (limited to 'gtk2_ardour/duplicate_routes_dialog.cc')
-rw-r--r-- | gtk2_ardour/duplicate_routes_dialog.cc | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/gtk2_ardour/duplicate_routes_dialog.cc b/gtk2_ardour/duplicate_routes_dialog.cc index 885bdcb221..0b6cc04c96 100644 --- a/gtk2_ardour/duplicate_routes_dialog.cc +++ b/gtk2_ardour/duplicate_routes_dialog.cc @@ -161,21 +161,35 @@ DuplicateRouteDialog::on_response (int response) TrackSelection tracks (PublicEditor::instance().get_selection().tracks); int err = 0; - for (TrackSelection::iterator t = tracks.begin(); t != tracks.end(); ++t) { + /* Track Selection should be sorted into presentation order before + * duplicating, so that new tracks appear in same order as the + * originals. + */ + + StripableList sl; + for (TrackSelection::iterator t = tracks.begin(); t != tracks.end(); ++t) { RouteUI* rui = dynamic_cast<RouteUI*> (*t); + sl.push_back (rui->route()); + } - if (!rui) { - /* some other type of timeaxis view, not a route */ + sl.sort (Stripable::Sorter()); + + for (StripableList::iterator s = sl.begin(); s != sl.end(); ++s) { + + boost::shared_ptr<Route> r; + + if ((r = boost::dynamic_pointer_cast<Route> (*s)) == 0) { + /* some other type of Stripable, not a route */ continue; } - if (rui->route()->is_master() || rui->route()->is_monitor()) { + if ((*s)->is_master() || (*s)->is_monitor()) { /* no option to duplicate these */ continue; } - XMLNode& state (rui->route()->get_state()); + XMLNode& state (r->get_state()); RouteList rl = _session->new_route_from_template (cnt, ARDOUR_UI::instance()->translate_order (insert_at()), state, std::string(), playlist_action); /* normally the state node would be added to a parent, and |