mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:47:45 +00:00
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.
This commit is contained in:
parent
9f6a09837b
commit
183a2ec8bd
1 changed files with 5 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
}));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue