X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fsession_playlists.cc;h=95982b6158932bfc0f0c842f7af7d79cebc2ebef;hb=cf52d6e4b40111eb04b244ec054055a4ec15dbe0;hp=b586ab196ebd318d65f09d9951fe86fa815664ac;hpb=2a7ed69c28c5c4606ff13b3605b9bc9c3eba607d;p=ardour.git diff --git a/libs/ardour/session_playlists.cc b/libs/ardour/session_playlists.cc index b586ab196e..95982b6158 100644 --- a/libs/ardour/session_playlists.cc +++ b/libs/ardour/session_playlists.cc @@ -23,7 +23,7 @@ #include "ardour/playlist_factory.h" #include "ardour/session_playlists.h" #include "ardour/track.h" -#include "i18n.h" +#include "pbd/i18n.h" #include "pbd/compose.h" #include "pbd/xml++.h" @@ -244,7 +244,6 @@ SessionPlaylists::destroy_region (boost::shared_ptr r) } } - void SessionPlaylists::find_equivalent_playlist_regions (boost::shared_ptr region, vector >& result) { @@ -260,6 +259,10 @@ SessionPlaylists::source_use_count (boost::shared_ptr src) const { uint32_t count = 0; + /* XXXX this can go wildly wrong in the presence of circular references + * between compound regions. + */ + for (List::const_iterator p = playlists.begin(); p != playlists.end(); ++p) { if ((*p)->uses_source (src)) { ++count; @@ -333,15 +336,39 @@ SessionPlaylists::maybe_delete_unused (boost::function > playlists_tbd; + bool delete_remaining = false; + bool keep_remaining = false; + for (List::iterator x = unused_playlists.begin(); x != unused_playlists.end(); ++x) { + if (keep_remaining) { + break; + } + + if (delete_remaining) { + playlists_tbd.push_back (*x); + continue; + } + int status = ask (*x); switch (status) { case -1: + // abort return true; - case 0: + case -2: + // keep this and all later + keep_remaining = true; + break; + + case 2: + // delete this and all later + delete_remaining = true; + // no break; + + case 1: + // delete this playlists_tbd.push_back (*x); break; @@ -465,7 +492,7 @@ SessionPlaylists::playlists_for_track (boost::shared_ptr tr) const { vector > pl; get (pl); - + vector > pl_tr; for (vector >::iterator i = pl.begin(); i != pl.end(); ++i) { @@ -476,3 +503,19 @@ SessionPlaylists::playlists_for_track (boost::shared_ptr tr) const return pl_tr; } + +void +SessionPlaylists::foreach (boost::function)> functor) +{ + Glib::Threads::Mutex::Lock lm (lock); + for (List::iterator i = playlists.begin(); i != playlists.end(); i++) { + if (!(*i)->hidden()) { + functor (*i); + } + } + for (List::iterator i = unused_playlists.begin(); i != unused_playlists.end(); i++) { + if (!(*i)->hidden()) { + functor (*i); + } + } +}