mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 15:25:01 +01:00
Consistently replace colons in IO/Port names
This fixes an issue when creating tracks or busses with a colon in the name. Renaming those tracks later IO::set_name() crashed in current_name.replace(std::string::npos,..). `IO::build_legal_port_name` uses ";" instead of ":" while `IO::set_name` replaced it with a "-". Initially the IO name included the colon, so ports created use a semicolon. But after renaming the IO, ::set_name() applies the replacement and the IO's name is changed to include the "-". This leads to a conflict with ports that already have the semicolon in the port-name.
This commit is contained in:
parent
85f640c31a
commit
62aae6cffb
1 changed files with 10 additions and 4 deletions
|
|
@ -65,11 +65,18 @@ using namespace PBD;
|
||||||
const string IO::state_node_name = "IO";
|
const string IO::state_node_name = "IO";
|
||||||
PBD::Signal1<void,ChanCount> IO::PortCountChanged;
|
PBD::Signal1<void,ChanCount> IO::PortCountChanged;
|
||||||
|
|
||||||
|
static std::string
|
||||||
|
legalize_io_name (std::string n)
|
||||||
|
{
|
||||||
|
replace_all (n, ":", "-");
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
/** @param default_type The type of port that will be created by ensure_io
|
/** @param default_type The type of port that will be created by ensure_io
|
||||||
* and friends if no type is explicitly requested (to avoid breakage).
|
* and friends if no type is explicitly requested (to avoid breakage).
|
||||||
*/
|
*/
|
||||||
IO::IO (Session& s, const string& name, Direction dir, DataType default_type, bool sendish)
|
IO::IO (Session& s, const string& name, Direction dir, DataType default_type, bool sendish)
|
||||||
: SessionObject (s, name)
|
: SessionObject (s, legalize_io_name (name))
|
||||||
, _direction (dir)
|
, _direction (dir)
|
||||||
, _default_type (default_type)
|
, _default_type (default_type)
|
||||||
, _sendish (sendish)
|
, _sendish (sendish)
|
||||||
|
|
@ -1137,7 +1144,7 @@ IO::set_name (const string& requested_name)
|
||||||
|
|
||||||
/* replace all colons in the name. i wish we didn't have to do this */
|
/* replace all colons in the name. i wish we didn't have to do this */
|
||||||
|
|
||||||
replace_all (name, ":", "-");
|
name = legalize_io_name (name);
|
||||||
|
|
||||||
for (PortSet::iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
for (PortSet::iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
||||||
string current_name = i->name();
|
string current_name = i->name();
|
||||||
|
|
@ -1402,8 +1409,7 @@ IO::build_legal_port_name (DataType type)
|
||||||
|
|
||||||
/* colons are illegal in port names, so fix that */
|
/* colons are illegal in port names, so fix that */
|
||||||
|
|
||||||
string nom = _name.val();
|
string nom = legalize_io_name (_name.val());
|
||||||
replace_all (nom, ":", ";");
|
|
||||||
|
|
||||||
snprintf (&buf1[0], name_size+1, ("%.*s/%s"), limit, nom.c_str(), suffix.c_str());
|
snprintf (&buf1[0], name_size+1, ("%.*s/%s"), limit, nom.c_str(), suffix.c_str());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue