From 192513ec3324b03cfb3178c70b94cf9061fab936 Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Sun, 5 Apr 2020 09:26:29 +0200 Subject: [PATCH] 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. --- Applications/QuickShow/QSWidget.cpp | 6 ++++++ 1 file changed, 6 insertions(+) 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 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());