hydrogen-music/hydrogen — pull request #147 by elpescado (2014-03-17 21:37:50+00:00)
Title: Bugfix for Pattern::purge_instrument crash

Right clicking on an instrument and selecting "Clear all" crashes Hydrogen.

There's an error in `Pattern::purge_instrument` method. That method invalidated iterator while traversing pattern (iterator is invalidated by clearing notes). I have included simple test case (`src/tests/pattern.cpp`, pardon my C influences):

Instrument *i = new Instrument();
Note *n = new Note( i, 1, 1.0, 1.0, 1.0, 1, 1.0 );

Pattern *pat = new Pattern();
pat->insert_note( n );
ASSERT( pat->find_note( 1, -1, i) != NULL );

pat->purge_instrument( i ); // crashes here
ASSERT( pat->find_note( 1, -1, i) == NULL );

This may fix also https://github.com/hydrogen-music/hydrogen/issues/118