mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:27:43 +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:
parent
c0373c3119
commit
36bcd63c0c
3 changed files with 3 additions and 3 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue