Commit 4097d3c3 authored by Michael Natterer's avatar Michael Natterer 😴

app: add check that items passed through the PDB belong to the right image

Add "image" parameter to gimp_pdb_item_is_attached() and if non-NULL,
make sure the item is attached to that image, and not only attached to
any image. Change wrappers to pass an image where it makes sense.
parent 7609e3d8
......@@ -66,7 +66,7 @@ brightness_contrast_invoker (GimpProcedure *procedure,
if (success)
{
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable))
success = FALSE;
......@@ -107,7 +107,7 @@ levels_invoker (GimpProcedure *procedure,
if (success)
{
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable) ||
(! gimp_drawable_has_alpha (drawable) &&
......@@ -143,7 +143,7 @@ levels_auto_invoker (GimpProcedure *procedure,
if (success)
{
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable))
success = FALSE;
......@@ -171,7 +171,7 @@ levels_stretch_invoker (GimpProcedure *procedure,
if (success)
{
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable))
success = FALSE;
......@@ -201,7 +201,7 @@ posterize_invoker (GimpProcedure *procedure,
if (success)
{
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable))
success = FALSE;
......@@ -229,7 +229,7 @@ desaturate_invoker (GimpProcedure *procedure,
if (success)
{
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
! gimp_drawable_is_rgb (drawable))
success = FALSE;
......@@ -259,7 +259,7 @@ desaturate_full_invoker (GimpProcedure *procedure,
if (success)
{
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
! gimp_drawable_is_rgb (drawable))
success = FALSE;
......@@ -289,7 +289,7 @@ equalize_invoker (GimpProcedure *procedure,
if (success)
{
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable))
success = FALSE;
......@@ -317,7 +317,7 @@ invert_invoker (GimpProcedure *procedure,
if (success)
{
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable))
success = FALSE;
......@@ -351,7 +351,7 @@ curves_spline_invoker (GimpProcedure *procedure,
if (success)
{
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable) || (num_points & 1) ||
(! gimp_drawable_has_alpha (drawable) &&
......@@ -390,7 +390,7 @@ curves_explicit_invoker (GimpProcedure *procedure,
if (success)
{
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable) || (num_bytes != 256) ||
(! gimp_drawable_has_alpha (drawable) &&
......@@ -433,7 +433,7 @@ color_balance_invoker (GimpProcedure *procedure,
if (success)
{
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable))
success = FALSE;
......@@ -470,7 +470,7 @@ colorize_invoker (GimpProcedure *procedure,
if (success)
{
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
! gimp_drawable_is_rgb (drawable))
success = FALSE;
......@@ -512,7 +512,7 @@ histogram_invoker (GimpProcedure *procedure,
if (success)
{
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), FALSE, error) ||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, FALSE, error) ||
gimp_drawable_is_indexed (drawable) ||
(! gimp_drawable_has_alpha (drawable) &&
channel == GIMP_HISTOGRAM_ALPHA) ||
......@@ -580,7 +580,7 @@ hue_saturation_invoker (GimpProcedure *procedure,
if (success)
{
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable))
success = FALSE;
......@@ -613,7 +613,7 @@ threshold_invoker (GimpProcedure *procedure,
if (success)
{
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable) ||
(low_threshold > high_threshold))
......
......@@ -854,7 +854,7 @@ drawable_mask_bounds_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), FALSE, error))
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, FALSE, error))
non_empty = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
else
success = FALSE;
......@@ -896,7 +896,7 @@ drawable_mask_intersect_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), FALSE, error))
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, FALSE, error))
non_empty = gimp_drawable_mask_intersect (drawable,
&x, &y, &width, &height);
else
......@@ -935,7 +935,7 @@ drawable_merge_shadow_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
const gchar *undo_desc = _("Plug-In");
......@@ -1175,7 +1175,7 @@ drawable_offset_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
gimp_drawable_offset (drawable, context, wrap_around, fill_type,
offset_x, offset_y);
......@@ -1368,7 +1368,7 @@ drawable_foreground_extract_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), FALSE, error))
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, FALSE, error))
gimp_drawable_foreground_extract (drawable, mode, mask, progress);
else
success = FALSE;
......
......@@ -68,7 +68,7 @@ drawable_transform_flip_simple_invoker (GimpProcedure *procedure,
{
gint x, y, width, height;
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
......@@ -125,7 +125,7 @@ drawable_transform_flip_invoker (GimpProcedure *procedure,
{
gint x, y, width, height;
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
......@@ -196,7 +196,7 @@ drawable_transform_flip_default_invoker (GimpProcedure *procedure,
{
gint x, y, width, height;
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
......@@ -285,7 +285,7 @@ drawable_transform_perspective_invoker (GimpProcedure *procedure,
{
gint x, y, width, height;
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
......@@ -366,7 +366,7 @@ drawable_transform_perspective_default_invoker (GimpProcedure *procedure,
{
gint x, y, width, height;
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
......@@ -441,7 +441,7 @@ drawable_transform_rotate_simple_invoker (GimpProcedure *procedure,
{
gint x, y, width, height;
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), FALSE, error);
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, FALSE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
......@@ -498,7 +498,7 @@ drawable_transform_rotate_invoker (GimpProcedure *procedure,
{
gint x, y, width, height;
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
......@@ -573,7 +573,7 @@ drawable_transform_rotate_default_invoker (GimpProcedure *procedure,
{
gint x, y, width, height;
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
......@@ -658,7 +658,7 @@ drawable_transform_scale_invoker (GimpProcedure *procedure,
{
gint x, y, width, height;
success = (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) && x0 < x1 && y0 < y1);
success = (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) && x0 < x1 && y0 < y1);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
......@@ -730,7 +730,7 @@ drawable_transform_scale_default_invoker (GimpProcedure *procedure,
{
gint x, y, width, height;
success = (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) && x0 < x1 && y0 < y1);
success = (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) && x0 < x1 && y0 < y1);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
......@@ -808,7 +808,7 @@ drawable_transform_shear_invoker (GimpProcedure *procedure,
{
gint x, y, width, height;
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
......@@ -876,7 +876,7 @@ drawable_transform_shear_default_invoker (GimpProcedure *procedure,
{
gint x, y, width, height;
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
......@@ -964,7 +964,7 @@ drawable_transform_2d_invoker (GimpProcedure *procedure,
{
gint x, y, width, height;
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
......@@ -1043,7 +1043,7 @@ drawable_transform_2d_default_invoker (GimpProcedure *procedure,
{
gint x, y, width, height;
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
......@@ -1136,7 +1136,7 @@ drawable_transform_matrix_invoker (GimpProcedure *procedure,
{
gint x, y, width, height;
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
......@@ -1223,7 +1223,7 @@ drawable_transform_matrix_default_invoker (GimpProcedure *procedure,
{
gint x, y, width, height;
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
......
......@@ -64,7 +64,7 @@ edit_cut_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
......@@ -110,7 +110,7 @@ edit_copy_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), FALSE, error))
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, FALSE, error))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GError *my_error = NULL;
......@@ -197,7 +197,7 @@ edit_paste_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp->global_buffer &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
floating_sel = gimp_edit_paste (gimp_item_get_image (GIMP_ITEM (drawable)),
......@@ -272,7 +272,7 @@ edit_named_cut_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
......@@ -325,7 +325,7 @@ edit_named_copy_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), FALSE, error))
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, FALSE, error))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GError *my_error = NULL;
......@@ -428,7 +428,7 @@ edit_named_paste_invoker (GimpProcedure *procedure,
GimpBuffer *buffer = gimp_pdb_get_buffer (gimp, buffer_name, error);
if (buffer &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
floating_sel = gimp_edit_paste (gimp_item_get_image (GIMP_ITEM (drawable)),
......@@ -504,7 +504,7 @@ edit_clear_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
......@@ -536,7 +536,7 @@ edit_fill_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
......@@ -581,7 +581,7 @@ edit_bucket_fill_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
......@@ -638,7 +638,7 @@ edit_bucket_fill_full_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
......@@ -707,7 +707,7 @@ edit_blend_invoker (GimpProcedure *procedure,
if (success)
{
success = (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
success = (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error));
if (success && supersample)
......@@ -760,7 +760,7 @@ edit_stroke_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
......@@ -801,9 +801,10 @@ edit_stroke_vectors_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
gimp_pdb_item_is_attached (GIMP_ITEM (vectors), FALSE, error))
gimp_pdb_item_is_attached (GIMP_ITEM (vectors),
gimp_item_get_image (GIMP_ITEM (drawable)), FALSE, error))
{
GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE);
......
......@@ -152,7 +152,7 @@ floating_sel_attach_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
floating_sel_attach (layer, drawable);
else
......
......@@ -304,10 +304,12 @@ gimp_pdb_get_paint_info (Gimp *gimp,
gboolean
gimp_pdb_item_is_attached (GimpItem *item,
GimpImage *image,
gboolean writable,
GError **error)
{
g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
g_return_val_if_fail (image == NULL || GIMP_IS_IMAGE (image), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (! gimp_item_is_attached (item))
......@@ -320,6 +322,16 @@ gimp_pdb_item_is_attached (GimpItem *item,
return FALSE;
}
if (image && image != gimp_item_get_image (item))
{
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_INVALID_ARGUMENT,
_("Item '%s' (%d) can not be used because it is "
"attached to another image"),
gimp_object_get_name (item),
gimp_item_get_ID (item));
return FALSE;
}
if (writable)
return gimp_pdb_item_is_writable (item, error);
......@@ -414,7 +426,7 @@ gimp_pdb_layer_is_text_layer (GimpLayer *layer,
return FALSE;
}
return gimp_pdb_item_is_attached (GIMP_ITEM (layer), writable, error);
return gimp_pdb_item_is_attached (GIMP_ITEM (layer), NULL, writable, error);
}
static const gchar *
......
......@@ -49,6 +49,7 @@ GimpPaintInfo * gimp_pdb_get_paint_info (Gimp *gimp,
GError **error);
gboolean gimp_pdb_item_is_attached (GimpItem *item,
GimpImage *image,
gboolean writable,
GError **error);
gboolean gimp_pdb_item_is_floating (GimpItem *item,
......
......@@ -946,7 +946,7 @@ image_remove_layer_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), FALSE, error))
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), image, FALSE, error))
gimp_image_remove_layer (image, layer, TRUE, NULL);
else
success = FALSE;
......@@ -1140,7 +1140,7 @@ image_remove_channel_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (channel), FALSE, error))
if (gimp_pdb_item_is_attached (GIMP_ITEM (channel), image, FALSE, error))
gimp_image_remove_channel (image, channel, TRUE, NULL);
else
success = FALSE;
......@@ -1286,7 +1286,7 @@ image_remove_vectors_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (vectors), FALSE, error))
if (gimp_pdb_item_is_attached (GIMP_ITEM (vectors), image, FALSE, error))
gimp_image_remove_vectors (image, vectors, TRUE, NULL);
else
success = FALSE;
......@@ -1515,7 +1515,7 @@ image_merge_down_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (merge_layer), FALSE, error))
if (gimp_pdb_item_is_attached (GIMP_ITEM (merge_layer), image, FALSE, error))
{
layer = gimp_image_merge_down (image, merge_layer, context, merge_type,
error);
......@@ -1585,7 +1585,7 @@ image_remove_layer_mask_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), mode == GIMP_MASK_APPLY, error) &&
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), image, mode == GIMP_MASK_APPLY, error) &&
gimp_layer_get_mask (layer))
gimp_layer_apply_mask (layer, mode, TRUE);
else
......
......@@ -292,7 +292,7 @@ layer_scale_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), TRUE, error))
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), NULL, TRUE, error))
{
if (progress)
gimp_progress_start (progress, _("Scaling"), FALSE);
......@@ -337,7 +337,7 @@ layer_scale_full_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), TRUE, error))
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), NULL, TRUE, error))
{
if (progress)
gimp_progress_start (progress, _("Scaling"), FALSE);
......@@ -382,7 +382,7 @@ layer_resize_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), TRUE, error))
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), NULL, TRUE, error))
gimp_item_resize (GIMP_ITEM (layer), context,
new_width, new_height, offx, offy);
else
......@@ -408,7 +408,7 @@ layer_resize_to_image_size_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), TRUE, error))
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), NULL, TRUE, error))
gimp_layer_resize_to_image (layer, context);
else
success = FALSE;
......@@ -648,7 +648,7 @@ layer_remove_mask_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), mode == GIMP_MASK_APPLY, error) &&
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), NULL, mode == GIMP_MASK_APPLY, error) &&
gimp_layer_get_mask (layer))
gimp_layer_apply_mask (layer, mode, TRUE);
else
......
......@@ -117,7 +117,7 @@ airbrush_invoker (GimpProcedure *procedure,
GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-airbrush", error);
if (info &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpPaintOptions *options = gimp_paint_options_new (info);
......@@ -161,7 +161,7 @@ airbrush_default_invoker (GimpProcedure *procedure,
GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-airbrush", error);
if (info &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpPaintOptions *options = gimp_paint_options_new (info);
......@@ -209,7 +209,7 @@ clone_invoker (GimpProcedure *procedure,
GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-clone", error);
if (info &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpPaintOptions *options = gimp_paint_options_new (info);
......@@ -256,7 +256,7 @@ clone_default_invoker (GimpProcedure *procedure,
GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-clone", error);
if (info &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpPaintOptions *options = gimp_paint_options_new (info);
......@@ -300,7 +300,7 @@ convolve_invoker (GimpProcedure *procedure,
GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-convolve", error);
if (info &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpPaintOptions *options = gimp_paint_options_new (info);
......@@ -345,7 +345,7 @@ convolve_default_invoker (GimpProcedure *procedure,
GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-convolve", error);
if (info &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpPaintOptions *options = gimp_paint_options_new (info);
......@@ -391,7 +391,7 @@ dodgeburn_invoker (GimpProcedure *procedure,
GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-dodge-burn", error);
if (info &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpPaintOptions *options = gimp_paint_options_new (info);
......@@ -437,7 +437,7 @@ dodgeburn_default_invoker (GimpProcedure *procedure,
GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-dodge-burn", error);
if (info &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpPaintOptions *options = gimp_paint_options_new (info);
......@@ -481,7 +481,7 @@ eraser_invoker (GimpProcedure *procedure,
GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-eraser", error);
if (info &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpPaintOptions *options = gimp_paint_options_new (info);
......@@ -526,7 +526,7 @@ eraser_default_invoker (GimpProcedure *procedure,
GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-eraser", error);
if (info &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpPaintOptions *options = gimp_paint_options_new (info);
......@@ -572,7 +572,7 @@ heal_invoker (GimpProcedure *procedure,
GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-heal", error);
if (info &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpPaintOptions *options = gimp_paint_options_new (info);
......@@ -615,7 +615,7 @@ heal_default_invoker (GimpProcedure *procedure,
GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-heal", error);
if (info &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpPaintOptions *options = gimp_paint_options_new (info);
......@@ -661,7 +661,7 @@ paintbrush_invoker (GimpProcedure *procedure,
GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-paintbrush", error);
if (info &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpPaintOptions *options = gimp_paint_options_new (info);
......@@ -709,7 +709,7 @@ paintbrush_default_invoker (GimpProcedure *procedure,
GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-paintbrush", error);
if (info &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpPaintOptions *options = gimp_paint_options_new (info);
......@@ -749,7 +749,7 @@ pencil_invoker (GimpProcedure *procedure,
GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-pencil", error);
if (info &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpPaintOptions *options = gimp_paint_options_new (info);
......@@ -791,7 +791,7 @@ smudge_invoker (GimpProcedure *procedure,
GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-smudge", error);
if (info &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpPaintOptions *options = gimp_paint_options_new (info);
......@@ -835,7 +835,7 @@ smudge_default_invoker (GimpProcedure *procedure,
GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-smudge", error);