From 3a2f0e40cfed091876a899afaa24582e60a8f024 Mon Sep 17 00:00:00 2001 From: Johannes Mueller Date: Sun, 5 Apr 2020 18:55:09 +0200 Subject: [PATCH] Fix crash when adding tracks from a5 route templates Ardour5 route templates seem not to have a in the root node playlist property. Ardour generally relies on that Track::playlist() always returns a valid playlist. Thus we need to create a playlist even if we don't have a playlist property in the route template's root node. --- libs/ardour/session.cc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 5510f738ce..a052727067 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2893,6 +2893,14 @@ Session::new_route_from_template (uint32_t how_many, PresentationInfo::order_t i Stateful::ForceIDRegeneration force_ids; IO::disable_connecting (); + /* New v6 templates do have a version in the Route-Template, + * we assume that all older, unversioned templates are + * from Ardour 5.x + * when Stateful::loading_state_version was 3002 + */ + int version = 3002; + node.get_property (X_("version"), version); + while (how_many) { /* We're going to modify the node contents a bit so take a @@ -2967,13 +2975,15 @@ Session::new_route_from_template (uint32_t how_many, PresentationInfo::order_t i } else { /* NewPlaylist */ PBD::ID pid; + std::string default_type; + node.get_property(X_("default-type"), default_type); - if (node_copy.get_property (X_("audio-playlist"), pid)) { + if (node_copy.get_property (X_("audio-playlist"), pid) || (version < 5000 && default_type == "audio")) { boost::shared_ptr playlist = PlaylistFactory::create (DataType::AUDIO, *this, name, false); node_copy.set_property (X_("audio-playlist"), playlist->id()); } - if (node_copy.get_property (X_("midi-playlist"), pid)) { + if (node_copy.get_property (X_("midi-playlist"), pid) || (version < 5000 && default_type == "midi")) { boost::shared_ptr playlist = PlaylistFactory::create (DataType::MIDI, *this, name, false); node_copy.set_property (X_("midi-playlist"), playlist->id()); } @@ -3045,14 +3055,6 @@ Session::new_route_from_template (uint32_t how_many, PresentationInfo::order_t i */ node_copy.remove_node_and_delete (X_("Controllable"), X_("name"), X_("solo")); - /* New v6 templates do have a version in the Route-Template, - * we assume that all older, unversioned templates are - * from Ardour 5.x - * when Stateful::loading_state_version was 3002 - */ - int version = 3002; - node.get_property (X_("version"), version); - boost::shared_ptr route; if (version < 3000) {