Fix Duplicate Track with Copy Playlist option selected

Previously two new empty playlists were created.

Related to and mentioned in issue #7141
This commit is contained in:
Tim Mayberry 2016-11-28 12:30:38 +10:00
parent 8ddeca133b
commit e9eea8de9d
1 changed files with 12 additions and 23 deletions

View File

@ -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> 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> track;
if ((track = boost::dynamic_pointer_cast<Track> (route))) {
switch (pd) {
case NewPlaylist:
break;
case CopyPlaylist:
track->use_copy_playlist ();
break;
case SharePlaylist:
break;
}
};
ret.push_back (route);
}