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".
This commit is contained in:
Robin Gareus 2018-08-06 19:52:51 +02:00
parent bdf8edc419
commit f4c1166651
2 changed files with 15 additions and 10 deletions

View File

@ -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);

View File

@ -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);
bool ret = (_input->set_name(name) && _output->set_name(name));
if (newname == name()) {
return true;
}
SessionObject::set_name (newname);
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.
*/