diff options
author | Tibor Nagy <xnagytibor@gmail.com> | 2020-04-05 09:26:29 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-05 09:36:46 +0200 |
commit | 192513ec3324b03cfb3178c70b94cf9061fab936 (patch) | |
tree | 0683cab7c39a1e9ebbfa3f67221731530d599059 /Applications | |
parent | 4e54d0ff21149eba820b7f12ddd3a5b0e0fecbc7 (diff) | |
download | serenity-192513ec3324b03cfb3178c70b94cf9061fab936.zip |
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.
Diffstat (limited to 'Applications')
-rw-r--r-- | Applications/QuickShow/QSWidget.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Applications/QuickShow/QSWidget.cpp b/Applications/QuickShow/QSWidget.cpp index ca8e206e77..511bf50ec7 100644 --- a/Applications/QuickShow/QSWidget.cpp +++ b/Applications/QuickShow/QSWidget.cpp @@ -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()); |