Cleanup: retain sources used by triggers in this session

Note that ::find_all_sources_across_snapshots() finds and retains
all sources in the SourceList of other snapshots regardless
if they are used in those snapshots.
This commit is contained in:
Robin Gareus 2022-06-16 20:03:43 +02:00
parent 9964f20c63
commit 7e039d4f3f
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 24 additions and 2 deletions

View File

@ -729,6 +729,8 @@ class LIBARDOUR_API TriggerBox : public Processor
XMLNode& get_state () const;
int set_state (const XMLNode&, int version);
void deep_sources (std::set<boost::shared_ptr<Source>>&);
void set_from_path (uint32_t slot, std::string const & path);
void set_from_selection (uint32_t slot, boost::shared_ptr<Region>);

View File

@ -3667,8 +3667,17 @@ Session::cleanup_sources (CleanupReport& rep)
_playlists->foreach (boost::bind (merge_all_sources, _1, &sources_used_by_this_snapshot));
/* add our current source list
*/
{
boost::shared_ptr<RouteList> rl = routes.reader();
for (auto const& r : *rl) {
boost::shared_ptr<TriggerBox> tb = r->triggerbox ();
if (tb) {
tb->deep_sources (sources_used_by_this_snapshot);
}
}
}
/* add our current source list */
ls.acquire ();
for (SourceMap::iterator i = sources.begin(); i != sources.end(); ) {

View File

@ -3250,6 +3250,17 @@ TriggerBox::trigger_by_id (PBD::ID check)
return TriggerPtr();
}
void
TriggerBox::deep_sources (std::set<boost::shared_ptr<Source> >& sources)
{
for (uint64_t n = 0; n < all_triggers.size(); ++n) {
boost::shared_ptr<Region> r (trigger(n)->region ());
if (r) {
r->deep_sources (sources);
}
}
}
void
TriggerBox::enqueue_trigger_state_for_region (boost::shared_ptr<Region> region, boost::shared_ptr<Trigger::UIState> state)
{