Stop saving of garbage values to LADSPA preset files when an output parameter is...
[ardour.git] / libs / ardour / session_command.cc
index 17ffa1e26dce27c2b3aadf5650774ebee1df0366..17c7d559d4795bf25efbf1fc882c90700665318b 100644 (file)
@@ -33,6 +33,8 @@
 #include "ardour/midi_region.h"
 #include "ardour/session_playlists.h"
 #include "ardour/region_factory.h"
+#include "ardour/midi_automation_list_binder.h"
+#include "ardour/crossfade.h"
 #include "pbd/error.h"
 #include "pbd/id.h"
 #include "pbd/statefuldestructible.h"
@@ -58,7 +60,12 @@ Session::memento_command_factory(XMLNode *n)
     XMLNode *child = 0;
 
     /* get id */
-    id = PBD::ID(n->property("obj-id")->value());
+
+    /* XXX: HACK! */
+    bool have_id = n->property("obj-id") != 0;
+    if (have_id) {
+           id = PBD::ID(n->property("obj-id")->value());
+    }
 
     /* get before/after */
 
@@ -97,13 +104,13 @@ Session::memento_command_factory(XMLNode *n)
                    return new MementoCommand<Source>(*sources[id], before, after);
 
     } else if (obj_T == "ARDOUR::Location") {
-           Location* loc = _locations.get_location_by_id(id);
+           Location* loc = _locations->get_location_by_id(id);
            if (loc) {
                    return new MementoCommand<Location>(*loc, before, after);
            }
 
     } else if (obj_T == "ARDOUR::Locations") {
-           return new MementoCommand<Locations>(_locations, before, after);
+           return new MementoCommand<Locations>(*_locations, before, after);
 
     } else if (obj_T == "ARDOUR::TempoMap") {
            return new MementoCommand<TempoMap>(*_tempo_map, before, after);
@@ -121,11 +128,28 @@ Session::memento_command_factory(XMLNode *n)
                }
 
     } else if (obj_T == "Evoral::Curve" || obj_T == "ARDOUR::AutomationList") {
-               std::map<PBD::ID, AutomationList*>::iterator i = automation_lists.find(id);
-               if (i != automation_lists.end()) {
-                   return new MementoCommand<AutomationList>(*i->second, before, after);
-               }
-                cerr << "Alist not found\n";
+           if (have_id) {
+                   std::map<PBD::ID, AutomationList*>::iterator i = automation_lists.find(id);
+                   if (i != automation_lists.end()) {
+                           return new MementoCommand<AutomationList>(*i->second, before, after);
+                   }
+           } else {
+                   return new MementoCommand<AutomationList> (
+                           new MidiAutomationListBinder (n, sources),
+                           before, after
+                           );
+           }
+           
+           cerr << "Alist 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);
+           } else {
+                   error << string_compose (X_("Crossfade %1 not found in session"), id) << endmsg;
+           }
+
     } else if (registry.count(id)) { // For Editor and AutomationLine which are off-limits herea
            return new MementoCommand<PBD::StatefulDestructible>(*registry[id], before, after);
     }