fixed collision with <SECONDARY>n binding
[ardour.git] / gtk2_ardour / editor.cc
index a29c1ebeef04b0dfbe37beae43d8b29b6e743a55..a66972a7e96d7a52566283c2533469dc4f0721ce 100644 (file)
@@ -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 ();
                }