diff options
author | Oleg Sikorskiy <olegsik@gmail.com> | 2021-03-17 22:45:50 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-17 21:58:26 +0100 |
commit | 9ea15a84acb0b521f3c134f9279d87efdfee463a (patch) | |
tree | 7bf5f58952e9413a800d8c1eb80e449803ee186f | |
parent | ea7bdf02b810d567cb72d0364dca55844cd4e530 (diff) | |
download | serenity-9ea15a84acb0b521f3c134f9279d87efdfee463a.zip |
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.
-rw-r--r-- | Userland/Applications/Piano/RollWidget.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
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()); |