From dbe49ae8c49612e8cdc041f9cdc8b4da11d3f26c Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Mon, 9 May 2022 14:44:05 -0500 Subject: [PATCH] editor::paste fix a thinko in undo nesting --- gtk2_ardour/editor_ops.cc | 11 ++++++++--- gtk2_ardour/midi_region_view.cc | 10 ++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 82938ab698..cd639304ae 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -5173,6 +5173,7 @@ Editor::paste_internal (timepos_t const & pos, float times) R1.A1, R1.A2, R2, R2.A1, ... */ } + bool commit = false; begin_reversible_command (Operations::paste); if (ts.size() == 1 && cut_buffer->lines.size() == 1 && @@ -5181,7 +5182,7 @@ Editor::paste_internal (timepos_t const & pos, float times) "greedy" paste from one automation type to another. */ PasteContext ctx(paste_count, times, ItemCounts(), true); - ts.front()->paste (position, *cut_buffer, ctx); + commit |= ts.front()->paste (position, *cut_buffer, ctx); } else { @@ -5189,13 +5190,17 @@ Editor::paste_internal (timepos_t const & pos, float times) PasteContext ctx(paste_count, times, ItemCounts(), false); for (TrackViewList::iterator i = ts.begin(); i != ts.end(); ++i) { - (*i)->paste (position, *cut_buffer, ctx); + commit |= (*i)->paste (position, *cut_buffer, ctx); } } ++paste_count; - commit_reversible_command (); + if (commit) { + commit_reversible_command (); + } else { + abort_reversible_command (); + } } void diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index fed1a77b7b..7f95b723fc 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -3837,7 +3837,7 @@ MidiRegionView::duplicate_selection () paste (dup_pos, local_selection, ctxt); } -/** This method handles undo */ +/** undo commands were initiated at the 'action' level. ::paste and ::paste_internal should implement subcommands */ bool MidiRegionView::paste (timepos_t const & pos, const ::Selection& selection, PasteContext& ctx) { @@ -3865,17 +3865,11 @@ MidiRegionView::paste (timepos_t const & pos, const ::Selection& selection, Past const ATracks& atracks = midi_view()->automation_tracks(); for (ATracks::const_iterator a = atracks.begin(); a != atracks.end(); ++a) { if (a->second->paste(pos, selection, ctx)) { - if(!commit) { - trackview.editor().begin_reversible_command (Operations::paste); - } commit = true; } } - if (commit) { - trackview.editor().commit_reversible_command (); - } - return true; + return commit; } /** undo commands were initiated at the 'action' level. ::paste and ::paste_internal should implement subcommands */