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.
This commit is contained in:
Alx Sa 2024-04-18 02:24:55 +00:00
parent dfb26f37e7
commit dbbdbb45e1
1 changed files with 11 additions and 6 deletions

View File

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