mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-28 16:08:12 +01:00
when renaming redirects, scan all routes AND sends AND port inserts for the name to avoid JACK port duplicate names
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@6052 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
39a4068e36
commit
ccdd99afce
7 changed files with 61 additions and 9 deletions
|
|
@ -925,12 +925,24 @@ RedirectBox::rename_redirect (boost::shared_ptr<Redirect> redirect)
|
|||
case Gtk::RESPONSE_ACCEPT:
|
||||
name_prompter.get_result (result);
|
||||
if (result.length()) {
|
||||
if (_session.route_by_name (result)) {
|
||||
ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
|
||||
return;
|
||||
int tries = 0;
|
||||
string test = result;
|
||||
|
||||
while (tries < 100) {
|
||||
if (_session.io_name_is_legal (test)) {
|
||||
result = test;
|
||||
break;
|
||||
}
|
||||
tries++;
|
||||
test = string_compose ("%1-%2", result, tries);
|
||||
}
|
||||
|
||||
if (tries < 100) {
|
||||
redirect->set_name (result, this);
|
||||
} else {
|
||||
ARDOUR_UI::instance()->popup_error
|
||||
(string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
|
||||
}
|
||||
|
||||
redirect->set_name (result, this);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,6 +167,8 @@ class Route : public IO
|
|||
return *i;
|
||||
}
|
||||
}
|
||||
|
||||
bool has_io_redirect_named (const std::string&);
|
||||
|
||||
uint32_t max_redirect_outs () const { return redirect_max_outs; }
|
||||
|
||||
|
|
|
|||
|
|
@ -326,7 +326,9 @@ class Session : public PBD::StatefulDestructible
|
|||
template<class T> void foreach_route (T *obj, void (T::*func)(boost::shared_ptr<Route>));
|
||||
template<class T, class A> void foreach_route (T *obj, void (T::*func)(Route&, A), A arg);
|
||||
|
||||
boost::shared_ptr<Route> route_by_name (string);
|
||||
bool io_name_is_legal (const std::string&);
|
||||
|
||||
boost::shared_ptr<Route> route_by_name (const std::string&);
|
||||
boost::shared_ptr<Route> route_by_id (PBD::ID);
|
||||
boost::shared_ptr<Route> route_by_remote_id (uint32_t id);
|
||||
|
||||
|
|
|
|||
|
|
@ -2712,3 +2712,21 @@ Route::set_name (string str, void* src)
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
Route::has_io_redirect_named (const string& name)
|
||||
{
|
||||
Glib::RWLock::ReaderLock lm (redirect_lock);
|
||||
RedirectList::iterator i;
|
||||
|
||||
for (i = _redirects.begin(); i != _redirects.end(); ++i) {
|
||||
if (boost::dynamic_pointer_cast<Send> (*i) ||
|
||||
boost::dynamic_pointer_cast<PortInsert> (*i)) {
|
||||
if ((*i)->name() == name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2531,8 +2531,26 @@ Session::catch_up_on_solo_mute_override ()
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Session::io_name_is_legal (const std::string& name)
|
||||
{
|
||||
shared_ptr<RouteList> r = routes.reader ();
|
||||
|
||||
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
|
||||
if ((*i)->name() == name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((*i)->has_io_redirect_named (name)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
shared_ptr<Route>
|
||||
Session::route_by_name (string name)
|
||||
Session::route_by_name (const std::string& name)
|
||||
{
|
||||
shared_ptr<RouteList> r = routes.reader ();
|
||||
|
||||
|
|
|
|||
|
|
@ -570,7 +570,7 @@ UI::handle_fatal (const char *message)
|
|||
}
|
||||
|
||||
void
|
||||
UI::popup_error (const char *text)
|
||||
UI::popup_error (const std::string& text)
|
||||
{
|
||||
if (!caller_is_ui_thread()) {
|
||||
error << "non-UI threads can't use UI::popup_error"
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ class UI : public Receiver, public AbstractUI<UIRequest>
|
|||
void run (Receiver &old_receiver);
|
||||
|
||||
void set_state (Gtk::Widget *w, Gtk::StateType state);
|
||||
void popup_error (const char *text);
|
||||
void popup_error (const std::string&);
|
||||
void flush_pending ();
|
||||
void toggle_errors ();
|
||||
void touch_display (Touchable *);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue