Fix #9961, update saved port-name references when renaming ports
Since internal connections are saved by port-name, renaming a port also needs to update references that other ports have.
This commit is contained in:
@@ -135,6 +135,8 @@ public:
|
||||
uint32_t externally_connected () const { return _externally_connected; }
|
||||
uint32_t internally_connected () const { return _internally_connected; }
|
||||
|
||||
void rename_connected_port (std::string const&, std::string const&);
|
||||
|
||||
void increment_external_connections ();
|
||||
void decrement_external_connections ();
|
||||
|
||||
|
||||
@@ -224,6 +224,17 @@ Port::erase_connection (std::string const& pn)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Port::rename_connected_port (std::string const& old_name, std::string const& new_name)
|
||||
{
|
||||
Glib::Threads::RWLock::WriterLock lm (_connections_lock);
|
||||
if (_int_connections.find (old_name) == _int_connections.end()) {
|
||||
return;
|
||||
}
|
||||
_int_connections.erase (old_name);
|
||||
_int_connections.insert (new_name);
|
||||
}
|
||||
|
||||
void
|
||||
Port::increment_external_connections ()
|
||||
{
|
||||
|
||||
@@ -551,6 +551,9 @@ PortManager::port_renamed (const std::string& old_relative_name, const std::stri
|
||||
if (x != p->end ()) {
|
||||
std::shared_ptr<Port> port = x->second;
|
||||
p->erase (x);
|
||||
for (auto& [pn, pt] : *p) {
|
||||
pt->rename_connected_port (old_relative_name, new_relative_name);
|
||||
}
|
||||
p->insert (make_pair (new_relative_name, port));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user