[gimp/wip/Jehan/classy-GIMP: 34/50] libgimp: GimpItem now also belong to libgimp.



commit 08849a584c4c7a3288b028f3f03e98ffb44e5bb6
Author: Jehan <jehan girinstud io>
Date:   Thu Aug 15 12:12:25 2019 +0200

    libgimp: GimpItem now also belong to libgimp.

 libgimp/gimpaspectpreview.c        |   1 -
 libgimp/gimpchannel.c              |  10 +---
 libgimp/gimpchannel_pdb.c          |  12 ++--
 libgimp/gimpdrawable.c             | 115 +++++++------------------------------
 libgimp/gimpdrawablepreview.c      |   1 -
 libgimp/gimpedit_pdb.c             |   8 +--
 libgimp/gimpexport.c               |  42 +++++---------
 libgimp/gimpfileops_pdb.c          |   4 +-
 libgimp/gimpimage.c                |  45 +++++----------
 libgimp/gimpimage_pdb.c            |  68 +++++++++++-----------
 libgimp/gimpimagemetadata.c        |   1 -
 libgimp/gimpitem.c                 |  74 +++++++++++++++++-------
 libgimp/gimpitem.h                 |   2 +-
 libgimp/gimpitem_pdb.c             |   4 +-
 libgimp/gimpitemcombobox.c         |   8 +--
 libgimp/gimpitemtransform_pdb.c    |  40 ++++++-------
 libgimp/gimplayer.c                |  61 ++++++++------------
 libgimp/gimplayer_pdb.c            |  32 +++++------
 libgimp/gimpprocedure.c            |   6 +-
 libgimp/gimpselection.c            |  13 ++---
 libgimp/gimpselection_pdb.c        |   8 +--
 libgimp/gimptextlayer_pdb.c        |   4 +-
 libgimp/gimptexttool_pdb.c         |   4 +-
 libgimp/gimpvectors_pdb.c          |  12 ++--
 libgimp/gimpzoompreview.c          |   1 -
 pdb/pdb.pl                         |  28 ++++-----
 plug-ins/common/blinds.c           |   8 +--
 plug-ins/common/checkerboard.c     |   8 +--
 plug-ins/common/contrast-retinex.c |   9 +--
 plug-ins/common/despeckle.c        |   8 +--
 plug-ins/common/destripe.c         |   9 +--
 plug-ins/common/grid.c             |   4 +-
 plug-ins/common/jigsaw.c           |   4 +-
 plug-ins/common/nl-filter.c        |   8 +--
 plug-ins/common/sparkle.c          |   9 +--
 35 files changed, 270 insertions(+), 401 deletions(-)
---
diff --git a/libgimp/gimpaspectpreview.c b/libgimp/gimpaspectpreview.c
index f334b7246d..8b8e4de0e1 100644
--- a/libgimp/gimpaspectpreview.c
+++ b/libgimp/gimpaspectpreview.c
@@ -327,7 +327,6 @@ gimp_aspect_preview_draw_buffer (GimpPreview  *preview,
                                               &w, &h, &bpp);
       sel = gimp_drawable_get_thumbnail_data (GIMP_DRAWABLE (selection),
                                               &w, &h, &bpp);
-      g_object_unref (selection);
 
       gimp_preview_area_mask (GIMP_PREVIEW_AREA (area),
                               0, 0, width, height,
diff --git a/libgimp/gimpchannel.c b/libgimp/gimpchannel.c
index f68a66bc3a..561f22eb4c 100644
--- a/libgimp/gimpchannel.c
+++ b/libgimp/gimpchannel.c
@@ -60,7 +60,8 @@ gimp_channel_init (GimpChannel *channel)
  * set with explicit procedure calls. The channel's contents are
  * undefined initially.
  *
- * Returns: The newly created channel.
+ * Returns: (transfer none): The newly created channel.
+ *          The object belongs to libgimp and you should not free it.
  */
 GimpChannel *
 gimp_channel_new (GimpImage     *image,
@@ -112,14 +113,9 @@ gimp_channel_new_deprecated (gint32         image_id,
                              const GimpRGB *color)
 {
   GimpChannel *channel;
-  gint32       channel_id;
 
   channel = gimp_channel_new (gimp_image_get_by_id (image_id),
                               name, width, height,
                               opacity, color);
-  channel_id = gimp_item_get_id (GIMP_ITEM (channel));
-
-  g_object_unref (channel);
-
-  return channel_id;
+  return gimp_item_get_id (GIMP_ITEM (channel));
 }
diff --git a/libgimp/gimpchannel_pdb.c b/libgimp/gimpchannel_pdb.c
index 9a9ef83146..e39734cd62 100644
--- a/libgimp/gimpchannel_pdb.c
+++ b/libgimp/gimpchannel_pdb.c
@@ -53,7 +53,7 @@
  * explicit procedure calls.
  * The channel's contents are undefined initially.
  *
- * Returns: (transfer full): The newly created channel.
+ * Returns: (transfer none): The newly created channel.
  **/
 GimpChannel *
 _gimp_channel_new (GimpImage     *image,
@@ -87,7 +87,7 @@ _gimp_channel_new (GimpImage     *image,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    channel = GIMP_CHANNEL (gimp_item_new_by_id (gimp_value_get_channel_id (gimp_value_array_index 
(return_vals, 1))));
+    channel = GIMP_CHANNEL (gimp_item_get_by_id (gimp_value_get_channel_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -108,7 +108,7 @@ _gimp_channel_new (GimpImage     *image,
  * Other attributes, such as channel visibility, should be set with
  * explicit procedure calls.
  *
- * Returns: (transfer full): The newly created channel.
+ * Returns: (transfer none): The newly created channel.
  *
  * Since: 2.4
  **/
@@ -138,7 +138,7 @@ gimp_channel_new_from_component (GimpImage       *image,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    channel = GIMP_CHANNEL (gimp_item_new_by_id (gimp_value_get_channel_id (gimp_value_array_index 
(return_vals, 1))));
+    channel = GIMP_CHANNEL (gimp_item_get_by_id (gimp_value_get_channel_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -206,7 +206,7 @@ _gimp_channel_new_from_component (gint32           image_ID,
  * The new channel still needs to be added to the image, as this is not
  * automatic. Add the new channel with gimp_image_insert_channel().
  *
- * Returns: (transfer full): The newly copied channel.
+ * Returns: (transfer none): The newly copied channel.
  **/
 GimpChannel *
 gimp_channel_copy (GimpChannel *channel)
@@ -230,7 +230,7 @@ gimp_channel_copy (GimpChannel *channel)
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    channel_copy = GIMP_CHANNEL (gimp_item_new_by_id (gimp_value_get_channel_id (gimp_value_array_index 
(return_vals, 1))));
+    channel_copy = GIMP_CHANNEL (gimp_item_get_by_id (gimp_value_get_channel_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
diff --git a/libgimp/gimpdrawable.c b/libgimp/gimpdrawable.c
index bdf0c8c006..8c797e4f01 100644
--- a/libgimp/gimpdrawable.c
+++ b/libgimp/gimpdrawable.c
@@ -369,7 +369,10 @@ gimp_drawable_get_thumbnail_format (GimpDrawable *drawable)
   gchar      *format_str = _gimp_drawable_get_thumbnail_format (drawable);
 
   if (format_str)
-    format = babl_format (format_str);
+    {
+      format = babl_format (format_str);
+      g_free (format_str);
+    }
 
   return format;
 }
@@ -388,7 +391,8 @@ gimp_drawable_get_thumbnail_format (GimpDrawable *drawable)
  * Retrieves thumbnail data for the drawable identified by @drawable_ID.
  * The thumbnail will be not larger than the requested size.
  *
- * Returns: (transfer full):
+ * Returns: (transfer full) (nullable): thumbnail data or %NULL if
+ *          @drawable_ID is invalid.
  **/
 guchar *
 gimp_drawable_get_thumbnail_data_deprecated (gint32  drawable_ID,
@@ -396,17 +400,8 @@ gimp_drawable_get_thumbnail_data_deprecated (gint32  drawable_ID,
                                              gint   *height,
                                              gint   *bpp)
 {
-  GimpDrawable *drawable;
-  guchar       *data = NULL;
-
-  drawable = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_ID));
-
-  g_return_val_if_fail (drawable, NULL);
-
-  data = gimp_drawable_get_thumbnail_data (drawable, width, height, bpp);
-  g_object_unref (drawable);
-
-  return data;
+  return gimp_drawable_get_thumbnail_data (GIMP_DRAWABLE (gimp_item_get_by_id (drawable_ID)),
+                                           width, height, bpp);
 }
 
 /**
@@ -420,7 +415,8 @@ gimp_drawable_get_thumbnail_data_deprecated (gint32  drawable_ID,
  * @drawable_ID. The thumbnail will be not larger than the requested
  * size.
  *
- * Returns: (transfer full): a new #GdkPixbuf
+ * Returns: (transfer full) (nullable): a new #GdkPixbuf or %NULL if
+ *          @drawable_ID is invalid.
  *
  * Since: 2.2
  **/
@@ -430,17 +426,8 @@ gimp_drawable_get_thumbnail_deprecated (gint32                  drawable_ID,
                                         gint                    height,
                                         GimpPixbufTransparency  alpha)
 {
-  GimpDrawable *drawable;
-  GdkPixbuf    *thumbnail = NULL;
-
-  drawable = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_ID));
-
-  g_return_val_if_fail (drawable, NULL);
-
-  thumbnail = gimp_drawable_get_thumbnail (drawable, width, height, alpha);
-  g_object_unref (drawable);
-
-  return thumbnail;
+  return gimp_drawable_get_thumbnail (GIMP_DRAWABLE (gimp_item_get_by_id (drawable_ID)),
+                                      width, height, alpha);
 }
 
 guchar *
@@ -453,19 +440,10 @@ gimp_drawable_get_sub_thumbnail_data_deprecated (gint32  drawable_ID,
                                                  gint   *dest_height,
                                                  gint   *bpp)
 {
-  GimpDrawable *drawable;
-  guchar       *data = NULL;
-
-  drawable = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_ID));
-
-  g_return_val_if_fail (drawable, NULL);
-
-  data = gimp_drawable_get_sub_thumbnail_data (drawable, src_x, src_y,
+  return gimp_drawable_get_sub_thumbnail_data (GIMP_DRAWABLE (gimp_item_get_by_id (drawable_ID)),
+                                               src_x, src_y,
                                                src_width, src_height,
                                                dest_width, dest_height, bpp);
-  g_object_unref (drawable);
-
-  return data;
 }
 
 /**
@@ -497,19 +475,10 @@ gimp_drawable_get_sub_thumbnail_deprecated (gint32                  drawable_ID,
                                             gint                    dest_height,
                                             GimpPixbufTransparency  alpha)
 {
-  GimpDrawable *drawable;
-  GdkPixbuf    *thumbnail = NULL;
-
-  drawable = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_ID));
-
-  g_return_val_if_fail (drawable, NULL);
-
-  thumbnail = gimp_drawable_get_sub_thumbnail (drawable, src_x, src_y,
-                                               src_width, src_height,
-                                               dest_width, dest_height, alpha);
-  g_object_unref (drawable);
-
-  return thumbnail;
+  return gimp_drawable_get_sub_thumbnail (GIMP_DRAWABLE (gimp_item_get_by_id (drawable_ID)),
+                                          src_x, src_y,
+                                          src_width, src_height,
+                                          dest_width, dest_height, alpha);
 }
 
 /**
@@ -530,17 +499,7 @@ gimp_drawable_get_sub_thumbnail_deprecated (gint32                  drawable_ID,
 GeglBuffer *
 gimp_drawable_get_buffer_deprecated (gint32 drawable_ID)
 {
-  GimpDrawable *drawable;
-  GeglBuffer   *buffer = NULL;
-
-  drawable = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_ID));
-
-  g_return_val_if_fail (drawable, NULL);
-
-  buffer = gimp_drawable_get_buffer (drawable);
-  g_object_unref (drawable);
-
-  return buffer;
+  return gimp_drawable_get_buffer (GIMP_DRAWABLE (gimp_item_get_by_id (drawable_ID)));
 }
 
 /**
@@ -561,17 +520,7 @@ gimp_drawable_get_buffer_deprecated (gint32 drawable_ID)
 GeglBuffer *
 gimp_drawable_get_shadow_buffer_deprecated (gint32 drawable_ID)
 {
-  GimpDrawable *drawable;
-  GeglBuffer   *buffer = NULL;
-
-  drawable = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_ID));
-
-  g_return_val_if_fail (drawable, NULL);
-
-  buffer = gimp_drawable_get_shadow_buffer (drawable);
-  g_object_unref (drawable);
-
-  return buffer;
+  return gimp_drawable_get_shadow_buffer (GIMP_DRAWABLE (gimp_item_get_by_id (drawable_ID)));
 }
 
 /**
@@ -587,17 +536,7 @@ gimp_drawable_get_shadow_buffer_deprecated (gint32 drawable_ID)
 const Babl *
 gimp_drawable_get_format_deprecated (gint32 drawable_ID)
 {
-  GimpDrawable *drawable;
-  const Babl   *format = NULL;
-
-  drawable = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_ID));
-
-  g_return_val_if_fail (drawable, NULL);
-
-  format = gimp_drawable_get_format (drawable);
-  g_object_unref (drawable);
-
-  return format;
+  return gimp_drawable_get_format (GIMP_DRAWABLE (gimp_item_get_by_id (drawable_ID)));
 }
 /**
  * gimp_drawable_get_thumbnail_format_deprecated: (skip)
@@ -612,15 +551,5 @@ gimp_drawable_get_format_deprecated (gint32 drawable_ID)
 const Babl *
 gimp_drawable_get_thumbnail_format_deprecated (gint32 drawable_ID)
 {
-  GimpDrawable *drawable;
-  const Babl   *format = NULL;
-
-  drawable = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_ID));
-
-  g_return_val_if_fail (drawable, NULL);
-
-  format = gimp_drawable_get_thumbnail_format (drawable);
-  g_object_unref (drawable);
-
-  return format;
+  return gimp_drawable_get_thumbnail_format (GIMP_DRAWABLE (gimp_item_get_by_id (drawable_ID)));
 }
diff --git a/libgimp/gimpdrawablepreview.c b/libgimp/gimpdrawablepreview.c
index efced0f072..bb03e751cd 100644
--- a/libgimp/gimpdrawablepreview.c
+++ b/libgimp/gimpdrawablepreview.c
@@ -474,7 +474,6 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview,
                                                       draw_width, draw_height,
                                                       &s_w, &s_h,
                                                       &s_bpp);
-          g_object_unref (selection);
 
           switch (d_bpp)
             {
diff --git a/libgimp/gimpedit_pdb.c b/libgimp/gimpedit_pdb.c
index 61a280dd03..a6600ed675 100644
--- a/libgimp/gimpedit_pdb.c
+++ b/libgimp/gimpedit_pdb.c
@@ -333,7 +333,7 @@ _gimp_edit_copy_visible (gint32 image_ID)
  * specified drawable, and a subsequent call to floating_sel_attach is
  * not needed.
  *
- * Returns: (transfer full): The new floating selection.
+ * Returns: (transfer none): The new floating selection.
  **/
 GimpLayer *
 gimp_edit_paste (GimpDrawable *drawable,
@@ -359,7 +359,7 @@ gimp_edit_paste (GimpDrawable *drawable,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    floating_sel = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index 
(return_vals, 1))));
+    floating_sel = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -808,7 +808,7 @@ _gimp_edit_named_copy_visible (gint32       image_ID,
  * This procedure works like gimp_edit_paste() but pastes a named
  * buffer instead of the global buffer.
  *
- * Returns: (transfer full): The new floating selection.
+ * Returns: (transfer none): The new floating selection.
  *
  * Since: 2.4
  **/
@@ -838,7 +838,7 @@ gimp_edit_named_paste (GimpDrawable *drawable,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    floating_sel = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index 
(return_vals, 1))));
+    floating_sel = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
diff --git a/libgimp/gimpexport.c b/libgimp/gimpexport.c
index 82737a3e27..462e65d749 100644
--- a/libgimp/gimpexport.c
+++ b/libgimp/gimpexport.c
@@ -101,8 +101,6 @@ export_merge (GimpImage     *image,
       gimp_selection_none (image);
       gimp_drawable_edit_clear (GIMP_DRAWABLE (transp));
       nvisible++;
-
-      g_object_unref (transp);
     }
 
   if (nvisible > 1)
@@ -121,7 +119,7 @@ export_merge (GimpImage     *image,
           return;  /* shouldn't happen */
         }
 
-      g_list_free_full (layers, g_object_unref);
+      g_list_free (layers);
       layers = gimp_image_get_layers (image);
 
       /*  make sure that the merged drawable matches the image size  */
@@ -144,7 +142,7 @@ export_merge (GimpImage     *image,
       if (gimp_item_get_id (iter->data) != gimp_item_get_id (GIMP_ITEM (*drawable)))
         gimp_image_remove_layer (image, iter->data);
     }
-  g_list_free_full (layers, g_object_unref);
+  g_list_free (layers);
 }
 
 static void
@@ -174,7 +172,7 @@ export_remove_alpha (GimpImage     *image,
         gimp_layer_flatten (iter->data);
     }
 
-  g_list_free_full (layers, g_object_unref);
+  g_list_free (layers);
 }
 
 static void
@@ -193,11 +191,9 @@ export_apply_masks (GimpImage     *image,
       mask = gimp_layer_get_mask (iter->data);
       if (mask)
         gimp_layer_remove_mask (iter->data, GIMP_MASK_APPLY);
-
-      g_clear_object (&mask);
     }
 
-  g_list_free_full (layers, g_object_unref);
+  g_list_free (layers);
 }
 
 static void
@@ -232,7 +228,7 @@ export_convert_indexed (GimpImage     *image,
                                 GIMP_CONVERT_DITHER_NONE,
                                 GIMP_CONVERT_PALETTE_GENERATE,
                                 256, FALSE, FALSE, "");
-  g_list_free_full (layers, g_object_unref);
+  g_list_free (layers);
 }
 
 static void
@@ -261,7 +257,7 @@ export_add_alpha (GimpImage     *image,
       if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (iter->data)))
         gimp_layer_add_alpha (GIMP_LAYER (iter->data));
     }
-  g_list_free_full (layers, g_object_unref);
+  g_list_free (layers);
 }
 
 static void
@@ -839,14 +835,8 @@ gimp_export_image (GimpImage             **image,
     {
       for (iter = layers; iter; iter = iter->next)
         {
-          GimpLayer     *layer = GIMP_LAYER (iter->data);
-          GimpLayerMask *mask;
-
-          mask = gimp_layer_get_mask (layer);
-          if (mask)
+          if (gimp_layer_get_mask (iter->data))
             has_layer_masks = TRUE;
-
-          g_clear_object (&mask);
         }
     }
 
@@ -924,7 +914,7 @@ gimp_export_image (GimpImage             **image,
             }
         }
 
-      g_list_free_full (children, g_object_unref);
+      g_list_free (children);
 
       /* check layer masks */
       if (has_layer_masks &&
@@ -932,7 +922,7 @@ gimp_export_image (GimpImage             **image,
         actions = g_slist_prepend (actions, &export_action_apply_masks);
     }
 
-  g_list_free_full (layers, g_object_unref);
+  g_list_free (layers);
 
   /* check the image type */
   type = gimp_image_base_type (*image);
@@ -1148,22 +1138,16 @@ gimp_export_image_deprecated (gint32                 *image_ID,
 {
   GimpImage        *image;
   GimpDrawable     *drawable;
-  GimpDrawable     *new_drawable;
   GimpExportReturn  retval;
 
-  image        = gimp_image_get_by_id (*image_ID);
-  drawable     = GIMP_DRAWABLE (gimp_item_new_by_id (*drawable_ID));
-  new_drawable = drawable;
+  image    = gimp_image_get_by_id (*image_ID);
+  drawable = GIMP_DRAWABLE (gimp_item_get_by_id (*drawable_ID));
 
-  retval = gimp_export_image (&image, &new_drawable,
+  retval = gimp_export_image (&image, &drawable,
                               format_name, capabilities);
 
   *image_ID    = gimp_image_get_id (image);
-  *drawable_ID = gimp_item_get_id (GIMP_ITEM (new_drawable));
-  if (retval == GIMP_EXPORT_EXPORT)
-    g_object_unref (new_drawable);
-
-  g_object_unref (drawable);
+  *drawable_ID = gimp_item_get_id (GIMP_ITEM (drawable));
 
   return retval;
 }
diff --git a/libgimp/gimpfileops_pdb.c b/libgimp/gimpfileops_pdb.c
index 589a16f36b..f47e08c943 100644
--- a/libgimp/gimpfileops_pdb.c
+++ b/libgimp/gimpfileops_pdb.c
@@ -149,7 +149,7 @@ _gimp_file_load (GimpRunMode  run_mode,
  * needs to be added to the existing image with
  * gimp_image_insert_layer().
  *
- * Returns: (transfer full): The layer created when loading the image file.
+ * Returns: (transfer none): The layer created when loading the image file.
  *
  * Since: 2.4
  **/
@@ -179,7 +179,7 @@ gimp_file_load_layer (GimpRunMode  run_mode,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    layer = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
+    layer = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
 
   gimp_value_array_unref (return_vals);
 
diff --git a/libgimp/gimpimage.c b/libgimp/gimpimage.c
index 52abdb858a..b3cc11686a 100644
--- a/libgimp/gimpimage.c
+++ b/libgimp/gimpimage.c
@@ -220,10 +220,10 @@ gimp_image_list (void)
  * This procedure returns the list of layers contained in the specified
  * image. The order of layers is from topmost to bottommost.
  *
- * Returns: (element-type GimpImage) (transfer full):
+ * Returns: (element-type GimpImage) (transfer container):
  *          The list of layers contained in the image.
- *          The returned value must be freed with:
- *          g_list_free_full(list, g_object_unref);
+ *          The returned value must be freed with g_list_free(). Layer
+ *          elements belong to libgimp and must not be freed.
  *
  * Since: 3.0
  **/
@@ -237,13 +237,8 @@ gimp_image_get_layers (GimpImage *image)
 
   ids = _gimp_image_get_layers (image, &num_layers);
   for (i = 0; i < num_layers; i++)
-    {
-      GimpLayer *layer;
-
-      layer = GIMP_LAYER (gimp_item_new_by_id (ids[i]));
-
-      layers = g_list_prepend (layers, layer);
-    }
+    layers = g_list_prepend (layers,
+                             GIMP_LAYER (gimp_item_get_by_id (ids[i])));
   layers = g_list_reverse (layers);
   g_free (ids);
 
@@ -262,10 +257,10 @@ gimp_image_get_layers (GimpImage *image)
  * \"channels\" are custom channels and do not include the image's
  * color components.
  *
- * Returns: (element-type GimpChannel) (transfer full):
+ * Returns: (element-type GimpChannel) (transfer container):
  *          The list of channels contained in the image.
- *          The returned value must be freed with:
- *          g_list_free_full(list, g_object_unref);
+ *          The returned value must be freed with g_list_free(). Channel
+ *          elements belong to libgimp and must not be freed.
  *
  * Since: 3.0
  **/
@@ -279,13 +274,8 @@ gimp_image_get_channels (GimpImage *image)
 
   ids = _gimp_image_get_channels (image, &num_channels);
   for (i = 0; i < num_channels; i++)
-    {
-      GimpChannel *channel;
-
-      channel = GIMP_CHANNEL (gimp_item_new_by_id (ids[i]));
-
-      channels = g_list_prepend (channels, channel);
-    }
+    channels = g_list_prepend (channels,
+                               GIMP_CHANNEL (gimp_item_get_by_id (ids[i])));
   channels = g_list_reverse (channels);
   g_free (ids);
 
@@ -301,10 +291,10 @@ gimp_image_get_channels (GimpImage *image)
  * This procedure returns the list of vectors contained in the
  * specified image.
  *
- * Returns: (element-type GimpVectors) (transfer full):
+ * Returns: (element-type GimpVectors) (transfer container):
  *          The list of vectors contained in the image.
- *          The returned value must be freed with:
- *          g_list_free_full(list, g_object_unref);
+ *          The returned value must be freed with g_list_free(). Vectors
+ *          elements belong to libgimp and must not be freed.
  *
  * Since: 3.0
  **/
@@ -318,13 +308,8 @@ gimp_image_get_vectors (GimpImage *image)
 
   ids = _gimp_image_get_vectors (image, &num_vectors);
   for (i = 0; i < num_vectors; i++)
-    {
-      GimpVectors *path;
-
-      path = GIMP_VECTORS (gimp_item_new_by_id (ids[i]));
-
-      vectors = g_list_prepend (vectors, path);
-    }
+    vectors = g_list_prepend (vectors,
+                              GIMP_VECTORS (gimp_item_get_by_id (ids[i])));
   vectors = g_list_reverse (vectors);
   g_free (ids);
 
diff --git a/libgimp/gimpimage_pdb.c b/libgimp/gimpimage_pdb.c
index ed2091b8d0..175f1c4ed8 100644
--- a/libgimp/gimpimage_pdb.c
+++ b/libgimp/gimpimage_pdb.c
@@ -1115,7 +1115,7 @@ _gimp_image_get_vectors (GimpImage *image,
  * layer mask and the layer mask is in edit mode, then the layer mask
  * is the active drawable.
  *
- * Returns: (transfer full): The active drawable.
+ * Returns: (transfer none): The active drawable.
  **/
 GimpDrawable *
 gimp_image_get_active_drawable (GimpImage *image)
@@ -1139,7 +1139,7 @@ gimp_image_get_active_drawable (GimpImage *image)
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    drawable = GIMP_DRAWABLE (gimp_item_new_by_id (gimp_value_get_drawable_id (gimp_value_array_index 
(return_vals, 1))));
+    drawable = GIMP_DRAWABLE (gimp_item_get_by_id (gimp_value_get_drawable_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -1281,7 +1281,7 @@ _gimp_image_unset_active_channel (gint32 image_ID)
  * This procedure returns the image's floating selection, if it exists.
  * If it doesn't exist, -1 is returned as the layer ID.
  *
- * Returns: (transfer full): The image's floating selection.
+ * Returns: (transfer none): The image's floating selection.
  **/
 GimpLayer *
 gimp_image_get_floating_sel (GimpImage *image)
@@ -1305,7 +1305,7 @@ gimp_image_get_floating_sel (GimpImage *image)
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    floating_sel = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index 
(return_vals, 1))));
+    floating_sel = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -1362,7 +1362,7 @@ _gimp_image_get_floating_sel (gint32 image_ID)
  * is attached to, if it exists. If it doesn't exist, -1 is returned as
  * the drawable ID.
  *
- * Returns: (transfer full):
+ * Returns: (transfer none):
  *          The drawable the floating selection is attached to.
  **/
 GimpDrawable *
@@ -1387,7 +1387,7 @@ gimp_image_floating_sel_attached_to (GimpImage *image)
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    drawable = GIMP_DRAWABLE (gimp_item_new_by_id (gimp_value_get_drawable_id (gimp_value_array_index 
(return_vals, 1))));
+    drawable = GIMP_DRAWABLE (gimp_item_get_by_id (gimp_value_get_drawable_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -1591,7 +1591,7 @@ _gimp_image_pick_color (gint32    image_ID,
  * at the specified coordinates. This procedure will return -1 if no
  * layer is found.
  *
- * Returns: (transfer full): The layer found at the specified coordinates.
+ * Returns: (transfer none): The layer found at the specified coordinates.
  **/
 GimpLayer *
 gimp_image_pick_correlate_layer (GimpImage *image,
@@ -1619,7 +1619,7 @@ gimp_image_pick_correlate_layer (GimpImage *image,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    layer = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
+    layer = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -3360,7 +3360,7 @@ _gimp_image_reorder_item (gint32 image_ID,
  * merging with the CLIP_TO_IMAGE merge type. Non-visible layers are
  * discarded, and the resulting image is stripped of its alpha channel.
  *
- * Returns: (transfer full): The resulting layer.
+ * Returns: (transfer none): The resulting layer.
  **/
 GimpLayer *
 gimp_image_flatten (GimpImage *image)
@@ -3384,7 +3384,7 @@ gimp_image_flatten (GimpImage *image)
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    layer = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
+    layer = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -3447,7 +3447,7 @@ _gimp_image_flatten (gint32 image_ID)
  * extents of the image. A merge type of CLIP_TO_BOTTOM_LAYER clips the
  * final layer to the size of the bottommost layer.
  *
- * Returns: (transfer full): The resulting layer.
+ * Returns: (transfer none): The resulting layer.
  **/
 GimpLayer *
 gimp_image_merge_visible_layers (GimpImage     *image,
@@ -3473,7 +3473,7 @@ gimp_image_merge_visible_layers (GimpImage     *image,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    layer = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
+    layer = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -3543,7 +3543,7 @@ _gimp_image_merge_visible_layers (gint32        image_ID,
  * CLIP_TO_BOTTOM_LAYER clips the final layer to the size of the
  * bottommost layer.
  *
- * Returns: (transfer full): The resulting layer.
+ * Returns: (transfer none): The resulting layer.
  **/
 GimpLayer *
 gimp_image_merge_down (GimpImage     *image,
@@ -3571,7 +3571,7 @@ gimp_image_merge_down (GimpImage     *image,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    layer = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
+    layer = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -4063,7 +4063,7 @@ _gimp_image_thumbnail (GimpImage  *image,
  * If a channel is currently active, then no layer will be. If a layer
  * mask is active, then this will return the associated layer.
  *
- * Returns: (transfer full): The active layer.
+ * Returns: (transfer none): The active layer.
  **/
 GimpLayer *
 gimp_image_get_active_layer (GimpImage *image)
@@ -4087,7 +4087,7 @@ gimp_image_get_active_layer (GimpImage *image)
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    active_layer = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index 
(return_vals, 1))));
+    active_layer = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -4232,7 +4232,7 @@ _gimp_image_set_active_layer (gint32 image_ID,
  * If there is an active channel, this will return the channel ID,
  * otherwise, -1.
  *
- * Returns: (transfer full): The active channel.
+ * Returns: (transfer none): The active channel.
  **/
 GimpChannel *
 gimp_image_get_active_channel (GimpImage *image)
@@ -4256,7 +4256,7 @@ gimp_image_get_active_channel (GimpImage *image)
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    active_channel = GIMP_CHANNEL (gimp_item_new_by_id (gimp_value_get_channel_id (gimp_value_array_index 
(return_vals, 1))));
+    active_channel = GIMP_CHANNEL (gimp_item_get_by_id (gimp_value_get_channel_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -4399,7 +4399,7 @@ _gimp_image_set_active_channel (gint32 image_ID,
  *
  * If there is an active path, its ID will be returned, otherwise, -1.
  *
- * Returns: (transfer full): The active vectors.
+ * Returns: (transfer none): The active vectors.
  **/
 GimpVectors *
 gimp_image_get_active_vectors (GimpImage *image)
@@ -4423,7 +4423,7 @@ gimp_image_get_active_vectors (GimpImage *image)
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    active_vectors = GIMP_VECTORS (gimp_item_new_by_id (gimp_value_get_vectors_id (gimp_value_array_index 
(return_vals, 1))));
+    active_vectors = GIMP_VECTORS (gimp_item_get_by_id (gimp_value_get_vectors_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -4560,7 +4560,7 @@ _gimp_image_set_active_vectors (gint32 image_ID,
  * This will always return a valid ID for a selection -- which is
  * represented as a channel internally.
  *
- * Returns: (transfer full): The selection channel.
+ * Returns: (transfer none): The selection channel.
  **/
 GimpSelection *
 gimp_image_get_selection (GimpImage *image)
@@ -4584,7 +4584,7 @@ gimp_image_get_selection (GimpImage *image)
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    selection = GIMP_SELECTION (gimp_item_new_by_id (gimp_value_get_selection_id (gimp_value_array_index 
(return_vals, 1))));
+    selection = GIMP_SELECTION (gimp_item_get_by_id (gimp_value_get_selection_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -6191,7 +6191,7 @@ _gimp_image_set_tattoo_state (gint32 image_ID,
  * This procedure returns the layer with the given tattoo in the
  * specified image.
  *
- * Returns: (transfer full): The layer with the specified tattoo.
+ * Returns: (transfer none): The layer with the specified tattoo.
  **/
 GimpLayer *
 gimp_image_get_layer_by_tattoo (GimpImage *image,
@@ -6217,7 +6217,7 @@ gimp_image_get_layer_by_tattoo (GimpImage *image,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    layer = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
+    layer = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -6277,7 +6277,7 @@ _gimp_image_get_layer_by_tattoo (gint32 image_ID,
  * This procedure returns the channel with the given tattoo in the
  * specified image.
  *
- * Returns: (transfer full): The channel with the specified tattoo.
+ * Returns: (transfer none): The channel with the specified tattoo.
  **/
 GimpChannel *
 gimp_image_get_channel_by_tattoo (GimpImage *image,
@@ -6303,7 +6303,7 @@ gimp_image_get_channel_by_tattoo (GimpImage *image,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    channel = GIMP_CHANNEL (gimp_item_new_by_id (gimp_value_get_channel_id (gimp_value_array_index 
(return_vals, 1))));
+    channel = GIMP_CHANNEL (gimp_item_get_by_id (gimp_value_get_channel_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -6363,7 +6363,7 @@ _gimp_image_get_channel_by_tattoo (gint32 image_ID,
  * This procedure returns the vectors with the given tattoo in the
  * specified image.
  *
- * Returns: (transfer full): The vectors with the specified tattoo.
+ * Returns: (transfer none): The vectors with the specified tattoo.
  *
  * Since: 2.6
  **/
@@ -6391,7 +6391,7 @@ gimp_image_get_vectors_by_tattoo (GimpImage *image,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    vectors = GIMP_VECTORS (gimp_item_new_by_id (gimp_value_get_vectors_id (gimp_value_array_index 
(return_vals, 1))));
+    vectors = GIMP_VECTORS (gimp_item_get_by_id (gimp_value_get_vectors_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -6453,7 +6453,7 @@ _gimp_image_get_vectors_by_tattoo (gint32 image_ID,
  * This procedure returns the layer with the given name in the
  * specified image.
  *
- * Returns: (transfer full): The layer with the specified name.
+ * Returns: (transfer none): The layer with the specified name.
  *
  * Since: 2.8
  **/
@@ -6481,7 +6481,7 @@ gimp_image_get_layer_by_name (GimpImage   *image,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    layer = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
+    layer = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -6543,7 +6543,7 @@ _gimp_image_get_layer_by_name (gint32       image_ID,
  * This procedure returns the channel with the given name in the
  * specified image.
  *
- * Returns: (transfer full): The channel with the specified name.
+ * Returns: (transfer none): The channel with the specified name.
  *
  * Since: 2.8
  **/
@@ -6571,7 +6571,7 @@ gimp_image_get_channel_by_name (GimpImage   *image,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    channel = GIMP_CHANNEL (gimp_item_new_by_id (gimp_value_get_channel_id (gimp_value_array_index 
(return_vals, 1))));
+    channel = GIMP_CHANNEL (gimp_item_get_by_id (gimp_value_get_channel_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -6633,7 +6633,7 @@ _gimp_image_get_channel_by_name (gint32       image_ID,
  * This procedure returns the vectors with the given name in the
  * specified image.
  *
- * Returns: (transfer full): The vectors with the specified name.
+ * Returns: (transfer none): The vectors with the specified name.
  *
  * Since: 2.8
  **/
@@ -6661,7 +6661,7 @@ gimp_image_get_vectors_by_name (GimpImage   *image,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    vectors = GIMP_VECTORS (gimp_item_new_by_id (gimp_value_get_vectors_id (gimp_value_array_index 
(return_vals, 1))));
+    vectors = GIMP_VECTORS (gimp_item_get_by_id (gimp_value_get_vectors_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
diff --git a/libgimp/gimpimagemetadata.c b/libgimp/gimpimagemetadata.c
index 3b66339565..edceb2a52c 100644
--- a/libgimp/gimpimagemetadata.c
+++ b/libgimp/gimpimagemetadata.c
@@ -717,7 +717,6 @@ gimp_image_metadata_load_thumbnail (GFile   *file,
       g_object_unref (pixbuf);
 
       gimp_image_insert_layer (image, layer, NULL, 0);
-      g_object_unref (layer);
 
       gimp_image_metadata_rotate (image,
                                   gexiv2_metadata_get_orientation (GEXIV2_METADATA (metadata)));
diff --git a/libgimp/gimpitem.c b/libgimp/gimpitem.c
index 87856d8c7a..0785bc80f4 100644
--- a/libgimp/gimpitem.c
+++ b/libgimp/gimpitem.c
@@ -37,6 +37,9 @@ struct _GimpItemPrivate
   gint id;
 };
 
+static GHashTable *gimp_items = NULL;
+
+
 static void       gimp_item_set_property  (GObject      *object,
                                             guint         property_id,
                                             const GValue *value,
@@ -136,29 +139,66 @@ gimp_item_get_id (GimpItem *item)
 }
 
 /**
- * gimp_item_new_by_id:
+ * gimp_item_get_by_id:
  * @item_id: The item id.
  *
  * Creates a #GimpItem representing @item_id. Since #GimpItem is an
  * abstract class, the object real type will actually be the proper
  * subclass.
  *
- * Returns: (nullable) (transfer full): a #GimpItem for @item_id or
+ * Returns: (nullable) (transfer none): a #GimpItem for @item_id or
  *          %NULL if @item_id does not represent a valid item.
+ *          The object belongs to libgimp and you should not free it.
  *
  * Since: 3.0
  **/
 GimpItem *
-gimp_item_new_by_id (gint32 item_id)
+gimp_item_get_by_id (gint32 item_id)
 {
   GimpItem *item = NULL;
 
-  if (_gimp_item_is_valid (item_id))
+  if (G_UNLIKELY (! gimp_items))
+    gimp_items = g_hash_table_new_full (g_direct_hash,
+                                        g_direct_equal,
+                                        NULL,
+                                        (GDestroyNotify) g_object_unref);
+
+  if (! _gimp_item_is_valid (item_id))
+    {
+      g_hash_table_remove (gimp_items, GINT_TO_POINTER (item_id));
+    }
+  else
     {
-      if (_gimp_item_is_layer (item_id))
-        item = g_object_new (GIMP_TYPE_LAYER,
-                             "id", item_id,
-                             NULL);
+      item = g_hash_table_lookup (gimp_items,
+                                  GINT_TO_POINTER (item_id));
+
+      if (! item)
+        {
+          if (_gimp_item_is_layer (item_id))
+            item = g_object_new (GIMP_TYPE_LAYER,
+                                 "id", item_id,
+                                 NULL);
+          else if (_gimp_item_is_layer_mask (item_id))
+            item = g_object_new (GIMP_TYPE_LAYER_MASK,
+                                 "id", item_id,
+                                 NULL);
+          else if (_gimp_item_is_selection (item_id))
+            item = g_object_new (GIMP_TYPE_SELECTION,
+                                 "id", item_id,
+                                 NULL);
+          else if (_gimp_item_is_channel (item_id))
+            item = g_object_new (GIMP_TYPE_CHANNEL,
+                                 "id", item_id,
+                                 NULL);
+          else if (_gimp_item_is_vectors (item_id))
+            item = g_object_new (GIMP_TYPE_VECTORS,
+                                 "id", item_id,
+                                 NULL);
+          if (item)
+            g_hash_table_insert (gimp_items,
+                                 GINT_TO_POINTER (item_id),
+                                 item);
+        }
     }
 
   return item;
@@ -173,10 +213,10 @@ gimp_item_new_by_id (gint32 item_id)
  * This procedure returns the list of items which are children of the
  * specified item. The order is topmost to bottommost.
  *
- * Returns: (element-type GimpItem) (transfer full):
+ * Returns: (element-type GimpItem) (transfer container):
  *          The item's list of children.
- *          The returned value must be freed with:
- *          g_list_free_full(list, g_object_unref);
+ *          The returned value must be freed with g_list_free(). Item
+ *          elements belong to libgimp and must not be freed.
  *
  * Since: 3.0
  **/
@@ -191,7 +231,7 @@ gimp_item_get_children (GimpItem *item)
   ids = _gimp_item_get_children (item, &num_items);
 
   for (i = 0; i < num_items; i++)
-    children = g_list_prepend (children, gimp_item_new_by_id (ids[i]));
+    children = g_list_prepend (children, gimp_item_get_by_id (ids[i]));
 
   children = g_list_reverse (children);
   g_free (ids);
@@ -219,12 +259,6 @@ gint *
 gimp_item_get_children_deprecated (gint32    item_id,
                                    gint     *num_children)
 {
-  GimpItem *item;
-  gint     *children;
-
-  item     = gimp_item_new_by_id (item_id);
-  children = _gimp_item_get_children (item, num_children);
-  g_object_unref (item);
-
-  return children;
+  return _gimp_item_get_children (gimp_item_get_by_id (item_id),
+                                  num_children);
 }
diff --git a/libgimp/gimpitem.h b/libgimp/gimpitem.h
index a8085e31d6..0013e3e6eb 100644
--- a/libgimp/gimpitem.h
+++ b/libgimp/gimpitem.h
@@ -67,7 +67,7 @@ struct _GimpItemClass
 GType         gimp_item_get_type     (void) G_GNUC_CONST;
 
 gint32        gimp_item_get_id       (GimpItem    *item);
-GimpItem    * gimp_item_new_by_id    (gint32       item_id);
+GimpItem    * gimp_item_get_by_id    (gint32       item_id);
 
 #ifndef GIMP_DEPRECATED_REPLACE_NEW_API
 
diff --git a/libgimp/gimpitem_pdb.c b/libgimp/gimpitem_pdb.c
index 4cca121b79..eb0a886f44 100644
--- a/libgimp/gimpitem_pdb.c
+++ b/libgimp/gimpitem_pdb.c
@@ -954,7 +954,7 @@ _gimp_item_is_group (gint32 item_ID)
  *
  * This procedure returns the item's parent item, if any.
  *
- * Returns: (transfer full): The item's parent item.
+ * Returns: (transfer none): The item's parent item.
  *
  * Since: 2.8
  **/
@@ -980,7 +980,7 @@ gimp_item_get_parent (GimpItem *item)
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    parent = gimp_item_new_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
+    parent = gimp_item_get_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
 
   gimp_value_array_unref (return_vals);
 
diff --git a/libgimp/gimpitemcombobox.c b/libgimp/gimpitemcombobox.c
index 5ccaa80a0a..87e9d3016f 100644
--- a/libgimp/gimpitemcombobox.c
+++ b/libgimp/gimpitemcombobox.c
@@ -406,7 +406,7 @@ gimp_item_combo_box_populate (GimpIntComboBox *combo_box)
           items = gimp_image_get_layers (image);
           gimp_item_combo_box_model_add (combo_box, GTK_LIST_STORE (model),
                                          image, items, 0);
-          g_list_free_full (items, g_object_unref);
+          g_list_free (items);
         }
 
       if (GIMP_IS_DRAWABLE_COMBO_BOX (combo_box) ||
@@ -415,7 +415,7 @@ gimp_item_combo_box_populate (GimpIntComboBox *combo_box)
           items = gimp_image_get_channels (image);
           gimp_item_combo_box_model_add (combo_box, GTK_LIST_STORE (model),
                                          image, items, 0);
-          g_list_free_full (items, g_object_unref);
+          g_list_free (items);
         }
 
       if (GIMP_IS_VECTORS_COMBO_BOX (combo_box))
@@ -423,7 +423,7 @@ gimp_item_combo_box_populate (GimpIntComboBox *combo_box)
           items = gimp_image_get_vectors (image);
           gimp_item_combo_box_model_add (combo_box, GTK_LIST_STORE (model),
                                          image, items, 0);
-          g_list_free_full (items, g_object_unref);
+          g_list_free (items);
         }
     }
 
@@ -507,7 +507,7 @@ gimp_item_combo_box_model_add (GimpIntComboBox *combo_box,
           gimp_item_combo_box_model_add (combo_box, store,
                                          image, children,
                                          tree_level + 1);
-          g_list_free_full (children, g_object_unref);
+          g_list_free (children);
         }
     }
 
diff --git a/libgimp/gimpitemtransform_pdb.c b/libgimp/gimpitemtransform_pdb.c
index 285308b345..0e02214502 100644
--- a/libgimp/gimpitemtransform_pdb.c
+++ b/libgimp/gimpitemtransform_pdb.c
@@ -52,7 +52,7 @@
  * linked flag set to TRUE will also be translated by the specified
  * offsets.
  *
- * Returns: (transfer full): The translated item.
+ * Returns: (transfer none): The translated item.
  *
  * Since: 2.10
  **/
@@ -82,7 +82,7 @@ gimp_item_transform_translate (GimpItem *item,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    ret_item = gimp_item_new_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
+    ret_item = gimp_item_get_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
 
   gimp_value_array_unref (return_vals);
 
@@ -173,7 +173,7 @@ _gimp_item_transform_translate (gint32  item_ID,
  * This procedure is affected by the following context setters:
  * gimp_context_set_transform_resize().
  *
- * Returns: (transfer full): The flipped item.
+ * Returns: (transfer none): The flipped item.
  *
  * Since: 2.2
  **/
@@ -205,7 +205,7 @@ gimp_item_transform_flip_simple (GimpItem            *item,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    ret_item = gimp_item_new_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
+    ret_item = gimp_item_get_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
 
   gimp_value_array_unref (return_vals);
 
@@ -310,7 +310,7 @@ _gimp_item_transform_flip_simple (gint32              item_ID,
  * gimp_context_set_transform_direction(),
  * gimp_context_set_transform_resize().
  *
- * Returns: (transfer full): The flipped item.
+ * Returns: (transfer none): The flipped item.
  *
  * Since: 2.8
  **/
@@ -344,7 +344,7 @@ gimp_item_transform_flip (GimpItem *item,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    ret_item = gimp_item_new_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
+    ret_item = gimp_item_get_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
 
   gimp_value_array_unref (return_vals);
 
@@ -465,7 +465,7 @@ _gimp_item_transform_flip (gint32  item_ID,
  * gimp_context_set_transform_direction(),
  * gimp_context_set_transform_resize().
  *
- * Returns: (transfer full): The transformed item.
+ * Returns: (transfer none): The transformed item.
  *
  * Since: 2.8
  **/
@@ -507,7 +507,7 @@ gimp_item_transform_perspective (GimpItem *item,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    ret_item = gimp_item_new_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
+    ret_item = gimp_item_get_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
 
   gimp_value_array_unref (return_vals);
 
@@ -639,7 +639,7 @@ _gimp_item_transform_perspective (gint32  item_ID,
  * This procedure is affected by the following context setters:
  * gimp_context_set_transform_resize().
  *
- * Returns: (transfer full): The rotated item.
+ * Returns: (transfer none): The rotated item.
  *
  * Since: 2.8
  **/
@@ -673,7 +673,7 @@ gimp_item_transform_rotate_simple (GimpItem         *item,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    ret_item = gimp_item_new_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
+    ret_item = gimp_item_get_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
 
   gimp_value_array_unref (return_vals);
 
@@ -789,7 +789,7 @@ _gimp_item_transform_rotate_simple (gint32           item_ID,
  * gimp_context_set_transform_direction(),
  * gimp_context_set_transform_resize().
  *
- * Returns: (transfer full): The rotated item.
+ * Returns: (transfer none): The rotated item.
  *
  * Since: 2.8
  **/
@@ -823,7 +823,7 @@ gimp_item_transform_rotate (GimpItem *item,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    ret_item = gimp_item_new_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
+    ret_item = gimp_item_get_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
 
   gimp_value_array_unref (return_vals);
 
@@ -938,7 +938,7 @@ _gimp_item_transform_rotate (gint32   item_ID,
  * gimp_context_set_transform_direction(),
  * gimp_context_set_transform_resize().
  *
- * Returns: (transfer full): The scaled item.
+ * Returns: (transfer none): The scaled item.
  *
  * Since: 2.8
  **/
@@ -972,7 +972,7 @@ gimp_item_transform_scale (GimpItem *item,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    ret_item = gimp_item_new_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
+    ret_item = gimp_item_get_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
 
   gimp_value_array_unref (return_vals);
 
@@ -1084,7 +1084,7 @@ _gimp_item_transform_scale (gint32  item_ID,
  * gimp_context_set_transform_direction(),
  * gimp_context_set_transform_resize().
  *
- * Returns: (transfer full): The sheared item.
+ * Returns: (transfer none): The sheared item.
  *
  * Since: 2.8
  **/
@@ -1114,7 +1114,7 @@ gimp_item_transform_shear (GimpItem            *item,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    ret_item = gimp_item_new_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
+    ret_item = gimp_item_get_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
 
   gimp_value_array_unref (return_vals);
 
@@ -1228,7 +1228,7 @@ _gimp_item_transform_shear (gint32              item_ID,
  * gimp_context_set_transform_direction(),
  * gimp_context_set_transform_resize().
  *
- * Returns: (transfer full): The transformed item.
+ * Returns: (transfer none): The transformed item.
  *
  * Since: 2.8
  **/
@@ -1268,7 +1268,7 @@ gimp_item_transform_2d (GimpItem *item,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    ret_item = gimp_item_new_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
+    ret_item = gimp_item_get_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
 
   gimp_value_array_unref (return_vals);
 
@@ -1398,7 +1398,7 @@ _gimp_item_transform_2d (gint32  item_ID,
  * gimp_context_set_transform_direction(),
  * gimp_context_set_transform_resize().
  *
- * Returns: (transfer full): The transformed item.
+ * Returns: (transfer none): The transformed item.
  *
  * Since: 2.8
  **/
@@ -1442,7 +1442,7 @@ gimp_item_transform_matrix (GimpItem *item,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    ret_item = gimp_item_new_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
+    ret_item = gimp_item_get_by_id (gimp_value_get_item_id (gimp_value_array_index (return_vals, 1)));
 
   gimp_value_array_unref (return_vals);
 
diff --git a/libgimp/gimplayer.c b/libgimp/gimplayer.c
index 7f31d111da..ae59b9a0e6 100644
--- a/libgimp/gimplayer.c
+++ b/libgimp/gimplayer.c
@@ -63,7 +63,10 @@ gimp_layer_init (GimpLayer *layer)
  * command. Other attributes such as layer mask modes, and offsets
  * should be set with explicit procedure calls.
  *
- * Returns: The newly created layer.
+ * Returns: (transfer none): The newly created layer.
+ *          The object belongs to libgimp and you should not free it.
+ *
+ * Since: 3.0
  */
 GimpLayer *
 gimp_layer_new (GimpImage     *image,
@@ -93,7 +96,10 @@ gimp_layer_new (GimpImage     *image,
  * newly copied layer is for use within the original layer's image. It
  * should not be subsequently added to any other image.
  *
- * Returns: (transfer full): The newly copied layer.
+ * Returns: (transfer none): The newly copied layer.
+ *          The object belongs to libgimp and you should not free it.
+ *
+ * Since: 3.0
  */
 GimpLayer *
 gimp_layer_copy (GimpLayer *layer)
@@ -121,9 +127,10 @@ gimp_layer_copy (GimpLayer *layer)
  * gimp_progress_update() will be called for. You have to call
  * gimp_progress_init() beforehand then.
  *
- * Returns: The newly created layer.
+ * Returns: (transfer none): The newly created layer.
+ *          The object belongs to libgimp and you should not free it.
  *
- * Since: 2.4
+ * Since: 3.0
  */
 GimpLayer *
 gimp_layer_new_from_pixbuf (GimpImage     *image,
@@ -199,9 +206,10 @@ gimp_layer_new_from_pixbuf (GimpImage     *image,
  * gimp_progress_update() will be called for. You have to call
  * gimp_progress_init() beforehand then.
  *
- * Returns: The newly created layer.
+ * Returns: (transfer none): The newly created layer.
+ *          The object belongs to libgimp and you should not free it.
  *
- * Since: 2.8
+ * Since: 3.0
  */
 GimpLayer *
 gimp_layer_new_from_surface (GimpImage            *image,
@@ -286,7 +294,7 @@ gimp_layer_new_from_surface (GimpImage            *image,
  * command. Other attributes such as layer mask modes, and offsets
  * should be set with explicit procedure calls.
  *
- * Returns: The newly created layer.
+ * Returns: The newly created layer ID.
  */
 gint32
 gimp_layer_new_deprecated (gint32         image_id,
@@ -298,16 +306,12 @@ gimp_layer_new_deprecated (gint32         image_id,
                            GimpLayerMode  mode)
 {
   GimpLayer *layer;
-  gint32     layer_id;
 
   layer = gimp_layer_new (gimp_image_get_by_id (image_id),
                           name, width, height,
                           type, opacity, mode);
-  layer_id = gimp_item_get_id (GIMP_ITEM (layer));
-
-  g_object_unref (layer);
 
-  return layer_id;
+  return gimp_item_get_id (GIMP_ITEM (layer));
 }
 
 /**
@@ -330,7 +334,7 @@ gimp_layer_new_deprecated (gint32         image_id,
  * gimp_progress_update() will be called for. You have to call
  * gimp_progress_init() beforehand then.
  *
- * Returns: The newly created layer.
+ * Returns: The newly created layer ID.
  *
  * Since: 2.4
  */
@@ -344,16 +348,12 @@ gimp_layer_new_from_pixbuf_deprecated (gint32         image_id,
                                        gdouble        progress_end)
 {
   GimpLayer *layer;
-  gint32     layer_id;
 
   layer = gimp_layer_new_from_pixbuf (gimp_image_get_by_id (image_id),
                                       name, pixbuf, opacity, mode,
                                       progress_start, progress_end);
-  layer_id = gimp_item_get_id (GIMP_ITEM (layer));
-
-  g_object_unref (layer);
 
-  return layer_id;
+  return gimp_item_get_id (GIMP_ITEM (layer));
 }
 
 /**
@@ -374,7 +374,7 @@ gimp_layer_new_from_pixbuf_deprecated (gint32         image_id,
  * gimp_progress_update() will be called for. You have to call
  * gimp_progress_init() beforehand then.
  *
- * Returns: The newly created layer.
+ * Returns: The newly created layer ID.
  *
  * Since: 2.8
  */
@@ -386,16 +386,12 @@ gimp_layer_new_from_surface_deprecated (gint32                image_id,
                                         gdouble               progress_end)
 {
   GimpLayer *layer;
-  gint32     layer_id;
 
   layer = gimp_layer_new_from_surface (gimp_image_get_by_id (image_id),
                                        name, surface,
                                        progress_start, progress_end);
-  layer_id = gimp_item_get_id (GIMP_ITEM (layer));
 
-  g_object_unref (layer);
-
-  return layer_id;
+  return gimp_item_get_id (GIMP_ITEM (layer));
 }
 
 /**
@@ -408,25 +404,14 @@ gimp_layer_new_from_surface_deprecated (gint32                image_id,
  * newly copied layer is for use within the original layer's image. It
  * should not be subsequently added to any other image.
  *
- * Returns: The newly copied layer.
+ * Returns: The newly copied layer ID.
  */
 gint32
 gimp_layer_copy_deprecated (gint32 layer_ID)
 {
-  GimpLayer *layer;
   GimpLayer *copy;
-  gint32     copy_id;
-
-  layer = GIMP_LAYER (gimp_item_new_by_id (layer_ID));
-  g_return_val_if_fail (layer, -1);
-
-  copy = gimp_layer_copy (layer);
-  g_return_val_if_fail (copy, -1);
-
-  copy_id = gimp_item_get_id (GIMP_ITEM (copy));
 
-  g_object_unref (copy);
-  g_object_unref (layer);
+  copy = gimp_layer_copy (GIMP_LAYER (gimp_item_get_by_id (layer_ID)));
 
-  return copy_id;
+  return gimp_item_get_id (GIMP_ITEM (copy));
 }
diff --git a/libgimp/gimplayer_pdb.c b/libgimp/gimplayer_pdb.c
index 4071746d70..5d355307bc 100644
--- a/libgimp/gimplayer_pdb.c
+++ b/libgimp/gimplayer_pdb.c
@@ -53,7 +53,7 @@
  * command. Other attributes such as layer mask modes, and offsets
  * should be set with explicit procedure calls.
  *
- * Returns: (transfer full): The newly created layer.
+ * Returns: (transfer none): The newly created layer.
  **/
 GimpLayer *
 _gimp_layer_new (GimpImage     *image,
@@ -89,7 +89,7 @@ _gimp_layer_new (GimpImage     *image,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    layer = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
+    layer = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -110,7 +110,7 @@ _gimp_layer_new (GimpImage     *image,
  * gimp_image_insert_layer() command. Other attributes such as layer
  * mask modes, and offsets should be set with explicit procedure calls.
  *
- * Returns: (transfer full): The newly created layer.
+ * Returns: (transfer none): The newly created layer.
  *
  * Since: 2.6
  **/
@@ -140,7 +140,7 @@ gimp_layer_new_from_visible (GimpImage   *image,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    layer = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
+    layer = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -211,7 +211,7 @@ _gimp_layer_new_from_visible (gint32       image_ID,
  * gimp_image_insert_layer() command. Other attributes such as layer
  * mask modes, and offsets should be set with explicit procedure calls.
  *
- * Returns: (transfer full): The newly copied layer.
+ * Returns: (transfer none): The newly copied layer.
  **/
 GimpLayer *
 gimp_layer_new_from_drawable (GimpDrawable *drawable,
@@ -237,7 +237,7 @@ gimp_layer_new_from_drawable (GimpDrawable *drawable,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    layer_copy = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index 
(return_vals, 1))));
+    layer_copy = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -304,7 +304,7 @@ _gimp_layer_new_from_drawable (gint32 drawable_ID,
  * gimp_image_reorder_item(), gimp_item_get_parent(),
  * gimp_item_get_children(), gimp_item_is_group().
  *
- * Returns: (transfer full): The newly created layer group.
+ * Returns: (transfer none): The newly created layer group.
  *
  * Since: 2.8
  **/
@@ -330,7 +330,7 @@ gimp_layer_group_new (GimpImage *image)
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    layer_group = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index 
(return_vals, 1))));
+    layer_group = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -398,7 +398,7 @@ _gimp_layer_group_new (gint32 image_ID)
  * the background layer in an image is being copied and added to the
  * same image.
  *
- * Returns: (transfer full): The newly copied layer.
+ * Returns: (transfer none): The newly copied layer.
  **/
 GimpLayer *
 _gimp_layer_copy (GimpLayer *layer,
@@ -424,7 +424,7 @@ _gimp_layer_copy (GimpLayer *layer,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    layer_copy = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index 
(return_vals, 1))));
+    layer_copy = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -1009,7 +1009,7 @@ _gimp_layer_set_offsets (gint32 layer_ID,
  * 'ADD-ALPHA-TRANSFER-MASK' on a layer with no alpha channels, or with
  * 'ADD-SELECTION-MASK' when there is no selection on the image.
  *
- * Returns: (transfer full): The newly created mask.
+ * Returns: (transfer none): The newly created mask.
  **/
 GimpLayerMask *
 gimp_layer_create_mask (GimpLayer       *layer,
@@ -1035,7 +1035,7 @@ gimp_layer_create_mask (GimpLayer       *layer,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    mask = GIMP_LAYER_MASK (gimp_item_new_by_id (gimp_value_get_layer_mask_id (gimp_value_array_index 
(return_vals, 1))));
+    mask = GIMP_LAYER_MASK (gimp_item_get_by_id (gimp_value_get_layer_mask_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -1112,7 +1112,7 @@ _gimp_layer_create_mask (gint32          layer_ID,
  * This procedure returns the specified layer's mask, or -1 if none
  * exists.
  *
- * Returns: (transfer full): The layer mask.
+ * Returns: (transfer none): The layer mask.
  **/
 GimpLayerMask *
 gimp_layer_get_mask (GimpLayer *layer)
@@ -1136,7 +1136,7 @@ gimp_layer_get_mask (GimpLayer *layer)
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    mask = GIMP_LAYER_MASK (gimp_item_new_by_id (gimp_value_get_layer_mask_id (gimp_value_array_index 
(return_vals, 1))));
+    mask = GIMP_LAYER_MASK (gimp_item_get_by_id (gimp_value_get_layer_mask_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -1192,7 +1192,7 @@ _gimp_layer_get_mask (gint32 layer_ID)
  * This procedure returns the specified mask's layer , or -1 if none
  * exists.
  *
- * Returns: (transfer full): The mask's layer.
+ * Returns: (transfer none): The mask's layer.
  *
  * Since: 2.2
  **/
@@ -1218,7 +1218,7 @@ gimp_layer_from_mask (GimpLayerMask *mask)
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    layer = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
+    layer = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
 
   gimp_value_array_unref (return_vals);
 
diff --git a/libgimp/gimpprocedure.c b/libgimp/gimpprocedure.c
index cdc53ef89c..7deb52d07a 100644
--- a/libgimp/gimpprocedure.c
+++ b/libgimp/gimpprocedure.c
@@ -1447,11 +1447,11 @@ gimp_procedure_validate_args (GimpProcedure   *procedure,
                (arg_type == GIMP_TYPE_LAYER_ID &&
                 spec_type == GIMP_TYPE_LAYER))
         {
-          GValue    value = G_VALUE_INIT;
-          GimpItem *item = gimp_item_new_by_id (g_value_get_int (arg));
+          GValue value = G_VALUE_INIT;
 
           g_value_init (&value, spec_type);
-          g_value_take_object (&value, item);
+          g_value_set_object (&value,
+                              gimp_item_get_by_id (g_value_get_int (arg)));
           gimp_value_array_remove (args, i);
           gimp_value_array_insert (args, i, &value);
           g_value_unset (&value);
diff --git a/libgimp/gimpselection.c b/libgimp/gimpselection.c
index db5fa11993..9f11777c39 100644
--- a/libgimp/gimpselection.c
+++ b/libgimp/gimpselection.c
@@ -36,6 +36,7 @@ static void
 gimp_selection_init (GimpSelection *selection)
 {
 }
+
 /**
  * gimp_selection_float:
  * @image: ignored
@@ -93,21 +94,15 @@ gimp_selection_float_deprecated (gint32 image_ID,
                                  gint   offx,
                                  gint   offy)
 {
-  GimpDrawable *drawable;
-  GimpLayer    *selection;
-  gint32        selection_id = -1;
-
-  drawable = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_ID));
+  GimpLayer *selection;
+  gint32     selection_id = -1;
 
   selection = gimp_selection_float (gimp_image_get_by_id (image_ID),
-                                    drawable,
+                                    GIMP_DRAWABLE (gimp_item_get_by_id (drawable_ID)),
                                     offx,
                                     offy);
   if (selection)
     selection_id = gimp_item_get_id (GIMP_ITEM (selection));
 
-  g_object_unref (drawable);
-  g_object_unref (selection);
-
   return selection_id;
 }
diff --git a/libgimp/gimpselection_pdb.c b/libgimp/gimpselection_pdb.c
index 6838dcbda4..e98dbf5f2a 100644
--- a/libgimp/gimpselection_pdb.c
+++ b/libgimp/gimpselection_pdb.c
@@ -457,7 +457,7 @@ _gimp_selection_translate (gint32 image_ID,
  * instantiated as a floating selection. The offsets allow initial
  * positioning of the new floating selection.
  *
- * Returns: (transfer full): The floated layer.
+ * Returns: (transfer none): The floated layer.
  **/
 GimpLayer *
 _gimp_selection_float (GimpDrawable *drawable,
@@ -485,7 +485,7 @@ _gimp_selection_float (GimpDrawable *drawable,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    layer = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
+    layer = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -1244,7 +1244,7 @@ _gimp_selection_flood (gint32 image_ID)
  * new channel. The new channel is automatically inserted into the
  * image's list of channels.
  *
- * Returns: (transfer full): The new channel.
+ * Returns: (transfer none): The new channel.
  **/
 GimpChannel *
 gimp_selection_save (GimpImage *image)
@@ -1268,7 +1268,7 @@ gimp_selection_save (GimpImage *image)
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    channel = GIMP_CHANNEL (gimp_item_new_by_id (gimp_value_get_channel_id (gimp_value_array_index 
(return_vals, 1))));
+    channel = GIMP_CHANNEL (gimp_item_get_by_id (gimp_value_get_channel_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
diff --git a/libgimp/gimptextlayer_pdb.c b/libgimp/gimptextlayer_pdb.c
index 098b6db778..759e224b5d 100644
--- a/libgimp/gimptextlayer_pdb.c
+++ b/libgimp/gimptextlayer_pdb.c
@@ -51,7 +51,7 @@
  * added to the image, as this is not automatic. Add the new layer
  * using gimp_image_insert_layer().
  *
- * Returns: (transfer full): The new text layer.
+ * Returns: (transfer none): The new text layer.
  *
  * Since: 2.6
  **/
@@ -85,7 +85,7 @@ gimp_text_layer_new (GimpImage   *image,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    layer = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
+    layer = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index (return_vals, 
1))));
 
   gimp_value_array_unref (return_vals);
 
diff --git a/libgimp/gimptexttool_pdb.c b/libgimp/gimptexttool_pdb.c
index 34fd711e6c..e2269e4ae9 100644
--- a/libgimp/gimptexttool_pdb.c
+++ b/libgimp/gimptexttool_pdb.c
@@ -64,7 +64,7 @@
  * divide the size in points by 72.0 and multiply it by the image's
  * vertical resolution.
  *
- * Returns: (transfer full): The new text layer or -1 if no layer was created.
+ * Returns: (transfer none): The new text layer or -1 if no layer was created.
  **/
 GimpLayer *
 gimp_text_fontname (GimpImage    *image,
@@ -106,7 +106,7 @@ gimp_text_fontname (GimpImage    *image,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    text_layer = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id (gimp_value_array_index 
(return_vals, 1))));
+    text_layer = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
diff --git a/libgimp/gimpvectors_pdb.c b/libgimp/gimpvectors_pdb.c
index fe380a5b86..69c6acb91d 100644
--- a/libgimp/gimpvectors_pdb.c
+++ b/libgimp/gimpvectors_pdb.c
@@ -44,7 +44,7 @@
  * Creates a new empty vectors object. The vectors object needs to be
  * added to the image using gimp_image_insert_vectors().
  *
- * Returns: (transfer full):
+ * Returns: (transfer none):
  *          the current vector object, 0 if no vector exists in the image.
  *
  * Since: 2.4
@@ -73,7 +73,7 @@ gimp_vectors_new (GimpImage   *image,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    vectors = GIMP_VECTORS (gimp_item_new_by_id (gimp_value_get_vectors_id (gimp_value_array_index 
(return_vals, 1))));
+    vectors = GIMP_VECTORS (gimp_item_get_by_id (gimp_value_get_vectors_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -135,7 +135,7 @@ _gimp_vectors_new (gint32       image_ID,
  * Creates a new vectors object from a text layer. The vectors object
  * needs to be added to the image using gimp_image_insert_vectors().
  *
- * Returns: (transfer full): The vectors of the text layer.
+ * Returns: (transfer none): The vectors of the text layer.
  *
  * Since: 2.6
  **/
@@ -163,7 +163,7 @@ gimp_vectors_new_from_text_layer (GimpImage *image,
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    vectors = GIMP_VECTORS (gimp_item_new_by_id (gimp_value_get_vectors_id (gimp_value_array_index 
(return_vals, 1))));
+    vectors = GIMP_VECTORS (gimp_item_get_by_id (gimp_value_get_vectors_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
@@ -224,7 +224,7 @@ _gimp_vectors_new_from_text_layer (gint32 image_ID,
  * This procedure copies the specified vectors object and returns the
  * copy.
  *
- * Returns: (transfer full): The newly copied vectors object.
+ * Returns: (transfer none): The newly copied vectors object.
  *
  * Since: 2.6
  **/
@@ -250,7 +250,7 @@ gimp_vectors_copy (GimpVectors *vectors)
   gimp_value_array_unref (args);
 
   if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    vectors_copy = GIMP_VECTORS (gimp_item_new_by_id (gimp_value_get_vectors_id (gimp_value_array_index 
(return_vals, 1))));
+    vectors_copy = GIMP_VECTORS (gimp_item_get_by_id (gimp_value_get_vectors_id (gimp_value_array_index 
(return_vals, 1))));
 
   gimp_value_array_unref (return_vals);
 
diff --git a/libgimp/gimpzoompreview.c b/libgimp/gimpzoompreview.c
index 82f489b9f1..42d81760ea 100644
--- a/libgimp/gimpzoompreview.c
+++ b/libgimp/gimpzoompreview.c
@@ -547,7 +547,6 @@ gimp_zoom_preview_draw_buffer (GimpPreview  *preview,
                                                   src_x + offsx, src_y + offsy,
                                                   src_width, src_height,
                                                   &width, &height, &bpp);
-      g_object_unref (selection);
 
       gimp_preview_area_mask (GIMP_PREVIEW_AREA (area),
                               0, 0, width, height,
diff --git a/pdb/pdb.pl b/pdb/pdb.pl
index 064dc5fbb2..c5f4a691b6 100644
--- a/pdb/pdb.pl
+++ b/pdb/pdb.pl
@@ -185,9 +185,9 @@ package Gimp::CodeGen::pdb;
                     const_type      => 'GimpItem *',
                     id              => 1,
                     init_value      => 'NULL',
-                    out_annotate    => '(transfer full)',
+                    out_annotate    => '(transfer none)',
                     get_value_func  => '$var = gimp_value_get_item ($value, gimp)',
-                    dup_value_func  => '$var = gimp_item_new_by_id (gimp_value_get_item_id ($value))',
+                    dup_value_func  => '$var = gimp_item_get_by_id (gimp_value_get_item_id ($value))',
                     dup_value_func_d=> '$var = gimp_value_get_item_id ($value)',
                     set_value_func  => 'gimp_value_set_item_id ($value, $var)',
                     take_value_func => 'gimp_value_set_item ($value, $var)',
@@ -200,9 +200,9 @@ package Gimp::CodeGen::pdb;
                     const_type      => 'GimpLayer *',
                     id              => 1,
                     init_value      => 'NULL',
-                    out_annotate    => '(transfer full)',
+                    out_annotate    => '(transfer none)',
                     get_value_func  => '$var = gimp_value_get_layer ($value, gimp)',
-                    dup_value_func  => '$var = GIMP_LAYER (gimp_item_new_by_id (gimp_value_get_layer_id 
($value)))',
+                    dup_value_func  => '$var = GIMP_LAYER (gimp_item_get_by_id (gimp_value_get_layer_id 
($value)))',
                     dup_value_func_d=> '$var = gimp_value_get_layer_id ($value)',
                     set_value_func  => 'gimp_value_set_layer_id ($value, $var)',
                     take_value_func => 'gimp_value_set_layer ($value, $var)',
@@ -215,9 +215,9 @@ package Gimp::CodeGen::pdb;
                     const_type      => 'GimpChannel *',
                     id              => 1,
                     init_value      => 'NULL',
-                    out_annotate    => '(transfer full)',
+                    out_annotate    => '(transfer none)',
                     get_value_func  => '$var = gimp_value_get_channel ($value, gimp)',
-                    dup_value_func  => '$var = GIMP_CHANNEL (gimp_item_new_by_id (gimp_value_get_channel_id 
($value)))',
+                    dup_value_func  => '$var = GIMP_CHANNEL (gimp_item_get_by_id (gimp_value_get_channel_id 
($value)))',
                     dup_value_func_d=> '$var = gimp_value_get_channel_id ($value)',
                     set_value_func  => 'gimp_value_set_channel_id ($value, $var)',
                     take_value_func => 'gimp_value_set_channel ($value, $var)',
@@ -230,9 +230,9 @@ package Gimp::CodeGen::pdb;
                     const_type      => 'GimpDrawable *',
                     id              => 1,
                     init_value      => 'NULL',
-                    out_annotate    => '(transfer full)',
+                    out_annotate    => '(transfer none)',
                     get_value_func  => '$var = gimp_value_get_drawable ($value, gimp)',
-                    dup_value_func  => '$var = GIMP_DRAWABLE (gimp_item_new_by_id 
(gimp_value_get_drawable_id ($value)))',
+                    dup_value_func  => '$var = GIMP_DRAWABLE (gimp_item_get_by_id 
(gimp_value_get_drawable_id ($value)))',
                     dup_value_func_d=> '$var = gimp_value_get_drawable_id ($value)',
                     set_value_func  => 'gimp_value_set_drawable_id ($value, $var)',
                     take_value_func => 'gimp_value_set_drawable ($value, $var)',
@@ -245,9 +245,9 @@ package Gimp::CodeGen::pdb;
                     const_type      => 'GimpSelection *',
                     id              => 1,
                     init_value      => 'NULL',
-                    out_annotate    => '(transfer full)',
+                    out_annotate    => '(transfer none)',
                     get_value_func  => '$var = gimp_value_get_selection ($value, gimp)',
-                    dup_value_func  => '$var = GIMP_SELECTION (gimp_item_new_by_id 
(gimp_value_get_selection_id ($value)))',
+                    dup_value_func  => '$var = GIMP_SELECTION (gimp_item_get_by_id 
(gimp_value_get_selection_id ($value)))',
                     dup_value_func_d=> '$var = gimp_value_get_selection_id ($value)',
                     set_value_func  => 'gimp_value_set_selection_id ($value, $var)',
                     take_value_func => 'gimp_value_set_selection ($value, $var)',
@@ -260,9 +260,9 @@ package Gimp::CodeGen::pdb;
                     const_type      => 'GimpLayerMask *',
                     id              => 1,
                     init_value      => 'NULL',
-                    out_annotate    => '(transfer full)',
+                    out_annotate    => '(transfer none)',
                     get_value_func  => '$var = gimp_value_get_layer_mask ($value, gimp)',
-                    dup_value_func  => '$var = GIMP_LAYER_MASK (gimp_item_new_by_id 
(gimp_value_get_layer_mask_id ($value)))',
+                    dup_value_func  => '$var = GIMP_LAYER_MASK (gimp_item_get_by_id 
(gimp_value_get_layer_mask_id ($value)))',
                     dup_value_func_d=> '$var = gimp_value_get_layer_mask_id ($value)',
                     set_value_func  => 'gimp_value_set_layer_mask_id ($value, $var)',
                     take_value_func => 'gimp_value_set_layer_mask ($value, $var)',
@@ -275,9 +275,9 @@ package Gimp::CodeGen::pdb;
                     const_type      => 'GimpVectors *',
                     id              => 1,
                     init_value      => 'NULL',
-                    out_annotate    => '(transfer full)',
+                    out_annotate    => '(transfer none)',
                     get_value_func  => '$var = gimp_value_get_vectors ($value, gimp)',
-                    dup_value_func  => '$var = GIMP_VECTORS (gimp_item_new_by_id (gimp_value_get_vectors_id 
($value)))',
+                    dup_value_func  => '$var = GIMP_VECTORS (gimp_item_get_by_id (gimp_value_get_vectors_id 
($value)))',
                     dup_value_func_d=> '$var = gimp_value_get_vectors_id ($value)',
                     set_value_func  => 'gimp_value_set_vectors_id ($value, $var)',
                     take_value_func => 'gimp_value_set_vectors ($value, $var)',
diff --git a/plug-ins/common/blinds.c b/plug-ins/common/blinds.c
index 7ac7c41b75..89d324707b 100644
--- a/plug-ins/common/blinds.c
+++ b/plug-ins/common/blinds.c
@@ -150,17 +150,14 @@ run (const gchar      *name,
 
   run_mode    = param[0].data.d_int32;
   drawable_id = param[2].data.d_drawable;
-  drawable    = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_id));
+  drawable    = GIMP_DRAWABLE (gimp_item_get_by_id (drawable_id));
 
   switch (run_mode)
     {
     case GIMP_RUN_INTERACTIVE:
       gimp_get_data (PLUG_IN_PROC, &bvals);
       if (! blinds_dialog (drawable))
-        {
-          g_object_unref (drawable);
-          return;
-        }
+        return;
       break;
 
     case GIMP_RUN_NONINTERACTIVE:
@@ -202,7 +199,6 @@ run (const gchar      *name,
       status = GIMP_PDB_EXECUTION_ERROR;
     }
 
-  g_object_unref (drawable);
   values[0].data.d_status = status;
 }
 
diff --git a/plug-ins/common/checkerboard.c b/plug-ins/common/checkerboard.c
index 15ad2f714e..3b413fb449 100644
--- a/plug-ins/common/checkerboard.c
+++ b/plug-ins/common/checkerboard.c
@@ -130,17 +130,14 @@ run (const gchar      *name,
   image_ID    = param[1].data.d_int32;
   drawable_ID = param[2].data.d_drawable;
   image       = gimp_image_get_by_id (image_ID);
-  drawable    = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_ID));
+  drawable    = GIMP_DRAWABLE (gimp_item_get_by_id (drawable_ID));
 
   switch (run_mode)
     {
     case GIMP_RUN_INTERACTIVE:
       gimp_get_data (PLUG_IN_PROC, &cvals);
       if (! checkerboard_dialog (image, drawable))
-        {
-          g_object_unref (drawable);
-          return;
-        }
+        return;
       break;
 
     case GIMP_RUN_NONINTERACTIVE:
@@ -177,7 +174,6 @@ run (const gchar      *name,
       status = GIMP_PDB_EXECUTION_ERROR;
     }
 
-  g_object_unref (drawable);
   values[0].data.d_status = status;
 }
 
diff --git a/plug-ins/common/contrast-retinex.c b/plug-ins/common/contrast-retinex.c
index 57382eb9e4..c1982f0432 100644
--- a/plug-ins/common/contrast-retinex.c
+++ b/plug-ins/common/contrast-retinex.c
@@ -199,7 +199,7 @@ run (const gchar      *name,
 
   run_mode    = param[0].data.d_int32;
   drawable_ID = param[2].data.d_drawable;
-  drawable    = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_ID));
+  drawable    = GIMP_DRAWABLE (gimp_item_get_by_id (drawable_ID));
 
   if (! gimp_drawable_mask_intersect (drawable,
                                       &x, &y, &width, &height) ||
@@ -208,7 +208,6 @@ run (const gchar      *name,
     {
       status = GIMP_PDB_EXECUTION_ERROR;
       values[0].data.d_status = status;
-      g_object_unref (drawable);
       return;
     }
 
@@ -220,10 +219,7 @@ run (const gchar      *name,
 
       /*  First acquire information with a dialog  */
       if (! retinex_dialog (drawable))
-        {
-          g_object_unref (drawable);
-          return;
-        }
+        return;
       break;
 
     case GIMP_RUN_NONINTERACTIVE:
@@ -268,7 +264,6 @@ run (const gchar      *name,
       status = GIMP_PDB_EXECUTION_ERROR;
     }
 
-  g_object_unref (drawable);
   values[0].data.d_status = status;
 }
 
diff --git a/plug-ins/common/despeckle.c b/plug-ins/common/despeckle.c
index 48f4a7e441..6a576ff641 100644
--- a/plug-ins/common/despeckle.c
+++ b/plug-ins/common/despeckle.c
@@ -188,7 +188,7 @@ run (const gchar      *name,
 
   run_mode    = param[0].data.d_int32;
   drawable_ID = param[2].data.d_drawable;
-  drawable    = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_ID));
+  drawable    = GIMP_DRAWABLE (gimp_item_get_by_id (drawable_ID));
 
   switch (run_mode)
     {
@@ -199,10 +199,7 @@ run (const gchar      *name,
           gimp_drawable_is_gray (drawable))
        {
           if (! despeckle_dialog ())
-            {
-              g_object_unref (drawable);
-              return;
-            }
+            return;
        }
       break;
 
@@ -270,7 +267,6 @@ run (const gchar      *name,
         }
     }
 
-  g_object_unref (drawable);
   values[0].data.d_status = status;
 }
 
diff --git a/plug-ins/common/destripe.c b/plug-ins/common/destripe.c
index 11bf6de14f..9696fb760a 100644
--- a/plug-ins/common/destripe.c
+++ b/plug-ins/common/destripe.c
@@ -143,7 +143,7 @@ run (const gchar      *name,
 
   run_mode    = param[0].data.d_int32;
   drawable_ID = param[2].data.d_drawable;
-  drawable    = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_ID));
+  drawable    = GIMP_DRAWABLE (gimp_item_get_by_id (drawable_ID));
 
   switch (run_mode)
     {
@@ -157,10 +157,7 @@ run (const gchar      *name,
        * Get information from the dialog...
        */
       if (! destripe_dialog (drawable))
-        {
-          g_object_unref (drawable);
-          return;
-        }
+        return;
       break;
 
     case GIMP_RUN_NONINTERACTIVE:
@@ -217,8 +214,6 @@ run (const gchar      *name,
         }
     };
 
-  g_object_unref (drawable);
-
   /*
    * Reset the current run status...
    */
diff --git a/plug-ins/common/grid.c b/plug-ins/common/grid.c
index 875625a623..7bb7025b7b 100644
--- a/plug-ins/common/grid.c
+++ b/plug-ins/common/grid.c
@@ -179,7 +179,7 @@ run (const gchar      *name,
   image_ID    = param[1].data.d_int32;
   drawable_ID = param[2].data.d_drawable;
   image       = gimp_image_get_by_id (image_ID);
-  drawable    = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_ID));
+  drawable    = GIMP_DRAWABLE (gimp_item_get_by_id (drawable_ID));
 
   if (run_mode == GIMP_RUN_NONINTERACTIVE)
     {
@@ -254,8 +254,6 @@ run (const gchar      *name,
         gimp_set_data (PLUG_IN_PROC, &grid_cfg, sizeof (grid_cfg));
     }
 
-  g_object_unref (drawable);
-
   values[0].type          = GIMP_PDB_STATUS;
   values[0].data.d_status = status;
 }
diff --git a/plug-ins/common/jigsaw.c b/plug-ins/common/jigsaw.c
index 750458fcca..58b188c28c 100644
--- a/plug-ins/common/jigsaw.c
+++ b/plug-ins/common/jigsaw.c
@@ -387,7 +387,7 @@ run (const gchar      *name,
 
   run_mode    = param[0].data.d_int32;
   drawable_id = param[2].data.d_drawable;
-  drawable    = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_id));
+  drawable    = GIMP_DRAWABLE (gimp_item_get_by_id (drawable_id));
 
   switch (run_mode)
     {
@@ -428,8 +428,6 @@ run (const gchar      *name,
       gimp_displays_flush ();
     }  /* switch */
 
-  g_object_unref (drawable);
-
   *nreturn_vals = 1;
   *return_vals = values;
   values[0].type = GIMP_PDB_STATUS;
diff --git a/plug-ins/common/nl-filter.c b/plug-ins/common/nl-filter.c
index f9b3130f48..a92eb4dca9 100644
--- a/plug-ins/common/nl-filter.c
+++ b/plug-ins/common/nl-filter.c
@@ -153,7 +153,7 @@ run (const gchar      *name,
 
   run_mode    = param[0].data.d_int32;
   drawable_id = param[2].data.d_drawable;
-  drawable    = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_id));
+  drawable    = GIMP_DRAWABLE (gimp_item_get_by_id (drawable_id));
 
   *nreturn_vals = 1;
   *return_vals  = values;
@@ -167,10 +167,7 @@ run (const gchar      *name,
       gimp_get_data (PLUG_IN_PROC, &nlfvals);
 
       if (! nlfilter_dialog (drawable))
-        {
-          g_object_unref (drawable);
-          return;
-        }
+        return;
       break;
 
     case GIMP_RUN_NONINTERACTIVE:
@@ -204,7 +201,6 @@ run (const gchar      *name,
         gimp_set_data (PLUG_IN_PROC, &nlfvals, sizeof (NLFilterValues));
     }
 
-  g_object_unref (drawable);
   values[0].data.d_status = status;
 }
 
diff --git a/plug-ins/common/sparkle.c b/plug-ins/common/sparkle.c
index 6220a39d80..1107cde4cd 100644
--- a/plug-ins/common/sparkle.c
+++ b/plug-ins/common/sparkle.c
@@ -216,12 +216,11 @@ run (const gchar      *name,
 
   run_mode    = param[0].data.d_int32;
   drawable_ID = param[2].data.d_drawable;
-  drawable    = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_ID));
+  drawable    = GIMP_DRAWABLE (gimp_item_get_by_id (drawable_ID));
 
   if (! gimp_drawable_mask_intersect (drawable, &x, &y, &w, &h))
     {
       g_message (_("Region selected for filter is empty"));
-      g_object_unref (drawable);
       return;
     }
 
@@ -233,10 +232,7 @@ run (const gchar      *name,
 
       /*  First acquire information with a dialog  */
       if (! sparkle_dialog (drawable))
-        {
-          g_object_unref (drawable);
-          return;
-        }
+        return;
       break;
 
     case GIMP_RUN_NONINTERACTIVE:
@@ -315,7 +311,6 @@ run (const gchar      *name,
       status = GIMP_PDB_EXECUTION_ERROR;
     }
 
-  g_object_unref (drawable);
   values[0].data.d_status = status;
 }
 


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