summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-04-01 20:45:57 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2013-04-01 20:45:57 -0400
commit2da10afb6492815aa76e9b8bb771f09c10721991 (patch)
tree94585b3c9fff57fb83ca9090013db0170758ca73 /libs
parent851a3924955a52a220b9a811229abdb2e8c8315f (diff)
fix #5424: routes created from templates do not get names based on the user-supplied text from the add route dialog
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/session.h2
-rw-r--r--libs/ardour/session.cc33
2 files changed, 26 insertions, 9 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index f0a2fd1189..525faa4e13 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -195,7 +195,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
std::string new_audio_source_name (const std::string&, uint32_t nchans, uint32_t chan, bool destructive);
std::string new_midi_source_name (const std::string&);
std::string new_source_path_from_name (DataType type, const std::string&);
- RouteList new_route_from_template (uint32_t how_many, const std::string& template_path);
+ RouteList new_route_from_template (uint32_t how_many, const std::string& template_path, const std::string& name);
void process (pframes_t nframes);
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 0e03efa945..da1f9e9115 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -1598,7 +1598,7 @@ Session::find_route_name (string const & base, uint32_t& id, char* name, size_t
}
++id;
-
+
} while (id < (UINT_MAX-1));
return false;
@@ -2037,12 +2037,13 @@ Session::new_audio_route (int input_channels, int output_channels, RouteGroup* r
}
RouteList
-Session::new_route_from_template (uint32_t how_many, const std::string& template_path)
+Session::new_route_from_template (uint32_t how_many, const std::string& template_path, const std::string& name_base)
{
RouteList ret;
uint32_t control_id;
XMLTree tree;
uint32_t number = 0;
+ const uint32_t being_added = how_many;
if (!tree.read (template_path.c_str())) {
return ret;
@@ -2062,13 +2063,29 @@ Session::new_route_from_template (uint32_t how_many, const std::string& template
node_copy.remove_property_recursively (X_("id"));
try {
- string const route_name = node_copy.property(X_("name"))->value ();
-
- /* generate a new name by adding a number to the end of the template name */
char name[32];
- if (!find_route_name (route_name.c_str(), ++number, name, sizeof(name), true)) {
- fatal << _("Session: UINT_MAX routes? impossible!") << endmsg;
- /*NOTREACHED*/
+
+ if (!name_base.empty()) {
+
+ /* if we're adding more than one routes, force
+ * all the names of the new routes to be
+ * numbered, via the final parameter.
+ */
+
+ if (!find_route_name (name_base.c_str(), ++number, name, sizeof(name), (being_added > 1))) {
+ fatal << _("Session: UINT_MAX routes? impossible!") << endmsg;
+ /*NOTREACHDE*/
+ }
+
+ } else {
+
+ string const route_name = node_copy.property(X_("name"))->value ();
+
+ /* generate a new name by adding a number to the end of the template name */
+ if (!find_route_name (route_name.c_str(), ++number, name, sizeof(name), true)) {
+ fatal << _("Session: UINT_MAX routes? impossible!") << endmsg;
+ /*NOTREACHED*/
+ }
}
/* set this name in the XML description that we are about to use */