summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-12-09 21:35:33 +0000
committerCarl Hetherington <carl@carlh.net>2010-12-09 21:35:33 +0000
commitad916f6241011266fea05877685376a06ec586bf (patch)
tree69d22d02c76d7f95b506a8a141d8af0fc9fa2d94
parent74385f96428536c4d71f0b9fb88ffdda691ebc89 (diff)
Fix a few bad iterator accesses.
git-svn-id: svn://localhost/ardour2/branches/3.0@8231 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--libs/evoral/src/Sequence.cpp35
1 files changed, 27 insertions, 8 deletions
diff --git a/libs/evoral/src/Sequence.cpp b/libs/evoral/src/Sequence.cpp
index 5c6f492a36..b71e6920d8 100644
--- a/libs/evoral/src/Sequence.cpp
+++ b/libs/evoral/src/Sequence.cpp
@@ -580,6 +580,7 @@ Sequence<Time>::end_write (bool delete_stuck)
for (typename Notes::iterator n = _notes.begin(); n != _notes.end() ;) {
typename Notes::iterator next = n;
++next;
+
if ((*n)->length() == 0) {
cerr << "WARNING: Stuck note lost: " << (*n)->note() << endl;
_notes.erase(n);
@@ -642,15 +643,20 @@ Sequence<Time>::remove_note_unlocked(const constNotePtr note)
DEBUG_TRACE (DEBUG::Sequence, string_compose ("%1 remove note %2 @ %3\n", this, (int)note->note(), note->time()));
- for (typename Sequence<Time>::Notes::iterator i = note_lower_bound(note->time());
- i != _notes.end() && (*i)->time() == note->time(); ++i) {
+ typename Sequence<Time>::Notes::iterator i = note_lower_bound(note->time());
+ while (i != _notes.end() && (*i)->time() == note->time()) {
+
+ typename Sequence<Time>::Notes::iterator tmp = i;
+ ++tmp;
if (*i == note) {
+
+ NotePtr n = *i;
DEBUG_TRACE (DEBUG::Sequence, string_compose ("%1\terasing note %2 @ %3\n", this, (int)(*i)->note(), (*i)->time()));
_notes.erase (i);
- if ((*i)->note() == _lowest_note || (*i)->note() == _highest_note) {
+ if (n->note() == _lowest_note || n->note() == _highest_note) {
_lowest_note = 127;
_highest_note = 0;
@@ -665,18 +671,25 @@ Sequence<Time>::remove_note_unlocked(const constNotePtr note)
erased = true;
}
+
+ i = tmp;
}
Pitches& p (pitches (note->channel()));
NotePtr search_note(new Note<Time>(0, 0, 0, note->note(), 0));
- for (typename Pitches::iterator i = p.lower_bound (search_note);
- i != p.end() && (*i)->note() == note->note(); ++i) {
- if (*i == note) {
+ typename Pitches::iterator j = p.lower_bound (search_note);
+ while (j != p.end() && (*j)->note() == note->note()) {
+ typename Pitches::iterator tmp = j;
+ ++tmp;
+
+ if (*j == note) {
DEBUG_TRACE (DEBUG::Sequence, string_compose ("%1\terasing pitch %2 @ %3\n", this, (int)(*i)->note(), (*i)->time()));
- p.erase (i);
+ p.erase (j);
}
+
+ j = tmp;
}
if (!erased) {
@@ -806,7 +819,11 @@ Sequence<Time>::append_note_off_unlocked (NotePtr note)
/* XXX use _overlap_pitch_resolution to determine FIFO/LIFO ... */
- for (typename WriteNotes::iterator n = _write_notes[note->channel()].begin(); n != _write_notes[note->channel()].end(); ++n) {
+ for (typename WriteNotes::iterator n = _write_notes[note->channel()].begin(); n != _write_notes[note->channel()].end(); ) {
+
+ typename WriteNotes::iterator tmp = n;
+ ++tmp;
+
NotePtr nn = *n;
if (note->note() == nn->note() && nn->channel() == note->channel()) {
assert(note->time() >= nn->time());
@@ -819,6 +836,8 @@ Sequence<Time>::append_note_off_unlocked (NotePtr note)
resolved = true;
break;
}
+
+ n = tmp;
}
if (!resolved) {