From d63c0fa328429ff0d7917fe3f4458c97063ba450 Mon Sep 17 00:00:00 2001 From: Sampo Savolainen Date: Tue, 21 Mar 2006 18:40:17 +0000 Subject: [PATCH] Various marker undo fixes. git-svn-id: svn://localhost/trunk/ardour2@413 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor_markers.cc | 6 ++++++ gtk2_ardour/editor_mouse.cc | 10 ++++++++++ libs/ardour/tempo.cc | 28 +++++++++++++++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index d933357685..e611b72d3f 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -810,7 +810,13 @@ Editor::marker_menu_rename () return; } + begin_reversible_command ( _("rename marker") ); + session->add_undo( session->locations()->get_memento() ); + loc->set_name (entry.get_text()); + + session->add_redo_no_execute( session->locations()->get_memento() ); + commit_reversible_command (); } gint diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 8c0b5229bf..6b38b904e1 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -2112,10 +2112,20 @@ Editor::marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event Marker* marker = (Marker *) drag_info.data; bool is_start; + + + + begin_reversible_command ( _("move marker") ); + session->add_undo( session->locations()->get_memento() ); + Location * location = find_location_from_marker (marker, is_start); + if (location) { location->set (drag_info.copied_location->start(), drag_info.copied_location->end()); } + + session->add_redo_no_execute( session->locations()->get_memento() ); + commit_reversible_command (); marker_drag_line->hide(); range_marker_drag_rect->hide(); diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index 24c234552c..5d6365cff3 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -1250,7 +1250,16 @@ TempoMap::set_state (const XMLNode& node) in_set_state = false; } + + /* This state needs to be saved. This string will never be a part of the + object's history though, because the allow_save flag is false during + session load. This state will eventually be tagged "initial state", + by a call to StateManager::allow_save from Session::set_state. + If this state is not saved, there is no way to reach it through undo actions. + */ + save_state(_("load XML data")); + send_state_changed (Change (0)); return 0; @@ -1287,7 +1296,24 @@ TempoMap::restore_state (StateManager::State& state) TempoMapState* tmstate = dynamic_cast (&state); - metrics = tmstate->metrics; + /* We can't just set the metrics pointer to the address of the metrics list + stored in the state, cause this would ruin this state for restoring in + the future. If they have the same address, they are the same list. + Thus we need to copy all the elements from the state metrics list to the + current metrics list. + */ + metrics->clear(); + for (Metrics::iterator i = tmstate->metrics->begin(); i != tmstate->metrics->end(); ++i) { + TempoSection *ts; + MeterSection *ms; + + if ((ts = dynamic_cast(*i)) != 0) { + metrics->push_back (new TempoSection (*ts)); + } else if ((ms = dynamic_cast(*i)) != 0) { + metrics->push_back (new MeterSection (*ms)); + } + } + last_bbt_valid = false; return Change (0);