From ac5f4792a8a7ce65f3f316b15ba6ef1b24539831 Mon Sep 17 00:00:00 2001 From: Caoimhe Date: Thu, 23 Mar 2023 18:38:22 +0000 Subject: [PATCH] ImageViewer: Fix crash when opening ImageViewer without an image Seems like a thing which slipped through the cracks... We shouldn't try to scale the image to the window's size if the bitmap doesn't exist. --- Userland/Applications/ImageViewer/ViewWidget.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/Applications/ImageViewer/ViewWidget.cpp b/Userland/Applications/ImageViewer/ViewWidget.cpp index a3dca258b5..61818e6d22 100644 --- a/Userland/Applications/ImageViewer/ViewWidget.cpp +++ b/Userland/Applications/ImageViewer/ViewWidget.cpp @@ -221,6 +221,9 @@ void ViewWidget::resize_event(GUI::ResizeEvent& event) void ViewWidget::scale_image_for_window() { + if (!m_bitmap) + return; + set_original_rect(m_bitmap->rect()); fit_content_to_view(GUI::AbstractZoomPanWidget::FitType::Both); }