Disallow midi-note duration changes beyond region boundaries
Fixes crash/assert with negative Beats. TODO discuss alternative: automatically extend/trim region (if possible) or accept but hide notes that are out of bounds. That would need some solution for ghost notes which still can have negative Beats while dragging.
This commit is contained in:
parent
4cde08cdb8
commit
f369208334
@ -2601,6 +2601,15 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_
|
||||
}
|
||||
}
|
||||
|
||||
if (current_x < 0) {
|
||||
// This works even with snapping because RegionView::snap_frame_to_frame()
|
||||
// snaps forward if the snapped sample is before the beginning of the region
|
||||
current_x = 0;
|
||||
}
|
||||
if (current_x > trackview.editor().sample_to_pixel(_region->length())) {
|
||||
current_x = trackview.editor().sample_to_pixel(_region->length());
|
||||
}
|
||||
|
||||
if (at_front) {
|
||||
resize_rect->set_x0 (snap_to_pixel(current_x));
|
||||
resize_rect->set_x1 (canvas_note->x1());
|
||||
@ -2675,6 +2684,13 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_
|
||||
}
|
||||
}
|
||||
|
||||
if (current_x < 0) {
|
||||
current_x = 0;
|
||||
}
|
||||
if (current_x > trackview.editor().sample_to_pixel(_region->length())) {
|
||||
current_x = trackview.editor().sample_to_pixel(_region->length());
|
||||
}
|
||||
|
||||
/* Convert that to a frame within the source */
|
||||
current_x = snap_pixel_to_sample (current_x) + _region->start ();
|
||||
|
||||
@ -3525,6 +3541,7 @@ MidiRegionView::create_ghost_note (double x, double y)
|
||||
_ghost_note = new Note (*this, _note_group, g);
|
||||
_ghost_note->set_ignore_events (true);
|
||||
_ghost_note->set_outline_color (0x000000aa);
|
||||
if (x < 0) { x = 0; }
|
||||
update_ghost_note (x, y);
|
||||
_ghost_note->show ();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user