diff options
author | Mustafa Quraish <mustafaq9@gmail.com> | 2021-09-12 22:51:17 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-13 13:43:53 +0200 |
commit | 36bcd63c0c6adddc6882285e305f3dc52b46c518 (patch) | |
tree | 949ec02fab6847de4e93d69591325a1783b96937 /Userland/Applications/PixelPaint | |
parent | c0373c3119aec5372bde632cda89e4cd3e944166 (diff) | |
download | serenity-36bcd63c0c6adddc6882285e305f3dc52b46c518.zip |
PixelPaint: Ensure thickness of shapes is never 0 when drawing
When drawing a line/rectangle/ellipse in `Tool::on_second_paint()`,
if `m_thickness * m_editor->scale()` was less than one, it would
get converted to 0 because of truncation. This was causing infinite
loops somewhere in the painter code and causing the application to
freeze.
Fixes #9986.
Diffstat (limited to 'Userland/Applications/PixelPaint')
-rw-r--r-- | Userland/Applications/PixelPaint/EllipseTool.cpp | 2 | ||||
-rw-r--r-- | Userland/Applications/PixelPaint/LineTool.cpp | 2 | ||||
-rw-r--r-- | Userland/Applications/PixelPaint/RectangleTool.cpp | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Applications/PixelPaint/EllipseTool.cpp b/Userland/Applications/PixelPaint/EllipseTool.cpp index 6fd331eca8..5ace7869b5 100644 --- a/Userland/Applications/PixelPaint/EllipseTool.cpp +++ b/Userland/Applications/PixelPaint/EllipseTool.cpp @@ -101,7 +101,7 @@ void EllipseTool::on_second_paint(Layer const* layer, GUI::PaintEvent& event) painter.add_clip_rect(event.rect()); auto preview_start = m_editor->layer_position_to_editor_position(*layer, m_ellipse_start_position).to_type<int>(); auto preview_end = m_editor->layer_position_to_editor_position(*layer, m_ellipse_end_position).to_type<int>(); - draw_using(painter, preview_start, preview_end, m_thickness * m_editor->scale()); + draw_using(painter, preview_start, preview_end, AK::max(m_thickness * m_editor->scale(), 1)); } void EllipseTool::on_keydown(GUI::KeyEvent& event) diff --git a/Userland/Applications/PixelPaint/LineTool.cpp b/Userland/Applications/PixelPaint/LineTool.cpp index db673e0580..23e92b4602 100644 --- a/Userland/Applications/PixelPaint/LineTool.cpp +++ b/Userland/Applications/PixelPaint/LineTool.cpp @@ -109,7 +109,7 @@ void LineTool::on_second_paint(Layer const* layer, GUI::PaintEvent& event) painter.add_clip_rect(event.rect()); auto preview_start = m_editor->layer_position_to_editor_position(*layer, m_line_start_position).to_type<int>(); auto preview_end = m_editor->layer_position_to_editor_position(*layer, m_line_end_position).to_type<int>(); - painter.draw_line(preview_start, preview_end, m_editor->color_for(m_drawing_button), m_thickness * m_editor->scale()); + painter.draw_line(preview_start, preview_end, m_editor->color_for(m_drawing_button), AK::max(m_thickness * m_editor->scale(), 1)); } void LineTool::on_keydown(GUI::KeyEvent& event) diff --git a/Userland/Applications/PixelPaint/RectangleTool.cpp b/Userland/Applications/PixelPaint/RectangleTool.cpp index c1c08bcb8a..ec3bceeb1b 100644 --- a/Userland/Applications/PixelPaint/RectangleTool.cpp +++ b/Userland/Applications/PixelPaint/RectangleTool.cpp @@ -107,7 +107,7 @@ void RectangleTool::on_second_paint(Layer const* layer, GUI::PaintEvent& event) painter.add_clip_rect(event.rect()); auto start_position = m_editor->layer_position_to_editor_position(*layer, m_rectangle_start_position).to_type<int>(); auto end_position = m_editor->layer_position_to_editor_position(*layer, m_rectangle_end_position).to_type<int>(); - draw_using(painter, start_position, end_position, m_thickness * m_editor->scale()); + draw_using(painter, start_position, end_position, AK::max(m_thickness * m_editor->scale(), 1)); } void RectangleTool::on_keydown(GUI::KeyEvent& event) |