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:
Robin Gareus 2025-08-02 02:24:45 +02:00
parent c8540a5ad6
commit 96431aa0d6
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
3 changed files with 16 additions and 0 deletions

View file

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

View file

@ -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 ()
{

View file

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