diff options
author | Robin Gareus <robin@gareus.org> | 2014-10-10 14:12:48 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2014-10-10 14:12:48 +0200 |
commit | 472900f4ffee3cd0faaa8ac54ba05dd3538c7922 (patch) | |
tree | d383a569b1909316185ae71a14d9af854a1d8e27 /libs | |
parent | 5b25dbba03bf0dce9e43f49748f9ce96ced3d37a (diff) |
cleanup unused nested regions:
This and two previous commits fixes #5979
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/session_state.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index bb39a03b09..538c408abb 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -96,6 +96,7 @@ #include "ardour/midi_track.h" #include "ardour/pannable.h" #include "ardour/playlist_factory.h" +#include "ardour/playlist_source.h" #include "ardour/port.h" #include "ardour/processor.h" #include "ardour/proxy_controllable.h" @@ -2611,6 +2612,7 @@ Session::ask_about_playlist_deletion (boost::shared_ptr<Playlist> p) void Session::cleanup_regions () { + bool removed = false; const RegionFactory::RegionMap& regions (RegionFactory::regions()); for (RegionFactory::RegionMap::const_iterator i = regions.begin(); i != regions.end(); ++i) { @@ -2618,10 +2620,24 @@ Session::cleanup_regions () uint32_t used = playlists->region_use_count (i->second); if (used == 0 && !i->second->automatic ()) { + removed = true; RegionFactory::map_remove (i->second); } } + if (removed) { + // re-check to remove parent references of compound regions + for (RegionFactory::RegionMap::const_iterator i = regions.begin(); i != regions.end(); ++i) { + if (!(i->second->whole_file() && i->second->max_source_level() > 0)) { + continue; + } + assert(boost::dynamic_pointer_cast<PlaylistSource>(i->second->source (0)) != 0); + if (0 == playlists->region_use_count (i->second)) { + RegionFactory::map_remove (i->second); + } + } + } + /* dump the history list */ _history.clear (); |