diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2009-07-04 18:22:45 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2009-07-04 18:22:45 +0000 |
commit | dcbd3fd33e2626b26dc240e419d94f5cb7f4330b (patch) | |
tree | 4b60197f737cc13697336c824c06b69702cb2a75 | |
parent | 28d25da2f07b241ee063dcd6fed66adb7a2c8d48 (diff) |
try to name/number new routes-from-templates to avoid colliding names if adding more than 1 at a time (mantis #2753)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@5322 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | libs/ardour/session.cc | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index ffa8eeb572..ef8d53b4bd 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2042,6 +2042,7 @@ Session::new_route_from_template (uint32_t how_many, const std::string& template RouteList ret; uint32_t control_id; XMLTree tree; + uint32_t number = 1; if (!tree.read (template_path.c_str())) { return ret; @@ -2057,30 +2058,25 @@ Session::new_route_from_template (uint32_t how_many, const std::string& template std::string node_name = IO::name_from_state (*node_copy.children().front()); - if (route_by_name (node_name) != 0) { - - /* generate a new name by adding a number to the end of the template name */ - - uint32_t number = 1; - - do { - snprintf (name, sizeof (name), "%s %" PRIu32, node_name.c_str(), number); - - number++; - - if (route_by_name (name) == 0) { - break; - } - - } while (number < UINT_MAX); - - if (number == UINT_MAX) { - fatal << _("Session: UINT_MAX routes? impossible!") << endmsg; - /*NOTREACHED*/ + /* generate a new name by adding a number to the end of the template name */ + + do { + snprintf (name, sizeof (name), "%s %" PRIu32, node_name.c_str(), number); + + number++; + + if (route_by_name (name) == 0) { + break; } - - IO::set_name_in_state (*node_copy.children().front(), name); + + } while (number < UINT_MAX); + + if (number == UINT_MAX) { + fatal << _("Session: UINT_MAX routes? impossible!") << endmsg; + /*NOTREACHED*/ } + + IO::set_name_in_state (*node_copy.children().front(), name); Track::zero_diskstream_id_in_xml (node_copy); |