flutter_sequencer icon indicating copy to clipboard operation
flutter_sequencer copied to clipboard

Crash when calling destroy() on Sequence

Open andreasmpet opened this issue 2 years ago • 0 comments

Hi!

I noticed that in Sequence's destroy() method you're iterating through a collection with forEach at the same time as you're modifying it. Not sure how this has worked before. Maybe some behavior of how iterating through the values of a map has changed recently.

void destroy() {
    _tracks.values.forEach((track) => deleteTrack(track));
    globalState.unregisterSequence(this);
}

deleteTrack now seems to be modifying the collection we are iterating through it. A simple solution is to copy the list of track to a list before iterating through it, or just using _tracks.values.toList().forEach instead.

andreasmpet avatar May 19 '22 11:05 andreasmpet