remove debug output and add a few suggestive comments
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 28 Jun 2016 20:05:35 +0000 (16:05 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 28 Jun 2016 20:05:35 +0000 (16:05 -0400)
libs/ardour/playlist.cc
libs/ardour/region.cc
libs/ardour/session_playlists.cc

index 7267ec8cdf8a02f067eb2e8314599e68e2aae0b7..58405e4755747be9c7b188a305413fd64162f1ba 100644 (file)
@@ -2675,7 +2675,13 @@ Playlist::uses_source (boost::shared_ptr<const Source> src, bool shallow) const
        RegionReadLock rlock (const_cast<Playlist*> (this));
 
        for (set<boost::shared_ptr<Region> >::const_iterator r = all_regions.begin(); r != all_regions.end(); ++r) {
-               if ((*r)->uses_source (src, true)) {
+               /* Note: passing the second argument as false can cause at best
+                  incredibly deep and time-consuming recursion, and at worst
+                  cycles if the user has managed to create cycles of reference
+                  between compound regions. We generally only this during
+                  cleanup, and @param shallow is passed as true.
+               */
+               if ((*r)->uses_source (src, shallow)) {
                        return true;
                }
        }
index 20cab959e7b7f567958e62f354334aad6e545f38..ba18cbc62db3d440efe873c3f558e3780d3c2824 100644 (file)
@@ -1531,15 +1531,15 @@ Region::deep_sources (std::set<boost::shared_ptr<Source> > & sources) const
 
                if (ps) {
                        if (sources.find (ps) == sources.end()) {
+                               /* (Playlist)Source not currently in
+                                  accumulating set, so recurse.
+                               */
                                ps->playlist()->deep_sources (sources);
-                               cerr << ps->name() << " new source\n";
-                       } else {
-                               cerr << ps->name() << " already in source list\n";
                        }
                }
 
+               /* add this source */
                sources.insert (*i);
-               cerr << "Added src " << (*i)->name() << endl;
        }
 
        for (SourceList::const_iterator i = _master_sources.begin(); i != _master_sources.end(); ++i) {
@@ -1548,15 +1548,15 @@ Region::deep_sources (std::set<boost::shared_ptr<Source> > & sources) const
 
                if (ps) {
                        if (sources.find (ps) == sources.end()) {
+                               /* (Playlist)Source not currently in
+                                  accumulating set, so recurse.
+                               */
                                ps->playlist()->deep_sources (sources);
-                               cerr << ps->name() << " new source2\n";
-                       } else {
-                               cerr << ps->name() << " already in source list2\n";
                        }
                }
 
+               /* add this source */
                sources.insert (*i);
-               cerr << "Added master src " << (*i)->name() << endl;
        }
 }
 
index c2e0461546ec06332b336db7d2c347af21578805..368b043ef73f335361ddf805f421d02174bbb1af 100644 (file)
@@ -244,7 +244,6 @@ SessionPlaylists::destroy_region (boost::shared_ptr<Region> r)
        }
 }
 
-
 void
 SessionPlaylists::find_equivalent_playlist_regions (boost::shared_ptr<Region> region, vector<boost::shared_ptr<Region> >& result)
 {
@@ -260,7 +259,10 @@ SessionPlaylists::source_use_count (boost::shared_ptr<const Source> src) const
 {
        uint32_t count = 0;
 
-       cerr << "\t\tcheck " << playlists.size() << " playlists\n";
+       /* 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;
@@ -268,7 +270,6 @@ SessionPlaylists::source_use_count (boost::shared_ptr<const Source> src) const
                 }
        }
 
-       cerr << "\t\tcheck " << playlists.size() << " unused playlists\n";
        for (List::const_iterator p = unused_playlists.begin(); p != unused_playlists.end(); ++p) {
                 if ((*p)->uses_source (src)) {
                         ++count;
@@ -518,4 +519,3 @@ SessionPlaylists::foreach (boost::function<void(boost::shared_ptr<const Playlist
                }
        }
 }
-