13
0

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
This commit is contained in:
Paul Davis 2024-11-10 12:44:05 -07:00
parent 96ef4d20f2
commit cdf88efeff

View File

@ -203,12 +203,15 @@ VelocityDisplay::set_size_and_position (GhostEvent& gev)
void void
VelocityDisplay::update_note (NoteBase* nb) 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) { if (!gev) {
return; return;
} }
_optimization_iterator = iter;
update_ghost_event (gev); update_ghost_event (gev);
} }
@ -319,7 +322,9 @@ VelocityDisplay::y_position_to_velocity (double y) const
void void
VelocityDisplay::note_selected (NoteBase* ev) 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) { if (!gev) {
return; return;