From dbbdbb45e124d8237899d3715662f619c21d707e Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Thu, 18 Apr 2024 02:24:55 +0000 Subject: [PATCH] core: Fix filter mask when copied to new image Switch to using gimp_item_convert () instead of gimp_item_duplicate () so that the filter mask can be properly associated with a new image when copy/pasted. --- app/core/gimpdrawablefilter.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/core/gimpdrawablefilter.c b/app/core/gimpdrawablefilter.c index 0c56f2daa9..8dbab72dfb 100644 --- a/app/core/gimpdrawablefilter.c +++ b/app/core/gimpdrawablefilter.c @@ -356,6 +356,7 @@ GimpDrawableFilter * gimp_drawable_filter_duplicate (GimpDrawable *drawable, GimpDrawableFilter *prior_filter) { + GimpImage *image; GimpDrawableFilter *filter; GimpChannel *mask; GeglNode *prior_node; @@ -414,13 +415,17 @@ gimp_drawable_filter_duplicate (GimpDrawable *drawable, gimp_drawable_filter_set_region (filter, prior_filter->region); - mask = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (prior_filter->mask), - GIMP_TYPE_CHANNEL)); + image = gimp_item_get_image (GIMP_ITEM (drawable)); + if (image != NULL) + { + mask = GIMP_CHANNEL (gimp_item_convert (GIMP_ITEM (prior_filter->mask), + image, GIMP_TYPE_CHANNEL)); - g_object_set (filter, - "mask", mask, - NULL); - g_object_unref (mask); + g_object_set (filter, + "mask", mask, + NULL); + g_object_unref (mask); + } return filter; }