1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:37:34 +00:00

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.
This commit is contained in:
Mustafa Quraish 2021-09-12 22:51:17 -04:00 committed by Andreas Kling
parent c0373c3119
commit 36bcd63c0c
3 changed files with 3 additions and 3 deletions

View file

@ -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)