diff options
author | nick_m <mainsbridge@gmail.com> | 2015-04-11 04:45:45 +1000 |
---|---|---|
committer | nick_m <mainsbridge@gmail.com> | 2015-04-11 04:45:45 +1000 |
commit | 5ce855157678de98cf78c241386ffbafe36f7368 (patch) | |
tree | b9720f62ac8f2fd223b81942148613057ee3cb47 /libs/ardour/location.cc | |
parent | 30d95bbb8c007bf4db96dff86eea9eff6c5eeab1 (diff) |
Fix dangling location on new location -> undo.
Diffstat (limited to 'libs/ardour/location.cc')
-rw-r--r-- | libs/ardour/location.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc index 2e9125126b..2c19ebd1e0 100644 --- a/libs/ardour/location.cc +++ b/libs/ardour/location.cc @@ -1113,6 +1113,30 @@ Locations::set_state (const XMLNode& node, int version) } } + /* We may have some unused locations in the old list. */ + for (LocationList::iterator i = locations.begin(); i != locations.end(); ) { + LocationList::iterator tmp = i; + ++tmp; + + LocationList::iterator n = new_locations.begin(); + bool found = false; + + while (n != new_locations.end ()) { + if ((*i)->id() == (*n)->id()) { + found = true; + break; + } + ++n; + } + + if (!found) { + delete *i; + locations.erase (i); + } + + i = tmp; + } + locations = new_locations; if (locations.size()) { |