son't try to select non-existent notes after editing (and thus crash).
[ardour.git] / gtk2_ardour / midi_region_view.cc
index c0d8a3c59968892b545cbc6b98a8fda0198cc5ec..fdd5f1b744e6ed9b8c3c6f8c5555d632bdf4eafd 100644 (file)
@@ -1675,7 +1675,7 @@ MidiRegionView::note_in_region_range (const boost::shared_ptr<NoteType> note, bo
 
        /* must compare double explicitly as Beats::operator< rounds to ppqn */
        const bool outside = (note->time().to_double() < midi_reg->start_beats() ||
-                             note->time().to_double() > midi_reg->start_beats() + midi_reg->length_beats());
+                             note->time().to_double() >= midi_reg->start_beats() + midi_reg->length_beats());
 
        visible = (note->note() >= midi_stream_view()->lowest_note()) &&
                (note->note() <= midi_stream_view()->highest_note());
@@ -3755,6 +3755,13 @@ MidiRegionView::update_ghost_note (double x, double y, uint32_t state)
        const bool shift_snap = midi_view()->note_mode() != Percussive;
        const Evoral::Beats snapped_beats = snap_frame_to_grid_underneath (unsnapped_frame, divisions, shift_snap);
 
+       /* prevent Percussive mode from displaying a ghost hit at region end */
+       if (!shift_snap && snapped_beats >= midi_region()->start_beats() + midi_region()->length_beats()) {
+               _ghost_note->hide();
+               hide_verbose_cursor ();
+               return;
+       }
+
        /* ghost note may have been snapped before region */
        if (_ghost_note && snapped_beats.to_double() < 0.0) {
                _ghost_note->hide();