Fix MIDI note cut

1. Editor::cut_copy() calls begin_reversible_command ("cut MIDI")
2. Editor::cut_copy_midi calls mrv->cut_copy_clear()
3. MidiRegionView::cut_copy_clear calls start_note_diff_command()
4. second call to  begin_reversible_command()
- debug builds assert() here, optimized builds continue
5. abort_reversible_command() is called, _current_trans = NULL;
6. MidiModel::apply_diff_command_as_subcommand()
7. Session::add_command, segfault because _current_trans == NULL

```
An UNDO transaction was started while a prior command was underway.
Aborting command (midi edit) and prior (cut MIDI)
```
This commit is contained in:
Robin Gareus 2022-07-13 22:12:30 +02:00
parent e6570b2247
commit 6a57baf193
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -3764,21 +3764,28 @@ MidiRegionView::cut_copy_clear (Editing::CutCopyOp op)
if (op != Copy) {
start_note_diff_command();
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
switch (op) {
case Copy:
break;
case Delete:
case Cut:
case Clear:
start_note_diff_command();
/* fallthrough */
case Cut:
/* for Cut, Editor::cut_copy already started an undo operation,
* so we cannot call start_note_diff_command ()
*/
if (!_note_diff_command) {
_note_diff_command = _model->new_note_diff_command ("Cut");
}
note_diff_remove_note (*i);
break;
}
}
apply_note_diff();
apply_note_diff (op == Cut);
}
}