diff --git a/gtk2_ardour/ghostregion.cc b/gtk2_ardour/ghostregion.cc index d76abd6659..e95a2b4950 100644 --- a/gtk2_ardour/ghostregion.cc +++ b/gtk2_ardour/ghostregion.cc @@ -356,11 +356,14 @@ MidiGhostRegion::add_note (NoteBase* n) void MidiGhostRegion::clear_events() { - for (EventList::iterator it = events.begin(); it != events.end(); ++it) { + EventList::iterator it = events.begin(); + + while (it != events.end()) { delete (*it).second; + events.erase (it); + ++it; } - events.clear(); _optimization_iterator = events.end (); }