1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 09:18:11 +00:00

PixelPaint: Ensure a layer is selected when restoring a snapshot

Previously when restoring the starting snapshot in the UndoStack we
would end up with no layer selected, which was kinda annoying
This commit is contained in:
Marco Cutecchia 2021-09-25 19:39:11 +02:00 committed by Andreas Kling
parent 6108bac606
commit c7431da3f2

View file

@ -259,14 +259,21 @@ void Image::restore_snapshot(Image const& snapshot)
{
m_layers.clear();
select_layer(nullptr);
bool layer_selected = false;
for (const auto& snapshot_layer : snapshot.m_layers) {
auto layer = Layer::try_create_snapshot(*this, snapshot_layer);
VERIFY(layer);
if (layer->is_selected())
if (layer->is_selected()) {
select_layer(layer.ptr());
layer_selected = true;
}
add_layer(*layer);
}
if (!layer_selected)
select_layer(&layer(0));
did_modify_layer_stack();
}