From 5b25dbba03bf0dce9e43f49748f9ce96ced3d37a Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 10 Oct 2014 14:11:43 +0200 Subject: [PATCH] Properly count nested regions --- libs/ardour/playlist.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index c8cca64b78..895741c8da 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -2596,6 +2596,29 @@ Playlist::region_use_count (boost::shared_ptr r) const } } + RegionFactory::CompoundAssociations& cassocs (RegionFactory::compound_associations()); + for (RegionFactory::CompoundAssociations::iterator it = cassocs.begin(); it != cassocs.end(); ++it) { + /* check if region is used in a compound */ + if (it->second == r) { + /* region is referenced as 'original' of a compound */ + ++cnt; + break; + } + if (r->whole_file() && r->max_source_level() > 0) { + /* region itself ia a compound. + * the compound regions are not referenced -> check regions inside compound + */ + const SourceList& sl = r->sources(); + for (SourceList::const_iterator s = sl.begin(); s != sl.end(); ++s) { + boost::shared_ptr ps = boost::dynamic_pointer_cast(*s); + if (!ps) continue; + if (ps->playlist()->region_use_count(it->first)) { + // break out of both loops + return ++cnt; + } + } + } + } return cnt; }