diff data/fileio/MIDIFileReader.cpp @ 965:2d5a8219b4b0

Backed out changeset 6b5e1edd95fc. I had misunderstood, the container is a vector, not a map, so the fix doesn't work and the original code (although definitely flawed) actually does
author Chris Cannam
date Wed, 03 Sep 2014 10:56:59 +0100
parents 6b5e1edd95fc
children 920699b6989d
line wrap: on
line diff
--- a/data/fileio/MIDIFileReader.cpp	Wed Sep 03 10:49:38 2014 +0100
+++ b/data/fileio/MIDIFileReader.cpp	Wed Sep 03 10:56:59 2014 +0100
@@ -661,10 +661,7 @@
     bool noteOffFound;
 
     for (MIDITrack::iterator i = m_midiComposition[track].begin();
-	 i != m_midiComposition[track].end(); ) {
-
-        MIDITrack::iterator nexti = i;
-        ++nexti; 
+	 i != m_midiComposition[track].end(); i++) {
 
         if ((*i)->getMessageType() == MIDI_NOTE_ON && (*i)->getVelocity() > 0) {
 
@@ -682,13 +679,6 @@
 
                     (*i)->setDuration((*j)->getTime() - (*i)->getTime());
 
-                    if (nexti == j) {
-                        // we're about to erase j, invalidating nexti
-                        // as well (but as this is a map, that is the
-                        // only iterator to be invalidated)
-                        ++nexti;
-                    }
-
                     delete *j;
                     m_midiComposition[track].erase(j);
 
@@ -706,8 +696,6 @@
                 (*i)->setDuration((*j)->getTime() - (*i)->getTime());
 	    }
         }
-
-        i = nexti;
     }
 
     return notesOnTrack;