From: Robin Gareus Date: Fri, 10 Oct 2014 12:11:43 +0000 (+0200) Subject: Properly count nested regions X-Git-Tag: 4.0-rc1~1601^2~29 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=5b25dbba03bf0dce9e43f49748f9ce96ced3d37a;p=ardour.git Properly count nested regions --- 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; }