Fix crash on out of range MIDI events (though this shouldn't be possible at all....
authorDavid Robillard <d@drobilla.net>
Fri, 16 May 2008 02:35:37 +0000 (02:35 +0000)
committerDavid Robillard <d@drobilla.net>
Fri, 16 May 2008 02:35:37 +0000 (02:35 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@3357 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/midi_region_view.cc
libs/ardour/midi_model.cc

index b9af0a81a2b5278d4ba26c75f29992e5e0603c95..d020a13d88a8dfd9de03cb998176d5890f30eaa9 100644 (file)
@@ -764,8 +764,8 @@ MidiRegionView::add_note(const boost::shared_ptr<Note> note)
                ev_rect->property_y2() = y1 + floor(midi_stream_view()->note_height());
 
                if (note->duration() == 0) {
-                       cerr << "MidiModel: WARNING: Discovered note with duration 0 and pitch" << note->note() 
-                            << " at time " << note->time() << endl;
+                       cerr << "MidiModel: WARNING: Discovered note with duration 0 and pitch"
+                               << (int)note->note() << " at time " << note->time() << endl;
                        if (_active_notes) {
                                assert(note->note() < 128);
                                _active_notes[note->note()] = ev_rect;
index b4e2c54d3cf95209da00fbed7902c557c2c9a3b1..88194236941b87ef3ac88d33e9fefbcffea1387d 100644 (file)
@@ -101,8 +101,12 @@ MidiModel::const_iterator::const_iterator(const MidiModel& model, double t)
                }
 
                assert(x >= 0);
-               assert(y >= i->first.min());
-               assert(y <= i->first.max());
+
+               if (y >= i->first.min() || y <= i->first.max()) {
+                       cerr << "ERROR: Event value '" << y << "' out of range ["
+                               << i->first.min() << "," << i->first.max() << "], ignored" << endl;
+                       continue;
+               }
 
                const MidiControlIterator new_iter(i->second->list(), x, y);