mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-03-06 21:45:29 +00:00
QuickShow: Fix crash on startup
QSWidget::relayout get triggered before setting a bitmap to display while setting the widget as the main widget of the window. I've added a null check to the paint event too to make sure the widget works with no bitmap set.
This commit is contained in:
committed by
Andreas Kling
parent
4e54d0ff21
commit
192513ec33
@@ -49,6 +49,9 @@ void QSWidget::set_bitmap(NonnullRefPtr<Gfx::Bitmap> bitmap)
|
||||
|
||||
void QSWidget::relayout()
|
||||
{
|
||||
if (m_bitmap.is_null())
|
||||
return;
|
||||
|
||||
Gfx::Size new_size;
|
||||
float scale_factor = (float)m_scale / 100.0f;
|
||||
new_size.set_width(m_bitmap->width() * scale_factor);
|
||||
@@ -65,6 +68,9 @@ void QSWidget::resize_event(GUI::ResizeEvent& event)
|
||||
|
||||
void QSWidget::paint_event(GUI::PaintEvent& event)
|
||||
{
|
||||
if (m_bitmap.is_null())
|
||||
return;
|
||||
|
||||
GUI::Painter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user