Piano: Avoid selecting out of range notes.

Fixes #5736. The selected note value could also underflow if
you drag to the left, but the assert got triggered only in
case you're dragging past the end of the note roll.
This commit is contained in:
Oleg Sikorskiy 2021-03-17 22:45:50 +03:00 committed by Andreas Kling
parent ea7bdf02b8
commit 9ea15a84ac
Notes: sideshowbarker 2024-07-18 21:16:15 +09:00

View file

@ -191,7 +191,7 @@ void RollWidget::mousemove_event(GUI::MouseEvent& event)
if (note_width_is_fractional && x_is_not_last)
++x;
x /= m_note_width;
return x;
return clamp(x, 0, m_num_notes - 1);
};
int x0 = get_note_x(m_note_drag_start.value().x());