From 1f695014b49da3748c253f7d982978b5cfdf4cec Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 30 Jun 2014 11:02:23 -0400 Subject: protect use of iterators across routeUI selection when operations change the selection (e.g. deletion) --- gtk2_ardour/track_selection.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/track_selection.h b/gtk2_ardour/track_selection.h index d94ec3c8c1..2e9927ab42 100644 --- a/gtk2_ardour/track_selection.h +++ b/gtk2_ardour/track_selection.h @@ -46,41 +46,54 @@ public: template void foreach_route_ui (Function f) { - for (iterator i = begin(); i != end(); ++i) { + for (iterator i = begin(); i != end(); ) { + iterator tmp = i; + ++tmp; + RouteUI* t = dynamic_cast (*i); if (t) { f (t); } + i = tmp; } } template void foreach_route_time_axis (Function f) { - for (iterator i = begin(); i != end(); ++i) { + for (iterator i = begin(); i != end(); ) { + iterator tmp = i; + ++tmp; RouteTimeAxisView* t = dynamic_cast (*i); if (t) { f (t); } + i = tmp; } } template void foreach_audio_time_axis (Function f) { - for (iterator i = begin(); i != end(); ++i) { + for (iterator i = begin(); i != end(); ) { + iterator tmp = i; + ++tmp; AudioTimeAxisView* t = dynamic_cast (*i); if (t) { f (t); } + i = tmp; } } template void foreach_midi_time_axis (Function f) { - for (iterator i = begin(); i != end(); ++i) { + for (iterator i = begin(); i != end(); ) { + iterator tmp = i; + ++tmp; MidiTimeAxisView* t = dynamic_cast (*i); if (t) { f (t); } + i = tmp; } } -- cgit v1.2.3