From b489d466cf914fc464c6a9b75b7af50af4956c8c Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 4 Mar 2025 12:18:29 -0700 Subject: [PATCH] commit crash caused by event-sensitive ghost note in MidiView --- gtk2_ardour/midi_view.cc | 14 +++++++------- gtk2_ardour/midi_view.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gtk2_ardour/midi_view.cc b/gtk2_ardour/midi_view.cc index 5fe3502588..9a641ea12c 100644 --- a/gtk2_ardour/midi_view.cc +++ b/gtk2_ardour/midi_view.cc @@ -1288,9 +1288,9 @@ MidiView::view_changed() } bool -MidiView::note_editable (std::shared_ptr note) const +MidiView::note_editable (NoteBase const * ev) const { - return (_visible_channel < 0) || (note->channel() == _visible_channel); + return (ev != _ghost_note) && (_visible_channel < 0) || (ev->note()->channel() == _visible_channel); } void @@ -1780,7 +1780,7 @@ MidiView::update_sustained (Note* ev) } color_note (ev, note->channel()); - ev->set_ignore_events (!note_editable (note)); + ev->set_ignore_events (!note_editable (ev)); } void @@ -1789,7 +1789,7 @@ MidiView::color_note (NoteBase* ev, int channel) // Update color in case velocity has changed uint32_t base_color = ev->base_color(); - if (!note_editable (ev->note())) { + if (!note_editable (ev)) { base_color = Gtkmm2ext::change_alpha (base_color, 0.15); } @@ -1932,7 +1932,7 @@ MidiView::update_hit (Hit* ev) ev->set_outline_color(ev->calculate_outline(base_col, ev->selected())); color_note (ev, _visible_channel); - ev->set_ignore_events (!note_editable (note)); + ev->set_ignore_events (!ev); } /** Add a MIDI note to the view (with length). @@ -2624,7 +2624,7 @@ MidiView::update_drag_selection(timepos_t const & start, timepos_t const & end, for (auto & [ note, gui ] : _events) { if (gui->x0() < x1 && gui->x1() > x0 && gui->y0() < y1 && gui->y1() > y0) { // Rectangles intersect - if (!gui->selected() && note_editable (note)) { + if (!gui->selected() && note_editable (gui)) { add_to_selection (gui); } } else if (gui->selected() && !extend) { @@ -5253,7 +5253,7 @@ MidiView::set_visible_channel (int chn, bool clear_selection) if (gui->item()->visible()) { color_note (gui, note->channel()); - gui->set_ignore_events (!note_editable (note)); + gui->set_ignore_events (!note_editable (gui)); } } diff --git a/gtk2_ardour/midi_view.h b/gtk2_ardour/midi_view.h index 90282ce960..7f44ce536e 100644 --- a/gtk2_ardour/midi_view.h +++ b/gtk2_ardour/midi_view.h @@ -390,7 +390,7 @@ class MidiView : public virtual sigc::trackable, public LineMerger virtual void reset_width_dependent_items (double pixel_width); void redisplay (bool view_only); - bool note_editable (std::shared_ptr) const; + bool note_editable (NoteBase const *) const; protected: friend class EditingContext;