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, ...@@ -66,7 +66,7 @@ brightness_contrast_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable)) gimp_drawable_is_indexed (drawable))
success = FALSE; success = FALSE;
...@@ -107,7 +107,7 @@ levels_invoker (GimpProcedure *procedure, ...@@ -107,7 +107,7 @@ levels_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable) || gimp_drawable_is_indexed (drawable) ||
(! gimp_drawable_has_alpha (drawable) && (! gimp_drawable_has_alpha (drawable) &&
...@@ -143,7 +143,7 @@ levels_auto_invoker (GimpProcedure *procedure, ...@@ -143,7 +143,7 @@ levels_auto_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable)) gimp_drawable_is_indexed (drawable))
success = FALSE; success = FALSE;
...@@ -171,7 +171,7 @@ levels_stretch_invoker (GimpProcedure *procedure, ...@@ -171,7 +171,7 @@ levels_stretch_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable)) gimp_drawable_is_indexed (drawable))
success = FALSE; success = FALSE;
...@@ -201,7 +201,7 @@ posterize_invoker (GimpProcedure *procedure, ...@@ -201,7 +201,7 @@ posterize_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable)) gimp_drawable_is_indexed (drawable))
success = FALSE; success = FALSE;
...@@ -229,7 +229,7 @@ desaturate_invoker (GimpProcedure *procedure, ...@@ -229,7 +229,7 @@ desaturate_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error) ||
! gimp_drawable_is_rgb (drawable)) ! gimp_drawable_is_rgb (drawable))
success = FALSE; success = FALSE;
...@@ -259,7 +259,7 @@ desaturate_full_invoker (GimpProcedure *procedure, ...@@ -259,7 +259,7 @@ desaturate_full_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error) ||
! gimp_drawable_is_rgb (drawable)) ! gimp_drawable_is_rgb (drawable))
success = FALSE; success = FALSE;
...@@ -289,7 +289,7 @@ equalize_invoker (GimpProcedure *procedure, ...@@ -289,7 +289,7 @@ equalize_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable)) gimp_drawable_is_indexed (drawable))
success = FALSE; success = FALSE;
...@@ -317,7 +317,7 @@ invert_invoker (GimpProcedure *procedure, ...@@ -317,7 +317,7 @@ invert_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable)) gimp_drawable_is_indexed (drawable))
success = FALSE; success = FALSE;
...@@ -351,7 +351,7 @@ curves_spline_invoker (GimpProcedure *procedure, ...@@ -351,7 +351,7 @@ curves_spline_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable) || (num_points & 1) || gimp_drawable_is_indexed (drawable) || (num_points & 1) ||
(! gimp_drawable_has_alpha (drawable) && (! gimp_drawable_has_alpha (drawable) &&
...@@ -390,7 +390,7 @@ curves_explicit_invoker (GimpProcedure *procedure, ...@@ -390,7 +390,7 @@ curves_explicit_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable) || (num_bytes != 256) || gimp_drawable_is_indexed (drawable) || (num_bytes != 256) ||
(! gimp_drawable_has_alpha (drawable) && (! gimp_drawable_has_alpha (drawable) &&
...@@ -433,7 +433,7 @@ color_balance_invoker (GimpProcedure *procedure, ...@@ -433,7 +433,7 @@ color_balance_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable)) gimp_drawable_is_indexed (drawable))
success = FALSE; success = FALSE;
...@@ -470,7 +470,7 @@ colorize_invoker (GimpProcedure *procedure, ...@@ -470,7 +470,7 @@ colorize_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error) ||
! gimp_drawable_is_rgb (drawable)) ! gimp_drawable_is_rgb (drawable))
success = FALSE; success = FALSE;
...@@ -512,7 +512,7 @@ histogram_invoker (GimpProcedure *procedure, ...@@ -512,7 +512,7 @@ histogram_invoker (GimpProcedure *procedure,
if (success) 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_is_indexed (drawable) ||
(! gimp_drawable_has_alpha (drawable) && (! gimp_drawable_has_alpha (drawable) &&
channel == GIMP_HISTOGRAM_ALPHA) || channel == GIMP_HISTOGRAM_ALPHA) ||
...@@ -580,7 +580,7 @@ hue_saturation_invoker (GimpProcedure *procedure, ...@@ -580,7 +580,7 @@ hue_saturation_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable)) gimp_drawable_is_indexed (drawable))
success = FALSE; success = FALSE;
...@@ -613,7 +613,7 @@ threshold_invoker (GimpProcedure *procedure, ...@@ -613,7 +613,7 @@ threshold_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error) ||
gimp_drawable_is_indexed (drawable) || gimp_drawable_is_indexed (drawable) ||
(low_threshold > high_threshold)) (low_threshold > high_threshold))
......
...@@ -854,7 +854,7 @@ drawable_mask_bounds_invoker (GimpProcedure *procedure, ...@@ -854,7 +854,7 @@ drawable_mask_bounds_invoker (GimpProcedure *procedure,
if (success) 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); non_empty = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
else else
success = FALSE; success = FALSE;
...@@ -896,7 +896,7 @@ drawable_mask_intersect_invoker (GimpProcedure *procedure, ...@@ -896,7 +896,7 @@ drawable_mask_intersect_invoker (GimpProcedure *procedure,
if (success) 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, non_empty = gimp_drawable_mask_intersect (drawable,
&x, &y, &width, &height); &x, &y, &width, &height);
else else
...@@ -935,7 +935,7 @@ drawable_merge_shadow_invoker (GimpProcedure *procedure, ...@@ -935,7 +935,7 @@ drawable_merge_shadow_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error))
{ {
const gchar *undo_desc = _("Plug-In"); const gchar *undo_desc = _("Plug-In");
...@@ -1175,7 +1175,7 @@ drawable_offset_invoker (GimpProcedure *procedure, ...@@ -1175,7 +1175,7 @@ drawable_offset_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error))
gimp_drawable_offset (drawable, context, wrap_around, fill_type, gimp_drawable_offset (drawable, context, wrap_around, fill_type,
offset_x, offset_y); offset_x, offset_y);
...@@ -1368,7 +1368,7 @@ drawable_foreground_extract_invoker (GimpProcedure *procedure, ...@@ -1368,7 +1368,7 @@ drawable_foreground_extract_invoker (GimpProcedure *procedure,
if (success) 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); gimp_drawable_foreground_extract (drawable, mode, mask, progress);
else else
success = FALSE; success = FALSE;
......
...@@ -68,7 +68,7 @@ drawable_transform_flip_simple_invoker (GimpProcedure *procedure, ...@@ -68,7 +68,7 @@ drawable_transform_flip_simple_invoker (GimpProcedure *procedure,
{ {
gint x, y, width, height; 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 && if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
...@@ -125,7 +125,7 @@ drawable_transform_flip_invoker (GimpProcedure *procedure, ...@@ -125,7 +125,7 @@ drawable_transform_flip_invoker (GimpProcedure *procedure,
{ {
gint x, y, width, height; 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 && if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
...@@ -196,7 +196,7 @@ drawable_transform_flip_default_invoker (GimpProcedure *procedure, ...@@ -196,7 +196,7 @@ drawable_transform_flip_default_invoker (GimpProcedure *procedure,
{ {
gint x, y, width, height; 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 && if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
...@@ -285,7 +285,7 @@ drawable_transform_perspective_invoker (GimpProcedure *procedure, ...@@ -285,7 +285,7 @@ drawable_transform_perspective_invoker (GimpProcedure *procedure,
{ {
gint x, y, width, height; 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 && if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
...@@ -366,7 +366,7 @@ drawable_transform_perspective_default_invoker (GimpProcedure *procedure, ...@@ -366,7 +366,7 @@ drawable_transform_perspective_default_invoker (GimpProcedure *procedure,
{ {
gint x, y, width, height; 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 && if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
...@@ -441,7 +441,7 @@ drawable_transform_rotate_simple_invoker (GimpProcedure *procedure, ...@@ -441,7 +441,7 @@ drawable_transform_rotate_simple_invoker (GimpProcedure *procedure,
{ {
gint x, y, width, height; 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 && if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
...@@ -498,7 +498,7 @@ drawable_transform_rotate_invoker (GimpProcedure *procedure, ...@@ -498,7 +498,7 @@ drawable_transform_rotate_invoker (GimpProcedure *procedure,
{ {
gint x, y, width, height; 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 && if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
...@@ -573,7 +573,7 @@ drawable_transform_rotate_default_invoker (GimpProcedure *procedure, ...@@ -573,7 +573,7 @@ drawable_transform_rotate_default_invoker (GimpProcedure *procedure,
{ {
gint x, y, width, height; 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 && if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
...@@ -658,7 +658,7 @@ drawable_transform_scale_invoker (GimpProcedure *procedure, ...@@ -658,7 +658,7 @@ drawable_transform_scale_invoker (GimpProcedure *procedure,
{ {
gint x, y, width, height; 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 && if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
...@@ -730,7 +730,7 @@ drawable_transform_scale_default_invoker (GimpProcedure *procedure, ...@@ -730,7 +730,7 @@ drawable_transform_scale_default_invoker (GimpProcedure *procedure,
{ {
gint x, y, width, height; 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 && if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
...@@ -808,7 +808,7 @@ drawable_transform_shear_invoker (GimpProcedure *procedure, ...@@ -808,7 +808,7 @@ drawable_transform_shear_invoker (GimpProcedure *procedure,
{ {
gint x, y, width, height; 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 && if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
...@@ -876,7 +876,7 @@ drawable_transform_shear_default_invoker (GimpProcedure *procedure, ...@@ -876,7 +876,7 @@ drawable_transform_shear_default_invoker (GimpProcedure *procedure,
{ {
gint x, y, width, height; 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 && if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
...@@ -964,7 +964,7 @@ drawable_transform_2d_invoker (GimpProcedure *procedure, ...@@ -964,7 +964,7 @@ drawable_transform_2d_invoker (GimpProcedure *procedure,
{ {
gint x, y, width, height; 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 && if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
...@@ -1043,7 +1043,7 @@ drawable_transform_2d_default_invoker (GimpProcedure *procedure, ...@@ -1043,7 +1043,7 @@ drawable_transform_2d_default_invoker (GimpProcedure *procedure,
{ {
gint x, y, width, height; 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 && if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
...@@ -1136,7 +1136,7 @@ drawable_transform_matrix_invoker (GimpProcedure *procedure, ...@@ -1136,7 +1136,7 @@ drawable_transform_matrix_invoker (GimpProcedure *procedure,
{ {
gint x, y, width, height; 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 && if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
...@@ -1223,7 +1223,7 @@ drawable_transform_matrix_default_invoker (GimpProcedure *procedure, ...@@ -1223,7 +1223,7 @@ drawable_transform_matrix_default_invoker (GimpProcedure *procedure,
{ {
gint x, y, width, height; 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 && if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
......
...@@ -64,7 +64,7 @@ edit_cut_invoker (GimpProcedure *procedure, ...@@ -64,7 +64,7 @@ edit_cut_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error))
{ {
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
...@@ -110,7 +110,7 @@ edit_copy_invoker (GimpProcedure *procedure, ...@@ -110,7 +110,7 @@ edit_copy_invoker (GimpProcedure *procedure,
if (success) 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)); GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GError *my_error = NULL; GError *my_error = NULL;
...@@ -197,7 +197,7 @@ edit_paste_invoker (GimpProcedure *procedure, ...@@ -197,7 +197,7 @@ edit_paste_invoker (GimpProcedure *procedure,
if (success) if (success)
{ {
if (gimp->global_buffer && 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)) gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{ {
floating_sel = gimp_edit_paste (gimp_item_get_image (GIMP_ITEM (drawable)), floating_sel = gimp_edit_paste (gimp_item_get_image (GIMP_ITEM (drawable)),
...@@ -272,7 +272,7 @@ edit_named_cut_invoker (GimpProcedure *procedure, ...@@ -272,7 +272,7 @@ edit_named_cut_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error))
{ {
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
...@@ -325,7 +325,7 @@ edit_named_copy_invoker (GimpProcedure *procedure, ...@@ -325,7 +325,7 @@ edit_named_copy_invoker (GimpProcedure *procedure,
if (success) 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)); GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GError *my_error = NULL; GError *my_error = NULL;
...@@ -428,7 +428,7 @@ edit_named_paste_invoker (GimpProcedure *procedure, ...@@ -428,7 +428,7 @@ edit_named_paste_invoker (GimpProcedure *procedure,
GimpBuffer *buffer = gimp_pdb_get_buffer (gimp, buffer_name, error); GimpBuffer *buffer = gimp_pdb_get_buffer (gimp, buffer_name, error);
if (buffer && 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)) gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{ {
floating_sel = gimp_edit_paste (gimp_item_get_image (GIMP_ITEM (drawable)), floating_sel = gimp_edit_paste (gimp_item_get_image (GIMP_ITEM (drawable)),
...@@ -504,7 +504,7 @@ edit_clear_invoker (GimpProcedure *procedure, ...@@ -504,7 +504,7 @@ edit_clear_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error))
{ {
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
...@@ -536,7 +536,7 @@ edit_fill_invoker (GimpProcedure *procedure, ...@@ -536,7 +536,7 @@ edit_fill_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error))
{ {
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
...@@ -581,7 +581,7 @@ edit_bucket_fill_invoker (GimpProcedure *procedure, ...@@ -581,7 +581,7 @@ edit_bucket_fill_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error))
{ {
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
...@@ -638,7 +638,7 @@ edit_bucket_fill_full_invoker (GimpProcedure *procedure, ...@@ -638,7 +638,7 @@ edit_bucket_fill_full_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error))
{ {
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
...@@ -707,7 +707,7 @@ edit_blend_invoker (GimpProcedure *procedure, ...@@ -707,7 +707,7 @@ edit_blend_invoker (GimpProcedure *procedure,
if (success) 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)); gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error));
if (success && supersample) if (success && supersample)
...@@ -760,7 +760,7 @@ edit_stroke_invoker (GimpProcedure *procedure, ...@@ -760,7 +760,7 @@ edit_stroke_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error))
{ {
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
...@@ -801,9 +801,10 @@ edit_stroke_vectors_invoker (GimpProcedure *procedure, ...@@ -801,9 +801,10 @@ edit_stroke_vectors_invoker (GimpProcedure *procedure,
if (success) 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_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); GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE);
......
...@@ -152,7 +152,7 @@ floating_sel_attach_invoker (GimpProcedure *procedure, ...@@ -152,7 +152,7 @@ floating_sel_attach_invoker (GimpProcedure *procedure,
if (success) 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_not_group (GIMP_ITEM (drawable), error))
floating_sel_attach (layer, drawable); floating_sel_attach (layer, drawable);
else else
......
...@@ -304,10 +304,12 @@ gimp_pdb_get_paint_info (Gimp *gimp, ...@@ -304,10 +304,12 @@ gimp_pdb_get_paint_info (Gimp *gimp,
gboolean gboolean
gimp_pdb_item_is_attached (GimpItem *item, gimp_pdb_item_is_attached (GimpItem *item,
GimpImage *image,
gboolean writable, gboolean writable,
GError **error) GError **error)
{ {
g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE); 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); g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (! gimp_item_is_attached (item)) if (! gimp_item_is_attached (item))
...@@ -320,6 +322,16 @@ gimp_pdb_item_is_attached (GimpItem *item, ...@@ -320,6 +322,16 @@ gimp_pdb_item_is_attached (GimpItem *item,
return FALSE; 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));