summaryrefslogtreecommitdiff
path: root/libs/ardour/location.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2011-05-05 12:09:37 +0000
committerCarl Hetherington <carl@carlh.net>2011-05-05 12:09:37 +0000
commitae91577f2c34119d07be11cc03d99483eeb5d4e6 (patch)
tree551f6ae2a2cac1849f06f93dc72e7e09ea001b3e /libs/ardour/location.cc
parent35eecc59162846d39e52aa80c284e6ffecfea926 (diff)
Re-use locations when setting location list state, so that selected locations are preserved through an undo (#3929).
git-svn-id: svn://localhost/ardour2/branches/3.0@9480 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/location.cc')
-rw-r--r--libs/ardour/location.cc28
1 files changed, 24 insertions, 4 deletions
diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc
index 4f90b32282..086b6ed0c8 100644
--- a/libs/ardour/location.cc
+++ b/libs/ardour/location.cc
@@ -801,13 +801,15 @@ Locations::set_state (const XMLNode& node, int version)
XMLNodeList nlist = node.children();
- locations.clear ();
+ /* build up a new locations list in here */
+ LocationList new_locations;
+
current_location = 0;
Location* session_range_location = 0;
if (version < 3000) {
session_range_location = new Location (_session, 0, 0, _("session"), Location::IsSessionRange);
- locations.push_back (session_range_location);
+ new_locations.push_back (session_range_location);
}
{
@@ -818,7 +820,23 @@ Locations::set_state (const XMLNode& node, int version)
try {
- Location *loc = new Location (_session, **niter);
+ XMLProperty const * prop_id = (*niter)->property ("id");
+ assert (prop_id);
+ PBD::ID id (prop_id->value ());
+
+ LocationList::const_iterator i = locations.begin();
+ while (i != locations.end () && (*i)->id() != id) {
+ ++i;
+ }
+
+ Location* loc;
+ if (i != locations.end()) {
+ /* we can re-use an old Location object */
+ loc = *i;
+ loc->set_state (**niter, version);
+ } else {
+ loc = new Location (_session, **niter);
+ }
bool add = true;
@@ -850,7 +868,7 @@ Locations::set_state (const XMLNode& node, int version)
}
if (add) {
- locations.push_back (loc);
+ new_locations.push_back (loc);
}
}
@@ -859,6 +877,8 @@ Locations::set_state (const XMLNode& node, int version)
}
}
+ locations = new_locations;
+
if (locations.size()) {
current_location = locations.front();
} else {