LibGUI: Fix ColorSlider crash when the selected hue is 360

If the ColorSlider returns a hue of 360 degrees one of the various
   `VERIFY(hsv.hue >= 0.0 && hsv.hue < 360.0);`
in Color.h will be hit.
This commit is contained in:
MacDue 2023-05-05 22:52:09 +01:00 committed by Andreas Kling
parent bd0bf8250e
commit 5f93f62f1c
Notes: sideshowbarker 2024-07-17 04:49:48 +09:00

View file

@ -705,6 +705,8 @@ void ColorSlider::pick_value_at_position(GUI::MouseEvent& event)
auto inner_rect = frame_inner_rect();
auto position = event.position().constrained(inner_rect).translated(-frame_thickness(), -frame_thickness());
auto hue = (double)position.y() / inner_rect.height() * 360;
if (hue >= 360)
hue -= 360;
m_last_position = position.y();
m_value = hue;