[gimp] Don't modify locked items from PDB wrappers



commit 28061c23f1559c7c29e034a5043210b4011fd566
Author: Michael Natterer <mitch gimp org>
Date:   Thu Aug 20 20:47:01 2009 +0200

    Don't modify locked items from PDB wrappers
    
    * app/pdb/gimppdb-utils.[ch]: add "gboolean writable" parameter to
      gimp_pdb_item_is_attached() because this function is called on
      almost all items where a check for locked is needed.
    
    * tools/pdbgen/pdb/*.pdb: pass writable = TRUE in all checks for items
      that are modified. Add explicit calls to gimp_pdb_item_is_writable()
      in some rare cases.
    
    * app/pdb/*-cmds.c: regenerated.

 app/pdb/color-cmds.c                    |   32 +++++++++++++-------------
 app/pdb/drawable-cmds.c                 |   18 +++++++++------
 app/pdb/drawable-transform-cmds.c       |   32 +++++++++++++-------------
 app/pdb/edit-cmds.c                     |   28 ++++++++++++------------
 app/pdb/floating-sel-cmds.c             |    2 +-
 app/pdb/gimppdb-utils.c                 |    6 ++++-
 app/pdb/gimppdb-utils.h                 |    1 +
 app/pdb/image-cmds.c                    |    8 +++---
 app/pdb/layer-cmds.c                    |   20 +++++++++++------
 app/pdb/paint-tools-cmds.c              |   34 ++++++++++++++--------------
 app/pdb/paths-cmds.c                    |    3 +-
 app/pdb/selection-cmds.c                |    2 +-
 app/pdb/text-tool-cmds.c                |    4 +-
 app/pdb/transform-tools-cmds.c          |   12 +++++-----
 tools/pdbgen/pdb/color.pdb              |   32 +++++++++++++-------------
 tools/pdbgen/pdb/drawable.pdb           |   18 +++++++++------
 tools/pdbgen/pdb/drawable_transform.pdb |   12 +++++-----
 tools/pdbgen/pdb/edit.pdb               |   28 ++++++++++++------------
 tools/pdbgen/pdb/floating_sel.pdb       |    2 +-
 tools/pdbgen/pdb/image.pdb              |    8 +++---
 tools/pdbgen/pdb/layer.pdb              |   20 +++++++++++------
 tools/pdbgen/pdb/paint_tools.pdb        |   36 +++++++++++++++---------------
 tools/pdbgen/pdb/paths.pdb              |    3 +-
 tools/pdbgen/pdb/selection.pdb          |    2 +-
 tools/pdbgen/pdb/text_tool.pdb          |    4 +-
 tools/pdbgen/pdb/transform_tools.pdb    |   12 +++++-----
 26 files changed, 203 insertions(+), 176 deletions(-)
---
diff --git a/app/pdb/color-cmds.c b/app/pdb/color-cmds.c
index 70325e3..c0d79f5 100644
--- a/app/pdb/color-cmds.c
+++ b/app/pdb/color-cmds.c
@@ -66,7 +66,7 @@ brightness_contrast_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
           gimp_drawable_is_indexed (drawable))
         success = FALSE;
 
@@ -106,7 +106,7 @@ levels_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
           gimp_drawable_is_indexed (drawable) ||
           (! gimp_drawable_has_alpha (drawable) &&
            channel == GIMP_HISTOGRAM_ALPHA) ||
@@ -141,7 +141,7 @@ levels_auto_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
           gimp_drawable_is_indexed (drawable))
         success = FALSE;
 
@@ -168,7 +168,7 @@ levels_stretch_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
           gimp_drawable_is_indexed (drawable))
         success = FALSE;
 
@@ -197,7 +197,7 @@ posterize_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
           gimp_drawable_is_indexed (drawable))
         success = FALSE;
 
@@ -224,7 +224,7 @@ desaturate_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
           ! gimp_drawable_is_rgb (drawable))
         success = FALSE;
 
@@ -253,7 +253,7 @@ desaturate_full_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
           ! gimp_drawable_is_rgb (drawable))
         success = FALSE;
 
@@ -282,7 +282,7 @@ equalize_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
           gimp_drawable_is_indexed (drawable))
         success = FALSE;
 
@@ -309,7 +309,7 @@ invert_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
           gimp_drawable_is_indexed (drawable))
         success = FALSE;
 
@@ -342,7 +342,7 @@ curves_spline_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
           gimp_drawable_is_indexed (drawable) || (num_points & 1) ||
           (! gimp_drawable_has_alpha (drawable) &&
            channel == GIMP_HISTOGRAM_ALPHA) ||
@@ -380,7 +380,7 @@ curves_explicit_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
           gimp_drawable_is_indexed (drawable) || (num_bytes != 256) ||
           (! gimp_drawable_has_alpha (drawable) &&
            channel == GIMP_HISTOGRAM_ALPHA) ||
@@ -422,7 +422,7 @@ color_balance_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
           gimp_drawable_is_indexed (drawable))
         success = FALSE;
 
@@ -458,7 +458,7 @@ colorize_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
           ! gimp_drawable_is_rgb (drawable))
         success = FALSE;
 
@@ -499,7 +499,7 @@ histogram_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), FALSE, error) ||
           gimp_drawable_is_indexed (drawable) ||
           (! gimp_drawable_has_alpha (drawable) &&
            channel == GIMP_HISTOGRAM_ALPHA) ||
@@ -567,7 +567,7 @@ hue_saturation_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
           gimp_drawable_is_indexed (drawable))
         success = FALSE;
 
@@ -599,7 +599,7 @@ threshold_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
           gimp_drawable_is_indexed (drawable) ||
           (low_threshold > high_threshold))
         success = FALSE;
diff --git a/app/pdb/drawable-cmds.c b/app/pdb/drawable-cmds.c
index 92ae43b..fd362e1 100644
--- a/app/pdb/drawable-cmds.c
+++ b/app/pdb/drawable-cmds.c
@@ -798,7 +798,7 @@ drawable_mask_bounds_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), FALSE, error))
         non_empty = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
       else
         success = FALSE;
@@ -840,7 +840,7 @@ drawable_mask_intersect_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), FALSE, error))
         non_empty = gimp_drawable_mask_intersect (drawable,
                                                   &x, &y, &width, &height);
       else
@@ -879,7 +879,7 @@ drawable_merge_shadow_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           const gchar *undo_desc = _("Plug-In");
 
@@ -1036,7 +1036,8 @@ drawable_set_pixel_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (x_coord < gimp_item_get_width  (GIMP_ITEM (drawable)) &&
+      if (gimp_pdb_item_is_writable (GIMP_ITEM (drawable), error) &&
+          x_coord < gimp_item_get_width  (GIMP_ITEM (drawable)) &&
           y_coord < gimp_item_get_height (GIMP_ITEM (drawable)) &&
           num_channels == gimp_drawable_bytes (drawable))
         {
@@ -1082,7 +1083,10 @@ drawable_fill_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      gimp_drawable_fill_by_type (drawable, context, (GimpFillType) fill_type);
+      if (gimp_pdb_item_is_writable (GIMP_ITEM (drawable), error))
+        gimp_drawable_fill_by_type (drawable, context, (GimpFillType) fill_type);
+      else
+        success = FALSE;
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -1112,7 +1116,7 @@ drawable_offset_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         gimp_drawable_offset (drawable, context, wrap_around, fill_type,
                               offset_x, offset_y);
       else
@@ -1304,7 +1308,7 @@ drawable_foreground_extract_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), FALSE, error))
         gimp_drawable_foreground_extract (drawable, mode, mask, progress);
       else
         success = FALSE;
diff --git a/app/pdb/drawable-transform-cmds.c b/app/pdb/drawable-transform-cmds.c
index e22c49e..aeed03e 100644
--- a/app/pdb/drawable-transform-cmds.c
+++ b/app/pdb/drawable-transform-cmds.c
@@ -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), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), 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), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), 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), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), 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), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), 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), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), 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), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, 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), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), 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), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), 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), error) && x0 < x1 && y0 < y1);
+      success = (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), 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), error) && x0 < x1 && y0 < y1);
+      success = (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), 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), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), 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), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), 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), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), 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), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), 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), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), 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), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
 
       if (success &&
           gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
diff --git a/app/pdb/edit-cmds.c b/app/pdb/edit-cmds.c
index d2321d4..24fde84 100644
--- a/app/pdb/edit-cmds.c
+++ b/app/pdb/edit-cmds.c
@@ -63,7 +63,7 @@ edit_cut_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpImage *image    = gimp_item_get_image (GIMP_ITEM (drawable));
           GError    *my_error = NULL;
@@ -108,7 +108,7 @@ edit_copy_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), FALSE, error))
         {
           GimpImage *image    = gimp_item_get_image (GIMP_ITEM (drawable));
           GError    *my_error = NULL;
@@ -195,7 +195,7 @@ edit_paste_invoker (GimpProcedure      *procedure,
   if (success)
     {
       if (gimp->global_buffer &&
-          gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+          gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           floating_sel = gimp_edit_paste (gimp_item_get_image (GIMP_ITEM (drawable)),
                                           drawable, gimp->global_buffer,
@@ -269,7 +269,7 @@ edit_named_cut_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpImage *image    = gimp_item_get_image (GIMP_ITEM (drawable));
           GError    *my_error = NULL;
@@ -321,7 +321,7 @@ edit_named_copy_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), FALSE, error))
         {
           GimpImage *image    = gimp_item_get_image (GIMP_ITEM (drawable));
           GError    *my_error = NULL;
@@ -423,7 +423,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), error))
+      if (buffer && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           floating_sel = gimp_edit_paste (gimp_item_get_image (GIMP_ITEM (drawable)),
                                           drawable, buffer,
@@ -498,7 +498,7 @@ edit_clear_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
 
@@ -529,7 +529,7 @@ edit_fill_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
 
@@ -573,7 +573,7 @@ edit_bucket_fill_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
           gboolean   do_seed_fill;
@@ -629,7 +629,7 @@ edit_bucket_fill_full_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
           gboolean   do_seed_fill;
@@ -697,7 +697,7 @@ edit_blend_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
 
       if (success && supersample)
         {
@@ -749,7 +749,7 @@ edit_stroke_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpImage         *image   = gimp_item_get_image (GIMP_ITEM (drawable));
           GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE);
@@ -789,8 +789,8 @@ edit_stroke_vectors_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) &&
-          gimp_pdb_item_is_attached (GIMP_ITEM (vectors), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
+          gimp_pdb_item_is_attached (GIMP_ITEM (vectors), FALSE, error))
         {
           GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE);
 
diff --git a/app/pdb/floating-sel-cmds.c b/app/pdb/floating-sel-cmds.c
index 6c66130..3af6bfc 100644
--- a/app/pdb/floating-sel-cmds.c
+++ b/app/pdb/floating-sel-cmds.c
@@ -152,7 +152,7 @@ floating_sel_attach_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         floating_sel_attach (layer, drawable);
       else
         success = FALSE;
diff --git a/app/pdb/gimppdb-utils.c b/app/pdb/gimppdb-utils.c
index a5bfe89..7157b4a 100644
--- a/app/pdb/gimppdb-utils.c
+++ b/app/pdb/gimppdb-utils.c
@@ -304,6 +304,7 @@ gimp_pdb_get_paint_info (Gimp         *gimp,
 
 gboolean
 gimp_pdb_item_is_attached (GimpItem  *item,
+                           gboolean   writable,
                            GError   **error)
 {
   g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
@@ -319,6 +320,9 @@ gimp_pdb_item_is_attached (GimpItem  *item,
       return FALSE;
     }
 
+  if (writable)
+    return gimp_pdb_item_is_writable (item, error);
+
   return TRUE;
 }
 
@@ -389,7 +393,7 @@ gimp_pdb_layer_is_text_layer (GimpLayer  *layer,
       return FALSE;
     }
 
-  return gimp_pdb_item_is_attached (GIMP_ITEM (layer), error);
+  return gimp_pdb_item_is_attached (GIMP_ITEM (layer), FALSE, error);
 }
 
 static const gchar *
diff --git a/app/pdb/gimppdb-utils.h b/app/pdb/gimppdb-utils.h
index f7d401f..f9e9be5 100644
--- a/app/pdb/gimppdb-utils.h
+++ b/app/pdb/gimppdb-utils.h
@@ -49,6 +49,7 @@ GimpPaintInfo * gimp_pdb_get_paint_info         (Gimp               *gimp,
                                                  GError            **error);
 
 gboolean        gimp_pdb_item_is_attached       (GimpItem           *item,
+                                                 gboolean            writable,
                                                  GError            **error);
 gboolean        gimp_pdb_item_is_floating       (GimpItem           *item,
                                                  GimpImage          *dest_image,
diff --git a/app/pdb/image-cmds.c b/app/pdb/image-cmds.c
index c57b041..e0c123c 100644
--- a/app/pdb/image-cmds.c
+++ b/app/pdb/image-cmds.c
@@ -945,7 +945,7 @@ image_remove_layer_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), FALSE, error))
         gimp_image_remove_layer (image, layer, TRUE, NULL);
       else
         success = FALSE;
@@ -1137,7 +1137,7 @@ image_remove_channel_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (channel), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (channel), FALSE, error))
         gimp_image_remove_channel (image, channel, TRUE, NULL);
       else
         success = FALSE;
@@ -1281,7 +1281,7 @@ image_remove_vectors_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (vectors), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (vectors), FALSE, error))
         gimp_image_remove_vectors (image, vectors, TRUE, NULL);
       else
         success = FALSE;
@@ -1571,7 +1571,7 @@ image_remove_layer_mask_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), error) &&
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), mode == GIMP_MASK_APPLY, error) &&
           gimp_layer_get_mask (layer))
         gimp_layer_apply_mask (layer, mode, TRUE);
       else
diff --git a/app/pdb/layer-cmds.c b/app/pdb/layer-cmds.c
index ee9fd8a..717b765 100644
--- a/app/pdb/layer-cmds.c
+++ b/app/pdb/layer-cmds.c
@@ -232,7 +232,10 @@ layer_add_alpha_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      gimp_layer_add_alpha (layer);
+      if (gimp_pdb_item_is_writable (GIMP_ITEM (layer), error))
+        gimp_layer_add_alpha (layer);
+      else
+       success = FALSE;
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -254,7 +257,10 @@ layer_flatten_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      gimp_layer_flatten (layer, context);
+      if (gimp_pdb_item_is_writable (GIMP_ITEM (layer), error))
+        gimp_layer_flatten (layer, context);
+      else
+       success = FALSE;
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -282,7 +288,7 @@ layer_scale_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), TRUE, error))
         {
           if (progress)
             gimp_progress_start (progress, _("Scaling"), FALSE);
@@ -327,7 +333,7 @@ layer_scale_full_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), TRUE, error))
         {
           if (progress)
             gimp_progress_start (progress, _("Scaling"), FALSE);
@@ -372,7 +378,7 @@ layer_resize_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), TRUE, error))
         gimp_item_resize (GIMP_ITEM (layer), context,
                           new_width, new_height, offx, offy);
       else
@@ -398,7 +404,7 @@ layer_resize_to_image_size_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), TRUE, error))
         gimp_layer_resize_to_image (layer, context);
       else
         success = FALSE;
@@ -637,7 +643,7 @@ layer_remove_mask_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), error) &&
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), mode == GIMP_MASK_APPLY, error) &&
           gimp_layer_get_mask (layer))
         gimp_layer_apply_mask (layer, mode, TRUE);
       else
diff --git a/app/pdb/paint-tools-cmds.c b/app/pdb/paint-tools-cmds.c
index 0ccdc5b..62a0106 100644
--- a/app/pdb/paint-tools-cmds.c
+++ b/app/pdb/paint-tools-cmds.c
@@ -116,7 +116,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), error))
+      if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -158,7 +158,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), error))
+      if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -204,7 +204,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), error))
+      if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -249,7 +249,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), error))
+      if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -291,7 +291,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), error))
+      if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -334,7 +334,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), error))
+      if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -378,7 +378,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), error))
+      if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -422,7 +422,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), error))
+      if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -464,7 +464,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), error))
+      if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -507,7 +507,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), error))
+      if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -551,7 +551,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), error))
+      if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -592,7 +592,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), error))
+      if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -636,7 +636,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), error))
+      if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -682,7 +682,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), error))
+      if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -720,7 +720,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), error))
+      if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -760,7 +760,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), error))
+      if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -802,7 +802,7 @@ smudge_default_invoker (GimpProcedure      *procedure,
     {
       GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-smudge", error);
 
-      if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpPaintOptions *options = gimp_paint_options_new (info);
 
diff --git a/app/pdb/paths-cmds.c b/app/pdb/paths-cmds.c
index 758caa7..59dec96 100644
--- a/app/pdb/paths-cmds.c
+++ b/app/pdb/paths-cmds.c
@@ -330,7 +330,8 @@ path_stroke_current_invoker (GimpProcedure      *procedure,
       GimpVectors  *vectors  = gimp_image_get_active_vectors (image);
       GimpDrawable *drawable = gimp_image_get_active_drawable (image);
 
-      if (vectors && drawable)
+      if (vectors && drawable &&
+          gimp_pdb_item_is_writable (GIMP_ITEM (drawable), error))
         {
           GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE);
 
diff --git a/app/pdb/selection-cmds.c b/app/pdb/selection-cmds.c
index 897e086..a5f9111 100644
--- a/app/pdb/selection-cmds.c
+++ b/app/pdb/selection-cmds.c
@@ -190,7 +190,7 @@ selection_float_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         {
           GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
 
diff --git a/app/pdb/text-tool-cmds.c b/app/pdb/text-tool-cmds.c
index 2947f2c..485695e 100644
--- a/app/pdb/text-tool-cmds.c
+++ b/app/pdb/text-tool-cmds.c
@@ -72,7 +72,7 @@ text_fontname_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (drawable && ! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      if (drawable && ! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         success = FALSE;
 
       if (success)
@@ -194,7 +194,7 @@ text_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (drawable && ! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      if (drawable && ! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
         success = FALSE;
 
       if (success)
diff --git a/app/pdb/transform-tools-cmds.c b/app/pdb/transform-tools-cmds.c
index 21eb2ea..ee503b3 100644
--- a/app/pdb/transform-tools-cmds.c
+++ b/app/pdb/transform-tools-cmds.c
@@ -62,7 +62,7 @@ flip_invoker (GimpProcedure      *procedure,
     {
       gint x, y, width, height;
 
-      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
 
       if (success &&
           gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
@@ -117,7 +117,7 @@ perspective_invoker (GimpProcedure      *procedure,
     {
       gint x, y, width, height;
 
-      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
 
       if (success &&
           gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
@@ -187,7 +187,7 @@ rotate_invoker (GimpProcedure      *procedure,
     {
       gint x, y, width, height;
 
-      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
 
       if (success &&
           gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
@@ -262,7 +262,7 @@ scale_invoker (GimpProcedure      *procedure,
     {
       gint x, y, width, height;
 
-      success = (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) &&
+      success = (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
                  x0 < x1 && y0 < y1);
 
       if (success &&
@@ -334,7 +334,7 @@ shear_invoker (GimpProcedure      *procedure,
     {
       gint x, y, width, height;
 
-      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
 
       if (success &&
           gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
@@ -415,7 +415,7 @@ transform_2d_invoker (GimpProcedure      *procedure,
     {
       gint x, y, width, height;
 
-      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error);
+      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
 
       if (success &&
           gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
diff --git a/tools/pdbgen/pdb/color.pdb b/tools/pdbgen/pdb/color.pdb
index 79aee51..8f9a819 100644
--- a/tools/pdbgen/pdb/color.pdb
+++ b/tools/pdbgen/pdb/color.pdb
@@ -41,7 +41,7 @@ HELP
         headers => [ qw("core/gimpdrawable-brightness-contrast.h") ],
 	code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
       gimp_drawable_is_indexed (drawable))
     success = FALSE;
 
@@ -93,7 +93,7 @@ HELP
 	headers => [ qw("core/gimpdrawable-levels.h") ],
 	code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
       gimp_drawable_is_indexed (drawable) ||
       (! gimp_drawable_has_alpha (drawable) &&
        channel == GIMP_HISTOGRAM_ALPHA) ||
@@ -135,7 +135,7 @@ HELP
         headers => [ qw("core/gimpdrawable-levels.h") ],
         code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
       gimp_drawable_is_indexed (drawable))
     success = FALSE;
 
@@ -158,7 +158,7 @@ sub levels_auto {
         headers => [ qw("core/gimpdrawable-levels.h") ],
         code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
       gimp_drawable_is_indexed (drawable))
     success = FALSE;
 
@@ -191,7 +191,7 @@ HELP
         headers => [ qw("core/gimpdrawable-posterize.h") ],
 	code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
       gimp_drawable_is_indexed (drawable))
     success = FALSE;
 
@@ -221,7 +221,7 @@ HELP
 	headers => [ qw("core/gimpdrawable-desaturate.h") ],
 	code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
       ! gimp_drawable_is_rgb (drawable))
     success = FALSE;
 
@@ -258,7 +258,7 @@ HELP
 	headers => [ qw("core/gimpdrawable-desaturate.h") ],
 	code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
       ! gimp_drawable_is_rgb (drawable))
     success = FALSE;
 
@@ -295,7 +295,7 @@ HELP
 	headers => [ qw("core/gimpdrawable-equalize.h") ],
 	code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
       gimp_drawable_is_indexed (drawable))
     success = FALSE;
 
@@ -326,7 +326,7 @@ HELP
 	headers => [ qw("core/gimpdrawable-invert.h") ],
 	code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
       gimp_drawable_is_indexed (drawable))
     success = FALSE;
 
@@ -368,7 +368,7 @@ HELP
 	headers => [ qw("core/gimpdrawable-curves.h") ],
 	code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
       gimp_drawable_is_indexed (drawable) || (num_points & 1) ||
       (! gimp_drawable_has_alpha (drawable) &&
        channel == GIMP_HISTOGRAM_ALPHA) ||
@@ -414,7 +414,7 @@ HELP
 	headers => [ qw("core/gimpdrawable-curves.h") ],
 	code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
       gimp_drawable_is_indexed (drawable) || (num_bytes != 256) ||
       (! gimp_drawable_has_alpha (drawable) &&
        channel == GIMP_HISTOGRAM_ALPHA) ||
@@ -465,7 +465,7 @@ HELP
 	headers => [ qw("core/gimpdrawable-color-balance.h") ],
 	code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
       gimp_drawable_is_indexed (drawable))
     success = FALSE;
 
@@ -505,7 +505,7 @@ HELP
 	headers => [ qw("core/gimpdrawable-colorize.h") ],
 	code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
       ! gimp_drawable_is_rgb (drawable))
     success = FALSE;
 
@@ -569,7 +569,7 @@ HELP
                         "core/gimpdrawable-histogram.h") ],
 	code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), FALSE, error) ||
       gimp_drawable_is_indexed (drawable) ||
       (! gimp_drawable_has_alpha (drawable) &&
        channel == GIMP_HISTOGRAM_ALPHA) ||
@@ -632,7 +632,7 @@ HELP
 	headers => [ qw("core/gimpdrawable-hue-saturation.h") ],
 	code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
       gimp_drawable_is_indexed (drawable))
     success = FALSE;
 
@@ -669,7 +669,7 @@ HELP
 	headers => [ qw("core/gimpdrawable-threshold.h") ],
 	code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) ||
+  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) ||
       gimp_drawable_is_indexed (drawable) ||
       (low_threshold > high_threshold))
     success = FALSE;
diff --git a/tools/pdbgen/pdb/drawable.pdb b/tools/pdbgen/pdb/drawable.pdb
index a2fe516..02afe9a 100644
--- a/tools/pdbgen/pdb/drawable.pdb
+++ b/tools/pdbgen/pdb/drawable.pdb
@@ -71,7 +71,7 @@ HELP
                         "plug-in/gimppluginmanager.h") ],
 	code    => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       const gchar *undo_desc = _("Plug-In");
 
@@ -148,7 +148,10 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  gimp_drawable_fill_by_type (drawable, context, (GimpFillType) fill_type);
+  if (gimp_pdb_item_is_writable (GIMP_ITEM (drawable), error))
+    gimp_drawable_fill_by_type (drawable, context, (GimpFillType) fill_type);
+  else
+    success = FALSE;
 }
 CODE
     );
@@ -231,7 +234,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), FALSE, error))
     non_empty = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
   else
     success = FALSE;
@@ -278,7 +281,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), FALSE, error))
     non_empty = gimp_drawable_mask_intersect (drawable,
                                               &x, &y, &width, &height);
   else
@@ -1009,7 +1012,8 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  if (x_coord < gimp_item_get_width  (GIMP_ITEM (drawable)) &&
+  if (gimp_pdb_item_is_writable (GIMP_ITEM (drawable), error) &&
+      x_coord < gimp_item_get_width  (GIMP_ITEM (drawable)) &&
       y_coord < gimp_item_get_height (GIMP_ITEM (drawable)) &&
       num_channels == gimp_drawable_bytes (drawable))
     {
@@ -1253,7 +1257,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     gimp_drawable_offset (drawable, context, wrap_around, fill_type,
                           offset_x, offset_y);
   else
@@ -1321,7 +1325,7 @@ HELP
 	headers => [ qw("core/gimpdrawable-foreground-extract.h") ],
         code    => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), FALSE, error))
     gimp_drawable_foreground_extract (drawable, mode, mask, progress);
   else
     success = FALSE;
diff --git a/tools/pdbgen/pdb/drawable_transform.pdb b/tools/pdbgen/pdb/drawable_transform.pdb
index e9fba35..bbd75ff 100644
--- a/tools/pdbgen/pdb/drawable_transform.pdb
+++ b/tools/pdbgen/pdb/drawable_transform.pdb
@@ -24,10 +24,10 @@
 
 sub transform_invoke {
     my ($progress_text, $assemble_matrix, $check) = @_;
-    my $success_check = 'gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error);';
+    my $success_check = 'gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);';
 
     if ($check) {
-        $success_check = "(gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) && " . $check . ");";
+        $success_check = "(gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) && " . $check . ");";
     }
 
     %invoke = (
@@ -70,10 +70,10 @@ CODE
 
 sub transform_default_invoke {
     my ($progress_text, $assemble_matrix, $check) = @_;
-    my $success_check = 'gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error);';
+    my $success_check = 'gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);';
 
     if ($check) {
-        $success_check = "(gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) && " . $check . ");";
+        $success_check = "(gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) && " . $check . ");";
     }
 
     %invoke = (
@@ -165,7 +165,7 @@ HELP
 {
   gint x, y, width, height;
 
-  success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error);
+  success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
 
   if (success &&
       gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
@@ -462,7 +462,7 @@ HELP
 {
   gint x, y, width, height;
 
-  success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error);
+  success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
 
   if (success &&
       gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
diff --git a/tools/pdbgen/pdb/edit.pdb b/tools/pdbgen/pdb/edit.pdb
index 4c80c47..13a9e22 100644
--- a/tools/pdbgen/pdb/edit.pdb
+++ b/tools/pdbgen/pdb/edit.pdb
@@ -46,7 +46,7 @@ HELP
     %invoke = (
 	code => <<CODE
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpImage *image    = gimp_item_get_image (GIMP_ITEM (drawable));
       GError    *my_error = NULL;
@@ -98,7 +98,7 @@ HELP
     %invoke = (
 	code => <<CODE
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), FALSE, error))
     {
       GimpImage *image    = gimp_item_get_image (GIMP_ITEM (drawable));
       GError    *my_error = NULL;
@@ -200,7 +200,7 @@ HELP
 	code => <<CODE
 {
   if (gimp->global_buffer &&
-      gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+      gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       floating_sel = gimp_edit_paste (gimp_item_get_image (GIMP_ITEM (drawable)),
                                       drawable, gimp->global_buffer,
@@ -277,7 +277,7 @@ HELP
     %invoke = (
 	code => <<CODE
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpImage *image    = gimp_item_get_image (GIMP_ITEM (drawable));
       GError    *my_error = NULL;
@@ -330,7 +330,7 @@ HELP
     %invoke = (
 	code => <<CODE
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), FALSE, error))
     {
       GimpImage *image    = gimp_item_get_image (GIMP_ITEM (drawable));
       GError    *my_error = NULL;
@@ -435,7 +435,7 @@ HELP
 {
   GimpBuffer *buffer = gimp_pdb_get_buffer (gimp, buffer_name, error);
 
-  if (buffer && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (buffer && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       floating_sel = gimp_edit_paste (gimp_item_get_image (GIMP_ITEM (drawable)),
                                       drawable, buffer,
@@ -510,7 +510,7 @@ HELP
     %invoke = (
 	code => <<CODE
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
 
@@ -550,7 +550,7 @@ HELP
     %invoke = (
 	code => <<CODE
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
 
@@ -618,7 +618,7 @@ HELP
 	                 "core/gimpchannel.h") ],
 	code => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
       gboolean   do_seed_fill;
@@ -702,7 +702,7 @@ HELP
 	                 "core/gimpchannel.h") ],
 	code => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
       gboolean   do_seed_fill;
@@ -779,7 +779,7 @@ HELP
         headers => [ qw("core/gimpdrawable-blend.h") ],
 	code => <<'CODE'
 {
-  success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error);
+  success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
 
   if (success && supersample)
     {
@@ -835,7 +835,7 @@ HELP
 	headers => [ qw("core/gimpstrokeoptions.h") ],
 	code => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpImage         *image   = gimp_item_get_image (GIMP_ITEM (drawable));
       GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE);
@@ -878,8 +878,8 @@ HELP
 	headers => [ qw("core/gimpstrokeoptions.h") ],
 	code => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) &&
-      gimp_pdb_item_is_attached (GIMP_ITEM (vectors), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
+      gimp_pdb_item_is_attached (GIMP_ITEM (vectors), FALSE, error))
     {
       GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE);
 
diff --git a/tools/pdbgen/pdb/floating_sel.pdb b/tools/pdbgen/pdb/floating_sel.pdb
index 3980b1a..ae0a8be 100644
--- a/tools/pdbgen/pdb/floating_sel.pdb
+++ b/tools/pdbgen/pdb/floating_sel.pdb
@@ -150,7 +150,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     floating_sel_attach (layer, drawable);
   else
     success = FALSE;
diff --git a/tools/pdbgen/pdb/image.pdb b/tools/pdbgen/pdb/image.pdb
index 7bdc071..8585db2 100644
--- a/tools/pdbgen/pdb/image.pdb
+++ b/tools/pdbgen/pdb/image.pdb
@@ -1047,7 +1047,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), FALSE, error))
     gimp_image_remove_layer (image, layer, TRUE, NULL);
   else
     success = FALSE;
@@ -1095,7 +1095,7 @@ sub image_remove_layer_mask {
     %invoke = (
 	code => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), error) &&
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), mode == GIMP_MASK_APPLY, error) &&
       gimp_layer_get_mask (layer))
     gimp_layer_apply_mask (layer, mode, TRUE);
   else
@@ -1253,7 +1253,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (channel), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (channel), FALSE, error))
     gimp_image_remove_channel (image, channel, TRUE, NULL);
   else
     success = FALSE;
@@ -1318,7 +1318,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (vectors), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (vectors), FALSE, error))
     gimp_image_remove_vectors (image, vectors, TRUE, NULL);
   else
     success = FALSE;
diff --git a/tools/pdbgen/pdb/layer.pdb b/tools/pdbgen/pdb/layer.pdb
index 1d50462..5c898ef 100644
--- a/tools/pdbgen/pdb/layer.pdb
+++ b/tools/pdbgen/pdb/layer.pdb
@@ -306,7 +306,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), error) &&
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), mode == GIMP_MASK_APPLY, error) &&
       gimp_layer_get_mask (layer))
     gimp_layer_apply_mask (layer, mode, TRUE);
   else
@@ -343,7 +343,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), TRUE, error))
     {
       if (progress)
         gimp_progress_start (progress, _("Scaling"), FALSE);
@@ -394,7 +394,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), TRUE, error))
     {
       if (progress)
         gimp_progress_start (progress, _("Scaling"), FALSE);
@@ -445,7 +445,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), TRUE, error))
     gimp_item_resize (GIMP_ITEM (layer), context,
                       new_width, new_height, offx, offy);
   else
@@ -473,7 +473,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), TRUE, error))
     gimp_layer_resize_to_image (layer, context);
   else
     success = FALSE;
@@ -546,7 +546,10 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  gimp_layer_add_alpha (layer);
+  if (gimp_pdb_item_is_writable (GIMP_ITEM (layer), error))
+    gimp_layer_add_alpha (layer);
+  else
+   success = FALSE;
 }
 CODE
     );
@@ -574,7 +577,10 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  gimp_layer_flatten (layer, context);
+  if (gimp_pdb_item_is_writable (GIMP_ITEM (layer), error))
+    gimp_layer_flatten (layer, context);
+  else
+   success = FALSE;
 }
 CODE
     );
diff --git a/tools/pdbgen/pdb/paint_tools.pdb b/tools/pdbgen/pdb/paint_tools.pdb
index 311315f..b8ea5c3 100644
--- a/tools/pdbgen/pdb/paint_tools.pdb
+++ b/tools/pdbgen/pdb/paint_tools.pdb
@@ -54,7 +54,7 @@ HELP
 {
   GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-airbrush", error);
 
-  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -99,7 +99,7 @@ HELP
 {
   GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-airbrush", error);
 
-  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -155,7 +155,7 @@ HELP
 {
   GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-clone", error);
 
-  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -204,7 +204,7 @@ HELP
 {
   GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-clone", error);
 
-  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -245,7 +245,7 @@ HELP
 {
   GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-convolve", error);
 
-  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -288,7 +288,7 @@ HELP
 {
   GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-convolve", error);
 
-  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -332,7 +332,7 @@ HELP
 {
   GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-eraser", error);
 
-  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -376,7 +376,7 @@ HELP
 {
   GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-eraser", error);
 
-  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -425,7 +425,7 @@ HELP
 {
   GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-eraser", error);
 
-  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -479,7 +479,7 @@ HELP
 {
   GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-heal", error);
 
-  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -524,7 +524,7 @@ HELP
 {
   GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-heal", error);
 
-  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -576,7 +576,7 @@ HELP
 {
   GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-paintbrush", error);
 
-  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -633,7 +633,7 @@ HELP
 {
   GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-paintbrush", error);
 
-  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -673,7 +673,7 @@ HELP
 {
   GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-pencil", error);
 
-  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -712,7 +712,7 @@ HELP
 {
   GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-smudge", error);
 
-  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -757,7 +757,7 @@ HELP
 {
   GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-smudge", error);
 
-  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -801,7 +801,7 @@ HELP
 {
   GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-dodge-burn", error);
 
-  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpPaintOptions *options = gimp_paint_options_new (info);
 
@@ -848,7 +848,7 @@ HELP
 {
   GimpPaintInfo *info = gimp_pdb_get_paint_info (gimp, "gimp-dodge-burn", error);
 
-  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (info && gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpPaintOptions *options = gimp_paint_options_new (info);
 
diff --git a/tools/pdbgen/pdb/paths.pdb b/tools/pdbgen/pdb/paths.pdb
index abe5d76..d6dc9d7 100644
--- a/tools/pdbgen/pdb/paths.pdb
+++ b/tools/pdbgen/pdb/paths.pdb
@@ -265,7 +265,8 @@ sub path_stroke_current {
   GimpVectors  *vectors  = gimp_image_get_active_vectors (image);
   GimpDrawable *drawable = gimp_image_get_active_drawable (image);
 
-  if (vectors && drawable)
+  if (vectors && drawable &&
+      gimp_pdb_item_is_writable (GIMP_ITEM (drawable), error))
     {
       GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE);
 
diff --git a/tools/pdbgen/pdb/selection.pdb b/tools/pdbgen/pdb/selection.pdb
index 0fad77b..b166f3b 100644
--- a/tools/pdbgen/pdb/selection.pdb
+++ b/tools/pdbgen/pdb/selection.pdb
@@ -183,7 +183,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     {
       GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
 
diff --git a/tools/pdbgen/pdb/text_tool.pdb b/tools/pdbgen/pdb/text_tool.pdb
index 47d2c9e..0f6472c 100644
--- a/tools/pdbgen/pdb/text_tool.pdb
+++ b/tools/pdbgen/pdb/text_tool.pdb
@@ -72,7 +72,7 @@ HELP
     %invoke = (
         code => <<'CODE'
 {
-  if (drawable && ! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (drawable && ! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     success = FALSE;
 
   if (success)
@@ -192,7 +192,7 @@ sub text {
     %invoke = (
         code => <<'CODE'
 {
-  if (drawable && ! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error))
+  if (drawable && ! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error))
     success = FALSE;
 
   if (success)
diff --git a/tools/pdbgen/pdb/transform_tools.pdb b/tools/pdbgen/pdb/transform_tools.pdb
index 6c1f24d..12d32ee 100644
--- a/tools/pdbgen/pdb/transform_tools.pdb
+++ b/tools/pdbgen/pdb/transform_tools.pdb
@@ -37,7 +37,7 @@ sub flip {
 {
   gint x, y, width, height;
 
-  success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error);
+  success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
 
   if (success &&
       gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
@@ -94,7 +94,7 @@ sub perspective {
 {
   gint x, y, width, height;
 
-  success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error);
+  success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
 
   if (success &&
       gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
@@ -158,7 +158,7 @@ sub rotate {
 {
   gint x, y, width, height;
 
-  success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error);
+  success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
 
   if (success &&
       gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
@@ -231,7 +231,7 @@ sub scale {
 {
   gint x, y, width, height;
 
-  success = (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) &&
+  success = (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error) &&
              x0 < x1 && y0 < y1);
 
   if (success &&
@@ -298,7 +298,7 @@ sub shear {
 {
   gint x, y, width, height;
 
-  success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error);
+  success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
 
   if (success &&
       gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
@@ -373,7 +373,7 @@ sub transform_2d {
 {
   gint x, y, width, height;
 
-  success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error);
+  success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), TRUE, error);
 
   if (success &&
       gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]