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.
This commit is contained in:
Marco Cutecchia 2021-04-04 11:05:43 +02:00 committed by Andreas Kling
parent e8d2d73d55
commit 1e912fb5a1
Notes: sideshowbarker 2024-07-18 20:47:31 +09:00

View file

@ -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;
}