From cdf88efeff8f0c896ff95c12244e72a866666235 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 10 Nov 2024 12:44:05 -0700 Subject: [PATCH] fix crash caused by VelocityDisplay _optimization_iterator Never use the _optimization_iterator when looking for a note to update or select because those two conditions may be preceded by note add/delete operations (including those via undo/redo) which would make the iterator invalid. The _optimization_iterator only makes sense when actually iterating over the event list, which is ironic because that's the one time we don't need it --- gtk2_ardour/velocity_display.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/velocity_display.cc b/gtk2_ardour/velocity_display.cc index 35fec17b19..d04baf95b7 100644 --- a/gtk2_ardour/velocity_display.cc +++ b/gtk2_ardour/velocity_display.cc @@ -203,12 +203,15 @@ VelocityDisplay::set_size_and_position (GhostEvent& gev) void VelocityDisplay::update_note (NoteBase* nb) { - GhostEvent* gev = GhostEvent::find (nb->note(), events, _optimization_iterator); + auto iter = events.end(); + + GhostEvent* gev = GhostEvent::find (nb->note(), events, iter); if (!gev) { return; } + _optimization_iterator = iter; update_ghost_event (gev); } @@ -319,7 +322,9 @@ VelocityDisplay::y_position_to_velocity (double y) const void VelocityDisplay::note_selected (NoteBase* ev) { - GhostEvent* gev = GhostEvent::find (ev->note(), events, _optimization_iterator); + auto ignore_optiter = events.end(); + + GhostEvent* gev = GhostEvent::find (ev->note(), events, ignore_optiter); if (!gev) { return;