summaryrefslogtreecommitdiff
path: root/Userland/Applications/PixelPaint
diff options
context:
space:
mode:
authorMarcus Nilsson <brainbomb@gmail.com>2021-07-01 22:44:56 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-02 17:54:01 +0200
commit54d4df668aaafee54295c44a560d726baceecd89 (patch)
treec12f90905fb7625257a869aea86416dfd53e3073 /Userland/Applications/PixelPaint
parentdd3996e20755d1a970963ab899b58f7f4696c270 (diff)
downloadserenity-54d4df668aaafee54295c44a560d726baceecd89.zip
PixelPaint: Add layer to image before setting properties
Previously when opening an image with layers that had properties like visibility set, PixelPaint would crash when trying to trigger layer_did_modify_properties() without in image. Avoid this by adding the layer to the image before setting the properties.
Diffstat (limited to 'Userland/Applications/PixelPaint')
-rw-r--r--Userland/Applications/PixelPaint/Image.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp
index 6e4067c0f1..f9f93c8c43 100644
--- a/Userland/Applications/PixelPaint/Image.cpp
+++ b/Userland/Applications/PixelPaint/Image.cpp
@@ -125,12 +125,12 @@ Result<NonnullRefPtr<Image>, String> Image::try_create_from_pixel_paint_file(Str
if (width != layer->size().width() || height != layer->size().height())
return String { "Decoded layer bitmap has wrong size"sv };
+ image->add_layer(*layer);
+
layer->set_location({ layer_object.get("locationx").to_i32(), layer_object.get("locationy").to_i32() });
layer->set_opacity_percent(layer_object.get("opacity_percent").to_i32());
layer->set_visible(layer_object.get("visible").as_bool());
layer->set_selected(layer_object.get("selected").as_bool());
-
- image->add_layer(*layer);
}
image->set_path(file_path);