From 9ea15a84acb0b521f3c134f9279d87efdfee463a Mon Sep 17 00:00:00 2001 From: Oleg Sikorskiy Date: Wed, 17 Mar 2021 22:45:50 +0300 Subject: [PATCH] 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. --- Userland/Applications/Piano/RollWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Applications/Piano/RollWidget.cpp b/Userland/Applications/Piano/RollWidget.cpp index 2677fed384..cc63e7ee92 100644 --- a/Userland/Applications/Piano/RollWidget.cpp +++ b/Userland/Applications/Piano/RollWidget.cpp @@ -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());