From 3112a6b44f42cb3198cad247c6e3a0dcbd4ba796 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Mon, 27 Feb 2023 23:33:35 +0000 Subject: [PATCH] PixelPaint: Fix clicking on the layer menu with no image loaded Previously, clicking on the layer menu with no image loaded would cause a crash. --- Userland/Applications/PixelPaint/MainWidget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Applications/PixelPaint/MainWidget.cpp b/Userland/Applications/PixelPaint/MainWidget.cpp index d0e5c53d01..57911fa649 100644 --- a/Userland/Applications/PixelPaint/MainWidget.cpp +++ b/Userland/Applications/PixelPaint/MainWidget.cpp @@ -691,7 +691,8 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) if (!visible) return; - bool image_has_selection = !current_image_editor()->active_layer()->image().selection().is_empty(); + auto* editor = current_image_editor(); + bool image_has_selection = editor && editor->active_layer() && !editor->active_layer()->image().selection().is_empty(); m_layer_via_copy->set_enabled(image_has_selection); m_layer_via_cut->set_enabled(image_has_selection);