From f1a792e6c9fb39a51cdfb1e13222c61430846359 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Tue, 14 Feb 2023 23:35:10 +0000 Subject: [PATCH] PixelPaint: Save layer mask when adding to the UndoStack This makes undoing actions performed on layer masks work as expected. did_modify_bitmap() is now also called on redo, to ensure the layer mask is displayed correctly. --- Userland/Applications/PixelPaint/Image.cpp | 1 + Userland/Applications/PixelPaint/Layer.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp index f975daa0b0..b948383484 100644 --- a/Userland/Applications/PixelPaint/Image.cpp +++ b/Userland/Applications/PixelPaint/Image.cpp @@ -237,6 +237,7 @@ ErrorOr Image::restore_snapshot(Image const& snapshot) select_layer(layer.ptr()); layer_selected = true; } + layer->did_modify_bitmap({}, Layer::NotifyClients::No); add_layer(*layer); } diff --git a/Userland/Applications/PixelPaint/Layer.cpp b/Userland/Applications/PixelPaint/Layer.cpp index 5682580ee1..16922d2984 100644 --- a/Userland/Applications/PixelPaint/Layer.cpp +++ b/Userland/Applications/PixelPaint/Layer.cpp @@ -41,6 +41,10 @@ ErrorOr> Layer::create_snapshot(Image& image, Layer const& { auto bitmap = TRY(layer.content_bitmap().clone()); auto snapshot = TRY(create_with_bitmap(image, move(bitmap), layer.name())); + if (layer.is_masked()) { + snapshot->m_mask_bitmap = TRY(layer.mask_bitmap()->clone()); + snapshot->m_edit_mode = layer.m_edit_mode; + } /* We set these properties directly because calling the setters might