Cleanup code, return early, don't nest

This commit is contained in:
Robin Gareus 2022-07-14 01:25:06 +02:00
parent b4a7c8a17d
commit c0ec11db8e
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04

View file

@ -3762,29 +3762,25 @@ MidiRegionView::cut_copy_clear (Editing::CutCopyOp op)
break; break;
} }
if (op != Copy) { if (op == Copy) {
return;
}
bool as_subcommand = false; 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) { 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) { if (!_note_diff_command) {
_note_diff_command = _model->new_note_diff_command ("Cut"); _note_diff_command = _model->new_note_diff_command ("Cut");
as_subcommand = true; as_subcommand = true;
} }
note_diff_remove_note (*i); note_diff_remove_note (*i);
break;
}
} }
apply_note_diff (as_subcommand); apply_note_diff (as_subcommand);
} }
}
MidiCutBuffer* MidiCutBuffer*
MidiRegionView::selection_as_cut_buffer () const MidiRegionView::selection_as_cut_buffer () const