X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fsession_playlists.cc;h=368b043ef73f335361ddf805f421d02174bbb1af;hb=e845b9f9357c4ff471c02b1f63a61275bb4a7d28;hp=b586ab196ebd318d65f09d9951fe86fa815664ac;hpb=9aacefc17010a889222425f97b99050171165038;p=ardour.git diff --git a/libs/ardour/session_playlists.cc b/libs/ardour/session_playlists.cc index b586ab196e..368b043ef7 100644 --- a/libs/ardour/session_playlists.cc +++ b/libs/ardour/session_playlists.cc @@ -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); + } + } +}