From 6e80f9839066c2bddcda82ab9fbaacffd67f092e Mon Sep 17 00:00:00 2001 From: Gabriele Barbero Date: Thu, 28 Aug 2025 21:29:04 +0200 Subject: [PATCH] plug-ins: use a temporary image to get the buffer... ...with filters during Recompose Previously, get_buffer_with_filters() inserted and removed a temporary copy of a layer in the original image. This caused the image to appear modified, adding entries in the undo history and prompting the user to save changes, even though the image itself was not actually changed. This patch modifies the function to create a temporary image and perform the layer insert operation there. Filters are applied as before, but the original image remains untouched, avoiding unwanted undo entries and mark the image as modified. --- plug-ins/common/compose.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plug-ins/common/compose.c b/plug-ins/common/compose.c index e0ca83f6b0..fbfa9f1b8c 100644 --- a/plug-ins/common/compose.c +++ b/plug-ins/common/compose.c @@ -862,13 +862,17 @@ static GeglBuffer * get_buffer_with_filters (GimpLayer *layer) { GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer)); - GimpLayer *temp = gimp_layer_copy (layer); + GimpImage *tmp_image; + GimpLayer *temp; GeglBuffer *src_buffer; GeglBuffer *dst_buffer; - gimp_image_insert_layer (image, temp, NULL, - gimp_image_get_item_position (image, - GIMP_ITEM (layer))); + tmp_image = gimp_image_new (gimp_image_get_width (image), + gimp_image_get_height (image), + gimp_image_get_base_type (image)); + temp = gimp_layer_new_from_drawable (GIMP_DRAWABLE (layer), tmp_image); + + gimp_image_insert_layer (tmp_image, temp, NULL, 0); gimp_drawable_merge_filters (GIMP_DRAWABLE (temp)); @@ -878,8 +882,8 @@ get_buffer_with_filters (GimpLayer *layer) gegl_buffer_copy (src_buffer, NULL, GEGL_ABYSS_NONE, dst_buffer, NULL); - gimp_image_remove_layer (image, temp); g_object_unref (src_buffer); + gimp_image_delete (tmp_image); return dst_buffer; }