r321@gandalf: fugalh | 2006-08-12 15:48:28 -0600
authorHans Fugal <hans@fugal.net>
Sat, 12 Aug 2006 21:52:56 +0000 (21:52 +0000)
committerHans Fugal <hans@fugal.net>
Sat, 12 Aug 2006 21:52:56 +0000 (21:52 +0000)
 Behold serialized undo.

git-svn-id: svn://localhost/ardour2/branches/undo@799 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ardour_ui.cc
gtk2_ardour/ardour_ui_dialogs.cc
libs/ardour/automation_event.cc
libs/ardour/curve.cc
libs/ardour/session.cc
libs/ardour/session_command.cc
libs/ardour/session_midi.cc
libs/ardour/session_state.cc
libs/ardour/session_transport.cc
libs/ardour/track.cc
libs/surfaces/control_protocol/basic_ui.cc

index 8a75396ed24c9324a6d6528fba9f8226cd77dbba..c054de98085ed05dba07e8a35896254a3164d5a3 100644 (file)
@@ -1298,7 +1298,6 @@ ARDOUR_UI::start_engine ()
                           settings for a new session 
                        */
                        session->save_state ("");
-                        session->save_history ("");
                }
 
                /* there is too much going on, in too many threads, for us to 
@@ -1472,7 +1471,6 @@ ARDOUR_UI::save_state_canfail (string name)
                }
 
                if ((ret = session->save_state (name)) != 0) {
-                        session->save_history (name);
                        return ret;
                }
        }
index 5a1ec874624e2d5c39862c049e0833c5a139ab5c..25f3068a813d39c04d0b38157e98f79dee0e6c7c 100644 (file)
@@ -156,7 +156,6 @@ ARDOUR_UI::unload_session ()
                        
                case 1:
                        session->save_state ("");
-                        session->save_history ("");
                        break;
                }
        }
index cf69c634b158e2f4876bfb28f2ea5bc6cde7855a..ccfcef28f4d01616bd67a4b737ec1f6cab533908 100644 (file)
@@ -33,6 +33,8 @@ using namespace ARDOUR;
 using namespace sigc;
 using namespace PBD;
 
+sigc::signal<void,AutomationList *> AutomationList::AutomationListCreated;
+
 #if 0
 static void dumpit (const AutomationList& al, string prefix = "")
 {
index 5879cb598865bb8bec781684fa157d6988605d6e..20f7053f2e9466e4ef43f82b5f561e02cd4ed38a 100644 (file)
@@ -40,6 +40,8 @@ using namespace ARDOUR;
 using namespace sigc;
 using namespace PBD;
 
+sigc::signal<void, Curve*> Curve::CurveCreated;
+
 Curve::Curve (double minv, double maxv, double canv, bool nostate)
        : AutomationList (canv, nostate)
 {
index 1bd11cacc0e5244601116d728475c5bc47e20a54..48f7fc30e9bec96b513fdb621977ed48289da8e5 100644 (file)
@@ -263,7 +263,7 @@ Session::Session (AudioEngine &eng,
 {
        bool new_session;
 
-       cerr << "Loading session " << fullpath << " using snapshot " << snapshot_name << endl;
+       cerr << "Loading session " << fullpath << " using snapshot " << snapshot_name << " (1)" << endl;
 
        n_physical_outputs = _engine.n_physical_outputs();
        n_physical_inputs =  _engine.n_physical_inputs();
@@ -312,7 +312,7 @@ Session::Session (AudioEngine &eng,
 {
        bool new_session;
 
-       cerr << "Loading session " << fullpath << " using snapshot " << snapshot_name << endl;
+       cerr << "Loading session " << fullpath << " using snapshot " << snapshot_name << " (2)" << endl;
 
        n_physical_outputs = max (requested_physical_out, _engine.n_physical_outputs());
        n_physical_inputs = max (requested_physical_in, _engine.n_physical_inputs());
@@ -1007,7 +1007,6 @@ Session::auto_punch_start_changed (Location* location)
        if (get_record_enabled() && get_punch_in()) {
                /* capture start has been changed, so save new pending state */
                save_state ("", true);
-                save_history("");
        }
 }      
 
@@ -1325,7 +1324,6 @@ Session::maybe_enable_record ()
        */
 
        save_state ("", true);
-        save_history ("");
 
        if (_transport_speed) {
                if (!punch_in) {
@@ -1889,7 +1887,6 @@ Session::add_route (shared_ptr<Route> route)
 
        set_dirty();
        save_state (_current_snapshot_name);
-       save_history (_current_snapshot_name);
 
        RouteAdded (route); /* EMIT SIGNAL */
 }
@@ -1921,7 +1918,6 @@ Session::add_diskstream (Diskstream* dstream)
 
        set_dirty();
        save_state (_current_snapshot_name);
-        save_history (_current_snapshot_name);
 
        DiskstreamAdded (dstream); /* EMIT SIGNAL */
 }
@@ -1986,7 +1982,6 @@ Session::remove_route (shared_ptr<Route> route)
        /* XXX should we disconnect from the Route's signals ? */
 
        save_state (_current_snapshot_name);
-       save_history (_current_snapshot_name);
 
        /* all shared ptrs to route should go out of scope here */
 }      
@@ -2689,7 +2684,6 @@ Session::remove_source (Source* source)
                */
                
                save_state (_current_snapshot_name);
-                save_history (_current_snapshot_name);
        }
 
        SourceRemoved(source); /* EMIT SIGNAL */
index 4021fae5731171a7e31d709ebeb27410a4a61a67..8c1a4b32cfeefc03f92ac064253332f99247c8b7 100644 (file)
@@ -31,12 +31,12 @@ Command *Session::memento_command_factory(XMLNode *n)
     /* get before/after */
     if (n->name() == "MementoCommand")
     {
-        before = n->children().front();
-        after = n->children().back();
+        before = new XMLNode(*n->children().front());
+        after = new XMLNode(*n->children().back());
     } else if (n->name() == "MementoUndoCommand")
-        before = n->children().front();
+        before = new XMLNode(*n->children().front());
     else if (n->name() == "MementoRedoCommand")
-        after = n->children().front();
+        after = new XMLNode(*n->children().front());
 
 
     /* create command */
@@ -64,9 +64,6 @@ Command *Session::memento_command_factory(XMLNode *n)
     }
     else if (obj_T == "Route") // inlcudes AudioTrack
         return new MementoCommand<Route>(*route_by_id(id), before, after);
-    // For Editor and AutomationLine which are off-limits here
-    else if (registry.count(id))
-        return new MementoCommand<Stateful>(*registry[id], before, after);
     else if (obj_T == "Curve")
     {
         if (curves.count(id))
@@ -77,6 +74,9 @@ Command *Session::memento_command_factory(XMLNode *n)
         if (automation_lists.count(id))
             return new MementoCommand<AutomationList>(*automation_lists[id], before, after);
     }
+    // For Editor and AutomationLine which are off-limits here
+    else if (registry.count(id))
+        return new MementoCommand<Stateful>(*registry[id], before, after);
 
     /* we failed */
     error << _("could not reconstitute MementoCommand from XMLNode. id=") << id.to_s() << endmsg;
index 887d6f5c197ca8b4dc6fd86d4de80ffa6155ad7c..821f894eeb1f4cb64d803c87c90c896c1e1fa16f 100644 (file)
@@ -594,7 +594,6 @@ Session::mmc_record_strobe (MIDI::MachineControl &mmc)
                */
                
                save_state ("", true);
-               save_history ("");
                g_atomic_int_set (&_record_status, Enabled);
                RecordStateChanged (); /* EMIT SIGNAL */
                
index 903d6f558ae397f3e4fa0d1bffbc9a6103100dd2..181d4c8a67639b5c5ae611eb894a465acae0057f 100644 (file)
@@ -349,6 +349,7 @@ Session::second_stage_init (bool new_session)
                _end_location_is_free = false;
        }
        
+        restore_history(_current_snapshot_name);
        return 0;
 }
 
@@ -715,6 +716,7 @@ Session::save_state (string snapshot_name, bool pending)
        }
 
        if (!pending) {
+                save_history(snapshot_name);
 
                bool was_dirty = dirty();
 
@@ -1690,7 +1692,6 @@ Session::set_state (const XMLNode& node)
 
        if (state_was_pending) {
                save_state (_current_snapshot_name);
-                save_history (_current_snapshot_name);
                remove_pending_capture_state ();
                state_was_pending = false;
        }
@@ -2478,7 +2479,6 @@ void
 Session::auto_save()
 {
        save_state (_current_snapshot_name);
-        save_history (_current_snapshot_name);
 }
 
 RouteGroup *
@@ -3150,7 +3150,6 @@ Session::cleanup_sources (Session::cleanup_report& rep)
        */
        
        save_state ("");
-       save_history ("");
 
   out:
        _state_of_the_state = (StateOfTheState) (_state_of_the_state & ~InCleanup);
@@ -3290,6 +3289,7 @@ Session::save_history (string snapshot_name)
     string xml_path;
     string bak_path;
 
+
     tree.set_root (&history.get_state());
 
     if (snapshot_name.empty()) {
@@ -3297,6 +3297,7 @@ Session::save_history (string snapshot_name)
     }
 
     xml_path = _path + snapshot_name + ".history"; 
+    info << "Saving history to " << xml_path << endmsg;
 
     bak_path = xml_path + ".bak";
 
@@ -3340,6 +3341,8 @@ Session::restore_history (string snapshot_name)
     /* read xml */
     xmlpath = _path + snapshot_name + ".history";
 
+    info << string_compose(_("Loading history from '%1'."), xmlpath) << endmsg;
+
     if (access (xmlpath.c_str(), F_OK)) {
         error << string_compose(_("%1: session history file \"%2\" doesn't exist!"), _name, xmlpath) << endmsg;
         return 1;
@@ -3350,6 +3353,8 @@ Session::restore_history (string snapshot_name)
         return -1;
     }
 
+    info << "root children " << tree.root()->children().size() << endmsg;
+
     /* replace history */
     history.clear();
     for (XMLNodeConstIterator it  = tree.root()->children().begin();
@@ -3388,5 +3393,10 @@ Session::restore_history (string snapshot_name)
         }
         history.add(ut);
     }
+
+    XMLTree tree2;
+    tree2.set_root(&history.get_state());
+    info << tree2.write_buffer() << endmsg;
+
     return 0;
 }
index 0e3895caf110bc0de18f953ae2cefe7c36229d52..7c2b4f1c6f8502b44d2dea9f3c58e39462e918ab 100644 (file)
@@ -411,7 +411,6 @@ Session::non_realtime_stop (bool abort)
        if ((post_transport_work & PostTransportLocate) && get_record_enabled()) {
                /* capture start has been changed, so save pending state */
                save_state ("", true);
-                save_history ("");
        }
 
         /* always try to get rid of this */
@@ -422,7 +421,6 @@ Session::non_realtime_stop (bool abort)
 
        if (did_record) {
                save_state (_current_snapshot_name);
-               save_history (_current_snapshot_name);
        }
 
        if (post_transport_work & PostTransportDuration) {
index 1efd18ae228c8a9494a4f1fbc0d9c02bda060bcf..58d8c1b3065692320e1a4ad3230a8458afe8871b 100644 (file)
@@ -224,7 +224,6 @@ Track::set_name (string str, void *src)
 
        if ((ret = IO::set_name (str, src)) == 0) {
                _session.save_state ("");
-                _session.save_history ("");
        }
        return ret;
 }
index bee47839140d46398d1c46cd2accda67737418df..3dc93cc64ad980070886d6215a613b25a5288260 100644 (file)
@@ -145,7 +145,6 @@ void
 BasicUI::save_state ()
 {
        session->save_state ("");
-        session->save_history("");
 }
 
 void