瀏覽代碼

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.
Tim Ledbetter 2 年之前
父節點
當前提交
3112a6b44f
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      Userland/Applications/PixelPaint/MainWidget.cpp

+ 2 - 1
Userland/Applications/PixelPaint/MainWidget.cpp

@@ -691,7 +691,8 @@ ErrorOr<void> 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);