alter config file copying infrastructure so it can be used at a suitable time in...
[ardour.git] / gtk2_ardour / editor.cc
index a29c1ebeef04b0dfbe37beae43d8b29b6e743a55..f20b24a80bc810dcb8d90fa961b7fa3efeb9af86 100644 (file)
@@ -1878,7 +1878,7 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
        edit_items.push_back (MenuElem (_("Bounce Range to Region List With Processing"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), false, true)));
        edit_items.push_back (MenuElem (_("Export Range..."), sigc::mem_fun(*this, &Editor::export_selection)));
        if (ARDOUR_UI::instance()->video_timeline->get_duration() > 0) {
-               edit_items.push_back (MenuElem (_("Export Video Range..."), sigc::bind (sigc::mem_fun(*this, &Editor::export_video), true)));
+               edit_items.push_back (MenuElem (_("Export Video Range..."), sigc::bind (sigc::mem_fun(*(ARDOUR_UI::instance()), &ARDOUR_UI::export_video), true)));
        }
 }
 
@@ -3326,7 +3326,12 @@ Editor::begin_selection_op_history ()
 {
        selection_op_cmd_depth = 0;
        selection_op_history_it = 0;
-       selection_op_history.clear();
+
+       while(!selection_op_history.empty()) {
+               delete selection_op_history.front();
+               selection_op_history.pop_front();
+       }
+
        selection_undo_action->set_sensitive (false);
        selection_redo_action->set_sensitive (false);
        selection_op_history.push_front (&_selection_memento->get_state ());
@@ -3349,10 +3354,19 @@ Editor::commit_reversible_selection_op ()
                if (selection_op_cmd_depth == 1) {
 
                        if (selection_op_history_it > 0 && selection_op_history_it < selection_op_history.size()) {
-                               /* the user has undone some selection ops and then made a new one */
+                               /**
+                                   The user has undone some selection ops and then made a new one,
+                                   making anything earlier in the list invalid.
+                               */
+                               
                                list<XMLNode *>::iterator it = selection_op_history.begin();
-                               advance (it, selection_op_history_it);
-                               selection_op_history.erase (selection_op_history.begin(), it);
+                               list<XMLNode *>::iterator e_it = it;
+                               advance (e_it, selection_op_history_it);
+                               
+                               for ( ; it != e_it; ++it) {
+                                       delete *it;
+                               }
+                               selection_op_history.erase (selection_op_history.begin(), e_it);
                        }
 
                        selection_op_history.push_front (&_selection_memento->get_state ());
@@ -3428,12 +3442,25 @@ Editor::begin_reversible_command (GQuark q)
        }
 }
 
+void
+Editor::abort_reversible_command ()
+{
+       if (_session) {
+               while(!before.empty()) {
+                       delete before.front();
+                       before.pop_front();
+               }
+               _session->abort_reversible_command ();
+       }
+}
+
 void
 Editor::commit_reversible_command ()
 {
        if (_session) {
                if (before.size() == 1) {
                        _session->add_command (new MementoCommand<SelectionMemento>(*(_selection_memento), before.front(), &_selection_memento->get_state ()));
+                       redo_action->set_sensitive(false);
                        undo_action->set_sensitive(true);
                        begin_selection_op_history ();
                }
@@ -5193,6 +5220,8 @@ Editor::add_routes (RouteList& routes)
 
        RouteTimeAxisView *rtv;
        list<RouteTimeAxisView*> new_views;
+       TrackViewList new_selection;
+       bool from_scratch = (track_views.size() == 0);
 
        for (RouteList::iterator x = routes.begin(); x != routes.end(); ++x) {
                boost::shared_ptr<Route> route = (*x);
@@ -5215,6 +5244,7 @@ Editor::add_routes (RouteList& routes)
 
                new_views.push_back (rtv);
                track_views.push_back (rtv);
+               new_selection.push_back (rtv);
 
                rtv->effective_gain_display ();
 
@@ -5227,6 +5257,12 @@ Editor::add_routes (RouteList& routes)
                _summary->routes_added (new_views);
        }
 
+       if (!from_scratch) {
+               selection->tracks.clear();
+               selection->add (new_selection);
+               begin_selection_op_history();
+       }
+
        if (show_editor_mixer_when_tracks_arrive) {
                show_editor_mixer (true);
        }