Browse Source

PixelPaint: Create an empty layer when the last layer is removed

Previously, when the last layer got deleted, the active layer was
set to nullptr, causing a crash.

Now, we create a new transparent background layer with the image
dimensions instead.
Felix Rauch 3 năm trước cách đây
mục cha
commit
183a2ec8bd
1 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 5 1
      Userland/Applications/PixelPaint/MainWidget.cpp

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

@@ -529,7 +529,11 @@ void MainWidget::initialize_menubar(GUI::Window& window)
                 auto& next_active_layer = editor->image().layer(active_layer_index > 0 ? active_layer_index - 1 : 0);
                 editor->set_active_layer(&next_active_layer);
             } else {
-                editor->set_active_layer(nullptr);
+                auto layer = PixelPaint::Layer::try_create_with_size(editor->image(), editor->image().size(), "Background");
+                VERIFY(layer);
+                editor->image().add_layer(layer.release_nonnull());
+                editor->layers_did_change();
+                m_layer_list_widget->select_top_layer();
             }
         }));