From: David Robillard Date: Mon, 16 Feb 2009 00:16:28 +0000 (+0000) Subject: Rewrite Sequence::const_iterator. X-Git-Tag: 3.0-alpha5~3670 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=473170200d3ce2a96b1425b6dfd57003124d8276;p=ardour.git Rewrite Sequence::const_iterator. Fixes crash bug when seeking back and forth from start to end of session. Not sure about other things, but it makes a lot more sense now anyway... git-svn-id: svn://localhost/ardour2/branches/3.0@4590 d708f5d6-7413-0410-9779-e7cbd77b26cf --- diff --git a/libs/ardour/ardour/midi_buffer.h b/libs/ardour/ardour/midi_buffer.h index 8ea5e32e81..4cd4cfea6b 100644 --- a/libs/ardour/ardour/midi_buffer.h +++ b/libs/ardour/ardour/midi_buffer.h @@ -52,25 +52,25 @@ public: bool merge(const MidiBuffer& a, const MidiBuffer& b); bool merge_in_place(const MidiBuffer &other); - template + template struct iterator_base { - iterator_base(BufferType& b, size_t o) : buffer(b), offset(o) {} - inline MIDIEventType operator*() const { + iterator_base(BufferType& b, size_t o) : buffer(b), offset(o) {} + inline EventType operator*() const { uint8_t* ev_start = buffer._data + offset + sizeof(TimeType); int event_size = Evoral::midi_event_size(ev_start); assert(event_size >= 0); - return MIDIEventType(EventTypeMap::instance().midi_event_type(*ev_start), + return EventType(EventTypeMap::instance().midi_event_type(*ev_start), *((TimeType*)(buffer._data + offset)), event_size, ev_start); } - inline iterator_base& operator++() { + inline iterator_base& operator++() { uint8_t* ev_start = buffer._data + offset + sizeof(TimeType); int event_size = Evoral::midi_event_size(ev_start); assert(event_size >= 0); offset += sizeof(TimeType) + event_size; return *this; } - inline bool operator!=(const iterator_base& other) const { + inline bool operator!=(const iterator_base& other) const { return (&buffer != &other.buffer) || (offset != other.offset); } BufferType& buffer; diff --git a/libs/evoral/evoral/Sequence.hpp b/libs/evoral/evoral/Sequence.hpp index 4273b893f7..30c1c1f0ca 100644 --- a/libs/evoral/evoral/Sequence.hpp +++ b/libs/evoral/evoral/Sequence.hpp @@ -83,8 +83,8 @@ public: /** Resizes vector if necessary (NOT realtime safe) */ void append(const Event