From 6c14a6c407ae3a7a2f663e2c7a2e20d409a40f24 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 18 Oct 2024 09:57:43 -0600 Subject: [PATCH] non-crashing version of previous commit --- gtk2_ardour/midi_view.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gtk2_ardour/midi_view.cc b/gtk2_ardour/midi_view.cc index 7f6ed7d837..5dc128f3a9 100644 --- a/gtk2_ardour/midi_view.cc +++ b/gtk2_ardour/midi_view.cc @@ -1565,10 +1565,12 @@ MidiView::begin_write() XXX this should not happen. */ - for (unsigned i = 0; i < 128; ++i) { - delete _active_notes[i]; + if (_active_notes) { + for (unsigned i = 0; i < 128; ++i) { + delete _active_notes[i]; + } + delete [] _active_notes; } - delete [] _active_notes; /* reallocate */ @@ -1585,12 +1587,13 @@ MidiView::begin_write() void MidiView::end_write() { - for (unsigned i = 0; i < 128; ++i) { - delete _active_notes[i]; + if (_active_notes) { + for (unsigned i = 0; i < 128; ++i) { + delete _active_notes[i]; + } + delete [] _active_notes; } - delete [] _active_notes; - _active_notes = nullptr; _marked_for_selection.clear(); _marked_for_velocity.clear();