summaryrefslogtreecommitdiff
path: root/libs/ardour/send.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-11-19 13:41:34 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-11-19 13:41:34 +0000
commit281d6c1bbd432dec79a83b6a00ae5175cf995ae2 (patch)
tree6ed3fcb295bb2781abdd4c1d7240dc0b6c8f2c14 /libs/ardour/send.cc
parentbd064938c4e811a552d9296bfacb03fbdebcf854 (diff)
maintain send names across session save/restore
git-svn-id: svn://localhost/ardour2/branches/3.0@6131 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/send.cc')
-rw-r--r--libs/ardour/send.cc24
1 files changed, 19 insertions, 5 deletions
diff --git a/libs/ardour/send.cc b/libs/ardour/send.cc
index d2c1d3c493..b0d66e01ba 100644
--- a/libs/ardour/send.cc
+++ b/libs/ardour/send.cc
@@ -17,6 +17,7 @@
*/
+#include <iostream>
#include <algorithm>
#include "pbd/xml++.h"
@@ -35,6 +36,7 @@
using namespace ARDOUR;
using namespace PBD;
+using namespace std;
Send::Send (Session& s, boost::shared_ptr<MuteMaster> mm, Role r)
: Delivery (s, mm, string_compose (_("send %1"), (_bitslot = s.next_send_id()) + 1), r)
@@ -212,7 +214,7 @@ Send::make_unique (XMLNode &state, Session &session)
snprintf (buf, sizeof (buf), "%" PRIu32, bitslot);
state.property("bitslot")->set_value (buf);
- std::string const name = string_compose (_("send %1"), bitslot);
+ string const name = string_compose (_("send %1"), bitslot);
state.property("name")->set_value (name);
@@ -224,15 +226,27 @@ Send::make_unique (XMLNode &state, Session &session)
}
bool
-Send::set_name (const std::string& new_name)
+Send::set_name (const string& new_name)
{
- std::string unique_name;
+ string unique_name;
if (_role == Delivery::Send) {
char buf[32];
- snprintf (buf, sizeof (buf), "%u", _bitslot);
- unique_name = new_name;
+
+ /* rip any existing numeric part of the name, and append the bitslot
+ */
+
+ string::size_type last_letter = new_name.find_last_not_of ("0123456789");
+
+ if (last_letter != string::npos) {
+ unique_name = new_name.substr (0, last_letter + 1);
+ } else {
+ unique_name = new_name;
+ }
+
+ snprintf (buf, sizeof (buf), "%u", (_bitslot + 1));
unique_name += buf;
+
} else {
unique_name = new_name;
}