From c0ec11db8e3c98aa745a4aa28398127bc730b89e Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 14 Jul 2022 01:25:06 +0200 Subject: [PATCH] Cleanup code, return early, don't nest --- gtk2_ardour/midi_region_view.cc | 38 +++++++++++++++------------------ 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index fb7380d20b..cc9be7006d 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -3762,28 +3762,24 @@ MidiRegionView::cut_copy_clear (Editing::CutCopyOp op) break; } - if (op != Copy) { - - bool as_subcommand = false; - - for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) { - switch (op) { - case Copy: - break; - case Delete: - case Clear: - case Cut: - if (!_note_diff_command) { - _note_diff_command = _model->new_note_diff_command ("Cut"); - as_subcommand = true; - } - note_diff_remove_note (*i); - break; - } - } - - apply_note_diff (as_subcommand); + if (op == Copy) { + return; } + + bool as_subcommand = false; + + /* Editor::cut_copy already started an undo operation, + * so we cannot call start_note_diff_command () + */ + for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) { + if (!_note_diff_command) { + _note_diff_command = _model->new_note_diff_command ("Cut"); + as_subcommand = true; + } + note_diff_remove_note (*i); + } + + apply_note_diff (as_subcommand); } MidiCutBuffer*