From e9eea8de9d13b43ad236e5f1623c1139311f5f1b Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Mon, 28 Nov 2016 12:30:38 +1000 Subject: Fix Duplicate Track with Copy Playlist option selected Previously two new empty playlists were created. Related to and mentioned in issue #7141 --- libs/ardour/session.cc | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'libs') diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 127367483b..06d19672b9 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -81,6 +81,7 @@ #include "ardour/midi_ui.h" #include "ardour/operations.h" #include "ardour/playlist.h" +#include "ardour/playlist_factory.h" #include "ardour/plugin.h" #include "ardour/plugin_insert.h" #include "ardour/process_thread.h" @@ -3240,17 +3241,19 @@ Session::new_route_from_template (uint32_t how_many, PresentationInfo::order_t i /* set this name in the XML description that we are about to use */ - bool rename_playlist; - switch (pd) { - case NewPlaylist: - case CopyPlaylist: - rename_playlist = true; - break; - default: - case SharePlaylist: - rename_playlist = false; + if (pd == CopyPlaylist) { + XMLNode* ds_node = find_named_node (node_copy, "Diskstream"); + if (ds_node) { + const std::string playlist_name = ds_node->property (X_("playlist"))->value (); + boost::shared_ptr playlist = playlists->by_name (playlist_name); + // Use same name as Route::set_name_in_state so playlist copy + // is picked up when creating the Route in XMLRouteFactory below + PlaylistFactory::create (playlist, string_compose ("%1.1", name)); + } } + bool rename_playlist = (pd == CopyPlaylist || pd == NewPlaylist); + Route::set_name_in_state (node_copy, name, rename_playlist); /* trim bitslots from listen sends so that new ones are used */ @@ -3328,20 +3331,6 @@ Session::new_route_from_template (uint32_t how_many, PresentationInfo::order_t i route->output()->changed (change, this); } - boost::shared_ptr track; - - if ((track = boost::dynamic_pointer_cast (route))) { - switch (pd) { - case NewPlaylist: - break; - case CopyPlaylist: - track->use_copy_playlist (); - break; - case SharePlaylist: - break; - } - }; - ret.push_back (route); } -- cgit v1.2.3