keep portmap & portindex in sync when renaming ports

Fixes crash on session re-load (introduced in 800c8182 and fde99e68)
This commit is contained in:
Robin Gareus 2016-04-26 02:26:20 +02:00
parent 11a69068af
commit 2169de3975
3 changed files with 36 additions and 4 deletions

View File

@ -1210,11 +1210,20 @@ AlsaAudioBackend::port_name_size () const
int
AlsaAudioBackend::set_port_name (PortEngine::PortHandle port, const std::string& name)
{
std::string newname (_instance_name + ":" + name);
if (!valid_port (port)) {
PBD::error << _("AlsaBackend::set_port_name: Invalid Port(s)") << endmsg;
PBD::error << _("AlsaBackend::set_port_name: Invalid Port") << endmsg;
return -1;
}
return static_cast<AlsaPort*>(port)->set_name (_instance_name + ":" + name);
if (find_port (newname)) {
PBD::error << _("AlsaBackend::set_port_name: Port with given name already exists") << endmsg;
return -1;
}
AlsaPort* p = static_cast<AlsaPort*>(port);
_portmap.erase (p->name());
_portmap.insert (make_pair (newname, p));
return p->set_name (newname);
}
std::string

View File

@ -902,11 +902,20 @@ CoreAudioBackend::port_name_size () const
int
CoreAudioBackend::set_port_name (PortEngine::PortHandle port, const std::string& name)
{
std::string newname (_instance_name + ":" + name);
if (!valid_port (port)) {
PBD::warning << _("CoreAudioBackend::set_port_name: Invalid Port(s)") << endmsg;
return -1;
}
return static_cast<CoreBackendPort*>(port)->set_name (_instance_name + ":" + name);
if (find_port (newname)) {
PBD::error << _("CoreAudioBackend::set_port_name: Port with given name already exists") << endmsg;
return -1;
}
CoreBackendPort* p = static_cast<CoreBackendPort*>(port);
_portmap.erase (p->name());
_portmap.insert (make_pair (newname, p));
return p->set_name (newname);
}
std::string

View File

@ -432,6 +432,9 @@ DummyAudioBackend::_start (bool /*for_latency_measurement*/)
for (PortIndex::const_iterator it = _ports.begin (); it != _ports.end (); ++it) {
PBD::info << _("DummyAudioBackend: port '") << (*it)->name () << "' exists." << endmsg;
}
for (PortMap::const_iterator it = _portmap.begin (); it != _portmap.end (); ++it) {
PBD::info << _("DummyAudioBackend: portmap '") << (*it).first << "' exists." << endmsg;
}
_system_inputs.clear();
_system_outputs.clear();
_system_midi_in.clear();
@ -643,11 +646,22 @@ DummyAudioBackend::port_name_size () const
int
DummyAudioBackend::set_port_name (PortEngine::PortHandle port, const std::string& name)
{
std::string newname (_instance_name + ":" + name);
if (!valid_port (port)) {
PBD::error << _("DummyBackend::set_port_name: Invalid Port(s)") << endmsg;
return -1;
}
return static_cast<DummyPort*>(port)->set_name (_instance_name + ":" + name);
if (find_port (newname)) {
PBD::error << _("DummyBackend::set_port_name: Port with given name already exists") << endmsg;
return -1;
}
DummyPort* p = static_cast<DummyPort*>(port);
_portmap.erase (p->name());
_portmap.insert (make_pair (newname, p));
return p->set_name (newname);
}
std::string