Use a few shared_ptrs to make things slightly neater.
[ardour.git] / libs / ardour / session_command.cc
index 17c7d559d4795bf25efbf1fc882c90700665318b..e5ddd0a0973ac9c816933584f7e852a74b76efcd 100644 (file)
@@ -34,6 +34,7 @@
 #include "ardour/session_playlists.h"
 #include "ardour/region_factory.h"
 #include "ardour/midi_automation_list_binder.h"
+#include "ardour/crossfade_binder.h"
 #include "ardour/crossfade.h"
 #include "pbd/error.h"
 #include "pbd/id.h"
@@ -139,15 +140,20 @@ Session::memento_command_factory(XMLNode *n)
                            before, after
                            );
            }
-           
-           cerr << "Alist not found\n";
+
+           cerr << "Alist " << id << " not found\n";
 
     } else if (obj_T == "ARDOUR::Crossfade") {
-           boost::shared_ptr<Crossfade> c = playlists->find_crossfade (id);
-           if (c) {
-                   return new MementoCommand<Crossfade> (*c.get(), before, after);
+           if (have_id) {
+                   boost::shared_ptr<Crossfade> c = playlists->find_crossfade (id);
+                   if (c) {
+                           return new MementoCommand<Crossfade> (*c.get(), before, after);
+                   }
            } else {
-                   error << string_compose (X_("Crossfade %1 not found in session"), id) << endmsg;
+                   return new MementoCommand<Crossfade> (
+                           new CrossfadeBinder (n, playlists),
+                           before, after
+                           );
            }
 
     } else if (registry.count(id)) { // For Editor and AutomationLine which are off-limits herea
@@ -182,10 +188,10 @@ Session::stateful_diff_command_factory (XMLNode* n)
         }
 
        /* we failed */
-       
+
        error << string_compose (
                _("could not reconstitute StatefulDiffCommand from XMLNode. object type = %1 id = %2"), obj_T, id.to_s())
              << endmsg;
-       
+
        return 0;
 }