summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2018-08-06 19:52:51 +0200
committerRobin Gareus <robin@gareus.org>2018-08-06 19:52:51 +0200
commitf4c11666519a6118aaa07c58762eb379b39345df (patch)
tree9e4daafc295d2552ffc094c641b7b0ed3b350a5e /libs/ardour
parentbdf8edc4198494505fb59f92ffc1aef9c1e2136f (diff)
Fix track rename oddity, don't skip over current name.
ensure_track_or_route_name() can produce the current name. This fixes the following issue: Create a two audio tracks. Their names are "Audio" and "Audio 1". Try to rename "Audio 1" to "Audio", its name becomes "Audio 2".
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/route.h2
-rw-r--r--libs/ardour/route.cc23
2 files changed, 15 insertions, 10 deletions
diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h
index d3a4a5d35f..152acf37e6 100644
--- a/libs/ardour/ardour/route.h
+++ b/libs/ardour/ardour/route.h
@@ -123,7 +123,7 @@ public:
bool active() const { return _active; }
void set_active (bool yn, void *);
- static std::string ensure_track_or_route_name(std::string, Session &);
+ std::string ensure_track_or_route_name (std::string) const;
std::string comment() { return _comment; }
void set_comment (std::string str, void *src);
diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc
index fba39744fa..8b60d68632 100644
--- a/libs/ardour/route.cc
+++ b/libs/ardour/route.cc
@@ -272,14 +272,14 @@ Route::~Route ()
}
string
-Route::ensure_track_or_route_name(string name, Session &session)
+Route::ensure_track_or_route_name (string newname) const
{
- string newname = name;
-
- while (!session.io_name_is_legal (newname)) {
+ while (!_session.io_name_is_legal (newname)) {
newname = bump_name_once (newname, ' ');
+ if (newname == name()) {
+ break;
+ }
}
-
return newname;
}
@@ -4212,10 +4212,15 @@ Route::set_name (const string& str)
return true;
}
- string name = Route::ensure_track_or_route_name (str, _session);
- SessionObject::set_name (name);
+ string newname = Route::ensure_track_or_route_name (str);
+
+ if (newname == name()) {
+ return true;
+ }
+
+ SessionObject::set_name (newname);
- bool ret = (_input->set_name(name) && _output->set_name(name));
+ bool ret = (_input->set_name(newname) && _output->set_name(newname));
if (ret) {
/* rename the main outs. Leave other IO processors
@@ -4225,7 +4230,7 @@ Route::set_name (const string& str)
*/
if (_main_outs) {
- if (_main_outs->set_name (name)) {
+ if (_main_outs->set_name (newname)) {
/* XXX returning false here is stupid because
we already changed the route name.
*/