handle searching for a note in an empty note list
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 20 Oct 2009 12:16:30 +0000 (12:16 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 20 Oct 2009 12:16:30 +0000 (12:16 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@5822 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/midi_model.cc

index 06beb4fa48f801031d2eaf339a5135b71413cf74..851ee49b46551c7a51d69118390ca9b1cb1da4cc 100644 (file)
@@ -719,10 +719,15 @@ MidiModel::get_state()
 boost::shared_ptr<Evoral::Note<MidiModel::TimeType> >
 MidiModel::find_note (boost::shared_ptr<Evoral::Note<TimeType> > other)
 {
-       for (Notes::iterator l = notes().lower_bound(other); (*l)->time() == other->time(); ++l) {
-               if (*l == other) {
-                       return *l;
+       Notes::iterator l = notes().lower_bound(other);
+
+       if (l != notes().end()) {
+               for (; (*l)->time() == other->time(); ++l) {
+                       if (*l == other) {
+                               return *l;
+                       }
                }
        }
+
        return boost::shared_ptr<Evoral::Note<TimeType> >();
 }