Prechádzať zdrojové kódy

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.
Caoimhe 2 rokov pred
rodič
commit
ac5f4792a8

+ 3 - 0
Userland/Applications/ImageViewer/ViewWidget.cpp

@@ -221,6 +221,9 @@ void ViewWidget::resize_event(GUI::ResizeEvent& event)
 
 
 void ViewWidget::scale_image_for_window()
 void ViewWidget::scale_image_for_window()
 {
 {
+    if (!m_bitmap)
+        return;
+
     set_original_rect(m_bitmap->rect());
     set_original_rect(m_bitmap->rect());
     fit_content_to_view(GUI::AbstractZoomPanWidget::FitType::Both);
     fit_content_to_view(GUI::AbstractZoomPanWidget::FitType::Both);
 }
 }