summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorMarco Cutecchia <marco.cutecchia@outlook.it>2021-04-04 11:05:43 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-04 22:43:30 +0200
commit1e912fb5a180a5b4e1b2c6ac576d34cfd53ba84a (patch)
tree97d2f3b43ee756bd63ba753e6f48659f6e391919 /Userland
parente8d2d73d55676a6528feb6656cd52db18f5dfe30 (diff)
downloadserenity-1e912fb5a180a5b4e1b2c6ac576d34cfd53ba84a.zip
PixelPaint: Avoid notifying image when creating a layer's snapshot
This fixes a bug where the application would crash if the user changed the default values for opacity or visibility of a layer and then tried to draw on it.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/PixelPaint/Layer.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/Userland/Applications/PixelPaint/Layer.cpp b/Userland/Applications/PixelPaint/Layer.cpp
index 8a0627d765..857ef4a350 100644
--- a/Userland/Applications/PixelPaint/Layer.cpp
+++ b/Userland/Applications/PixelPaint/Layer.cpp
@@ -55,10 +55,17 @@ RefPtr<Layer> Layer::create_with_bitmap(Image& image, const Gfx::Bitmap& bitmap,
RefPtr<Layer> Layer::create_snapshot(Image& image, const Layer& layer)
{
auto snapshot = create_with_bitmap(image, *layer.bitmap().clone(), layer.name());
- snapshot->set_opacity_percent(layer.opacity_percent());
- snapshot->set_visible(layer.is_visible());
+ /*
+ We set these properties directly because calling the setters might
+ notify the image of an update on the newly created layer, but this
+ layer has not yet been added to the image.
+ */
+ snapshot->m_opacity_percent = layer.opacity_percent();
+ snapshot->m_visible = layer.is_visible();
+
snapshot->set_selected(layer.is_selected());
snapshot->set_location(layer.location());
+
return snapshot;
}