don't double-load NestedSource nodes, which are listed both forthe parent/root region...
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 22 Jun 2011 22:46:31 +0000 (22:46 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 22 Jun 2011 22:46:31 +0000 (22:46 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9761 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/region.cc
libs/ardour/session_state.cc
libs/ardour/source_factory.cc

index 8a95f22f8dda0d295d7865ff5209c02b2a2bfdc5..76b7ec0ec63f8f8937af583979b496ec1b68d7a2 100644 (file)
@@ -1207,7 +1207,11 @@ Region::state ()
                node->add_property (buf2, buf);
        }
 
-       if (max_source_level() > 0) {
+       /* Only store nested sources for the whole-file region that acts
+          as the parent/root of all regions using it.
+       */
+
+       if (_whole_file && max_source_level() > 0) {
 
                XMLNode* nested_node = new XMLNode (X_("NestedSource"));
 
index 5d9967cc98dd5d01f79645296da707861e15b19d..8022c7670c20a18c6fbe4ab2d00952f01cbd1cd9 100644 (file)
@@ -1660,11 +1660,26 @@ Session::load_nested_sources (const XMLNode& node)
 
        for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
                if ((*niter)->name() == "Source") {
-                       try {
-                               SourceFactory::create (*this, **niter, true);
+
+                       /* it may already exist, so don't recreate it unnecessarily 
+                        */
+
+                       XMLProperty* prop = (*niter)->property (X_("id"));
+                       if (!prop) {
+                               error << _("Nested source has no ID info in session state file! (ignored)") << endmsg;
+                               continue;
                        }
-                       catch (failed_constructor& err) {
-                               error << string_compose (_("Cannot reconstruct nested source for region %1"), name()) << endmsg;
+
+                       ID source_id (prop->value());
+
+                       if (!source_by_id (source_id)) {
+
+                               try {
+                                       SourceFactory::create (*this, **niter, true);
+                               }
+                               catch (failed_constructor& err) {
+                                       error << string_compose (_("Cannot reconstruct nested source for region %1"), name()) << endmsg;
+                               }
                        }
                }
        }
index a2e93ee61b9711efb8bdedebdd63f212e7382136..3ea63a75ed981817028cd4798797bf26e073ee6f 100644 (file)
@@ -155,12 +155,13 @@ SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks)
 
                        try {
                                boost::shared_ptr<AudioPlaylistSource> ap (new AudioPlaylistSource (s, node));
-
+                               
                                if (setup_peakfile (ap, true)) {
                                        return boost::shared_ptr<Source>();
                                }
 
                                ap->check_for_analysis_data_on_disk ();
+
                                SourceCreated (ap);
                                return ap;