libgimp: s/gimp_image_new_by_id()/gimp_image_get_by_id()/

This means that images' ownership is not given to caller in particular.
libgimp will now keep a reference of all GimpImage-s it creates and
return this same reference if called again. It also means that you can
now compare images by pointer comparison (as 2 GimpImage objects
representing the same image ID will be equal).
Obviously as a side effect, gimp_image_list() is changed to (transfer
container) as you must only free the container now, not the elements.
Also various other functions creating new images are now (transfer none)
too.

Long-time plug-ins will have to be taken in consideration in a further
step (we currently never free GimpImage for destroyed images in
particular).
This commit is contained in:
Jehan 2019-08-15 10:01:08 +02:00
parent 8559cee053
commit cfd30ec62a
23 changed files with 114 additions and 230 deletions

View File

@ -339,7 +339,6 @@ gimp_aspect_preview_draw_buffer (GimpPreview *preview,
g_free (sel);
g_free (src);
}
g_object_unref (image);
}
static void

View File

@ -111,15 +111,14 @@ gimp_channel_new_deprecated (gint32 image_id,
gdouble opacity,
const GimpRGB *color)
{
GimpImage *image = gimp_image_new_by_id (image_id);
GimpChannel *channel;
gint32 channel_id;
channel = gimp_channel_new (image, name, width, height,
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 (image);
g_object_unref (channel);
return channel_id;

View File

@ -347,7 +347,6 @@ gimp_drawable_get_format (GimpDrawable *drawable)
format = babl_format_with_space (format_str, space);
}
g_object_unref (image);
g_free (format_str);
}

View File

@ -485,7 +485,6 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview,
default:
g_free (sel);
g_free (src);
g_object_unref (image);
return;
}
@ -506,7 +505,6 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview,
g_free (src);
}
}
g_object_unref (image);
}
static void
@ -552,7 +550,6 @@ gimp_drawable_preview_set_drawable (GimpDrawablePreview *drawable_preview,
cmap = gimp_image_get_colormap (image, &num_colors);
gimp_preview_area_set_colormap (GIMP_PREVIEW_AREA (area),
cmap, num_colors);
g_object_unref (image);
g_free (cmap);
}
}

View File

@ -432,7 +432,7 @@ _gimp_edit_paste (gint32 drawable_ID,
* previously made to either gimp_edit_cut() or gimp_edit_copy(). This
* procedure returns the new image or -1 if the edit buffer was empty.
*
* Returns: (transfer full): The new image.
* Returns: (transfer none): The new image.
*
* Since: 2.10
**/
@ -457,7 +457,7 @@ gimp_edit_paste_as_new_image (void)
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
image = gimp_image_new_by_id (gimp_value_get_image_id (gimp_value_array_index (return_vals, 1)));
image = gimp_image_get_by_id (gimp_value_get_image_id (gimp_value_array_index (return_vals, 1)));
gimp_value_array_unref (return_vals);
@ -902,7 +902,7 @@ _gimp_edit_named_paste (gint32 drawable_ID,
* This procedure works like gimp_edit_paste_as_new_image() but pastes
* a named buffer instead of the global buffer.
*
* Returns: (transfer full): The new image.
* Returns: (transfer none): The new image.
*
* Since: 2.10
**/
@ -928,7 +928,7 @@ gimp_edit_named_paste_as_new_image (const gchar *buffer_name)
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
image = gimp_image_new_by_id (gimp_value_get_image_id (gimp_value_array_index (return_vals, 1)));
image = gimp_image_get_by_id (gimp_value_get_image_id (gimp_value_array_index (return_vals, 1)));
gimp_value_array_unref (return_vals);

View File

@ -1147,28 +1147,22 @@ gimp_export_image_deprecated (gint32 *image_ID,
GimpExportCapabilities capabilities)
{
GimpImage *image;
GimpImage *new_image;
GimpDrawable *drawable;
GimpDrawable *new_drawable;
GimpExportReturn retval;
image = gimp_image_new_by_id (*image_ID);
new_image = image;
image = gimp_image_get_by_id (*image_ID);
drawable = GIMP_DRAWABLE (gimp_item_new_by_id (*drawable_ID));
new_drawable = drawable;
retval = gimp_export_image (&new_image, &new_drawable,
retval = gimp_export_image (&image, &new_drawable,
format_name, capabilities);
*image_ID = gimp_image_get_id (new_image);
*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_image);
g_object_unref (new_drawable);
}
g_object_unref (new_drawable);
g_object_unref (image);
g_object_unref (drawable);
return retval;

View File

@ -50,7 +50,7 @@
* https://www.gimp.org/foo.png he wants to fetch a URL, and the full
* pathname will not look like a URL.
*
* Returns: (transfer full): The output image.
* Returns: (transfer none): The output image.
**/
GimpImage *
gimp_file_load (GimpRunMode run_mode,
@ -78,7 +78,7 @@ gimp_file_load (GimpRunMode run_mode,
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
image = gimp_image_new_by_id (gimp_value_get_image_id (gimp_value_array_index (return_vals, 1)));
image = gimp_image_get_by_id (gimp_value_get_image_id (gimp_value_array_index (return_vals, 1)));
gimp_value_array_unref (return_vals);

View File

@ -36,6 +36,9 @@ struct _GimpImagePrivate
gint id;
};
static GHashTable *gimp_images = NULL;
static void gimp_image_set_property (GObject *object,
guint property_id,
const GValue *value,
@ -131,29 +134,49 @@ gimp_image_get_property (GObject *object,
gint32
gimp_image_get_id (GimpImage *image)
{
return image->priv->id;
return image ? image->priv->id : -1;
}
/**
* gimp_image_new_by_id:
* gimp_image_get_by_id:
* @image_id: The image id.
*
* Returns: (nullable) (transfer full): a #GimpImage for @image_id or
* Returns: (nullable) (transfer none): a #GimpImage for @image_id or
* %NULL if @image_id does not represent a valid image.
* The object belongs to libgimp and you should not free it.
*
* Since: 3.0
**/
GimpImage *
gimp_image_new_by_id (gint32 image_id)
gimp_image_get_by_id (gint32 image_id)
{
GimpImage *image;
GimpImage *image = NULL;
image = g_object_new (GIMP_TYPE_IMAGE,
"id", image_id,
NULL);
if (G_UNLIKELY (! gimp_images))
gimp_images = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
NULL,
(GDestroyNotify) g_object_unref);
if (! gimp_image_is_valid (image))
g_clear_object (&image);
if (! _gimp_image_is_valid (image_id))
{
g_hash_table_remove (gimp_images, GINT_TO_POINTER (image_id));
}
else
{
image = g_hash_table_lookup (gimp_images,
GINT_TO_POINTER (image_id));
if (! image)
{
image = g_object_new (GIMP_TYPE_IMAGE,
"id", image_id,
NULL);
g_hash_table_insert (gimp_images,
GINT_TO_POINTER (image_id),
image);
}
}
return image;
}
@ -165,10 +188,10 @@ gimp_image_new_by_id (gint32 image_id)
*
* This procedure returns the list of images currently open in GIMP.
*
* Returns: (element-type GimpImage) (transfer full):
* Returns: (element-type GimpImage) (transfer container):
* The list of images currently open.
* 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(). Image
* elements belong to libgimp and must not be freed.
**/
GList *
gimp_image_list (void)
@ -180,13 +203,8 @@ gimp_image_list (void)
ids = _gimp_image_list (&num_images);
for (i = 0; i < num_images; i++)
{
GimpImage *image;
image = gimp_image_new_by_id (ids[i]);
images = g_list_prepend (images, image);
}
images = g_list_prepend (images,
gimp_image_get_by_id (ids[i]));
images = g_list_reverse (images);
g_free (ids);
@ -547,14 +565,8 @@ gint *
gimp_image_get_layers_deprecated (gint32 image_id,
gint *num_layers)
{
GimpImage *image;
gint *layers;
image = gimp_image_new_by_id (image_id);
layers = _gimp_image_get_layers (image, num_layers);
g_object_unref (image);
return layers;
return _gimp_image_get_layers (gimp_image_get_by_id (image_id),
num_layers);
}
/**
@ -578,14 +590,8 @@ gint *
gimp_image_get_channels_deprecated (gint32 image_id,
gint *num_channels)
{
GimpImage *image;
gint *channels;
image = gimp_image_new_by_id (image_id);
channels = _gimp_image_get_layers (image, num_channels);
g_object_unref (image);
return channels;
return _gimp_image_get_layers (gimp_image_get_by_id (image_id),
num_channels);
}
/**
@ -608,14 +614,8 @@ gint *
gimp_image_get_vectors_deprecated (gint32 image_id,
gint *num_vectors)
{
GimpImage *image;
gint *vectors;
image = gimp_image_new_by_id (image_id);
vectors = _gimp_image_get_vectors (image, num_vectors);
g_object_unref (image);
return vectors;
return _gimp_image_get_vectors (gimp_image_get_by_id (image_id),
num_vectors);
}
/**
@ -635,14 +635,8 @@ guchar *
gimp_image_get_colormap_deprecated (gint32 image_id,
gint *num_colors)
{
GimpImage *image = gimp_image_new_by_id (image_id);
guchar *colormap;
colormap = gimp_image_get_colormap (image, num_colors);
g_object_unref (image);
return colormap;
return gimp_image_get_colormap (gimp_image_get_by_id (image_id),
num_colors);
}
/**
@ -665,14 +659,8 @@ gimp_image_set_colormap_deprecated (gint32 image_id,
const guchar *colormap,
gint num_colors)
{
GimpImage *image = gimp_image_new_by_id (image_id);
gboolean success;
success = gimp_image_set_colormap (image, colormap, num_colors);
g_object_unref (image);
return success;
return gimp_image_set_colormap (gimp_image_get_by_id (image_id),
colormap, num_colors);
}
/**
@ -697,14 +685,8 @@ gimp_image_get_thumbnail_data_deprecated (gint32 image_id,
gint *height,
gint *bpp)
{
GimpImage *image = gimp_image_new_by_id (image_id);
guchar *thumbdata;
thumbdata = gimp_image_get_thumbnail_data (image, width, height, bpp);
g_object_unref (image);
return thumbdata;
return gimp_image_get_thumbnail_data (gimp_image_get_by_id (image_id),
width, height, bpp);
}
/**
@ -727,14 +709,8 @@ gimp_image_get_thumbnail_deprecated (gint32 image_id,
gint height,
GimpPixbufTransparency alpha)
{
GimpImage *image = gimp_image_new_by_id (image_id);
GdkPixbuf *thumbnail;
thumbnail = gimp_image_get_thumbnail (image, width, height, alpha);
g_object_unref (image);
return thumbnail;
return gimp_image_get_thumbnail (gimp_image_get_by_id (image_id),
width, height, alpha);
}
/**
@ -753,14 +729,7 @@ gimp_image_get_thumbnail_deprecated (gint32 image_id,
GimpMetadata *
gimp_image_get_metadata_deprecated (gint32 image_id)
{
GimpImage *image = gimp_image_new_by_id (image_id);
GimpMetadata *metadata;
metadata = gimp_image_get_metadata (image);
g_object_unref (image);
return metadata;
return gimp_image_get_metadata (gimp_image_get_by_id (image_id));
}
/**
@ -781,12 +750,6 @@ gboolean
gimp_image_set_metadata_deprecated (gint32 image_id,
GimpMetadata *metadata)
{
GimpImage *image = gimp_image_new_by_id (image_id);
gboolean success;
success = gimp_image_set_metadata (image, metadata);
g_object_unref (image);
return success;
return gimp_image_set_metadata (gimp_image_get_by_id (image_id),
metadata);
}

View File

@ -66,7 +66,7 @@ struct _GimpImageClass
GType gimp_image_get_type (void) G_GNUC_CONST;
gint32 gimp_image_get_id (GimpImage *image);
GimpImage * gimp_image_new_by_id (gint32 image_id);
GimpImage * gimp_image_get_by_id (gint32 image_id);
GList * gimp_image_list (void);

View File

@ -183,7 +183,7 @@ _gimp_image_list (gint *num_images)
* gimp_image_set_colormap(). An indexed image without a colormap will
* output unexpected colors.
*
* Returns: (transfer full): The newly created image.
* Returns: (transfer none): The newly created image.
**/
GimpImage *
gimp_image_new (gint width,
@ -211,7 +211,7 @@ gimp_image_new (gint width,
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
image = gimp_image_new_by_id (gimp_value_get_image_id (gimp_value_array_index (return_vals, 1)));
image = gimp_image_get_by_id (gimp_value_get_image_id (gimp_value_array_index (return_vals, 1)));
gimp_value_array_unref (return_vals);
@ -287,7 +287,7 @@ _gimp_image_new (gint width,
* GIMP_PRECISION_U8_NON_LINEAR precision. See gimp_image_new() for
* further details.
*
* Returns: (transfer full): The newly created image.
* Returns: (transfer none): The newly created image.
*
* Since: 2.10
**/
@ -319,7 +319,7 @@ gimp_image_new_with_precision (gint width,
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
image = gimp_image_new_by_id (gimp_value_get_image_id (gimp_value_array_index (return_vals, 1)));
image = gimp_image_get_by_id (gimp_value_get_image_id (gimp_value_array_index (return_vals, 1)));
gimp_value_array_unref (return_vals);
@ -389,7 +389,7 @@ _gimp_image_new_with_precision (gint width,
* This procedure duplicates the specified image, copying all layers,
* channels, and image information.
*
* Returns: (transfer full): The new, duplicated image.
* Returns: (transfer none): The new, duplicated image.
**/
GimpImage *
gimp_image_duplicate (GimpImage *image)
@ -413,7 +413,7 @@ gimp_image_duplicate (GimpImage *image)
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
new_image = gimp_image_new_by_id (gimp_value_get_image_id (gimp_value_array_index (return_vals, 1)));
new_image = gimp_image_get_by_id (gimp_value_get_image_id (gimp_value_array_index (return_vals, 1)));
gimp_value_array_unref (return_vals);

View File

@ -191,14 +191,7 @@ gimp_image_convert_color_profile (GimpImage *image,
GimpColorProfile *
gimp_image_get_color_profile_deprecated (gint32 image_id)
{
GimpImage *image = gimp_image_new_by_id (image_id);
GimpColorProfile *profile;
profile = gimp_image_get_color_profile (image);
g_object_unref (image);
return profile;
return gimp_image_get_color_profile (gimp_image_get_by_id (image_id));
}
/**
@ -216,14 +209,8 @@ gboolean
gimp_image_set_color_profile_deprecated (gint32 image_id,
GimpColorProfile *profile)
{
GimpImage *image = gimp_image_new_by_id (image_id);
gboolean success;
success = gimp_image_set_color_profile (image, profile);
g_object_unref (image);
return success;
return gimp_image_set_color_profile (gimp_image_get_by_id (image_id),
profile);
}
/**
@ -245,14 +232,7 @@ gimp_image_set_color_profile_deprecated (gint32 image_id,
GimpColorProfile *
gimp_image_get_effective_color_profile_deprecated (gint32 image_id)
{
GimpImage *image = gimp_image_new_by_id (image_id);
GimpColorProfile *profile;
profile = gimp_image_get_effective_color_profile (image);
g_object_unref (image);
return profile;
return gimp_image_get_effective_color_profile (gimp_image_get_by_id (image_id));
}
/**
@ -276,12 +256,6 @@ gimp_image_convert_color_profile_deprecated (gint32 image_id,
GimpColorRenderingIntent intent,
gboolean bpc)
{
GimpImage *image = gimp_image_new_by_id (image_id);
gboolean success;
success = gimp_image_convert_color_profile (image, profile, intent, bpc);
g_object_unref (image);
return success;
return gimp_image_convert_color_profile (gimp_image_get_by_id (image_id),
profile, intent, bpc);
}

View File

@ -191,7 +191,7 @@ gimp_image_combo_box_populate (GimpImageComboBox *combo_box)
combo_box->constraint_d,
combo_box->data);
g_list_free_full (images, g_object_unref);
g_list_free (images);
if (gtk_tree_model_get_iter_first (model, &iter))
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
@ -288,10 +288,7 @@ gimp_image_combo_box_changed (GimpImageComboBox *combo_box)
if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (combo_box),
&image_ID))
{
GimpImage *image;
image = gimp_image_new_by_id (image_ID);
if (! gimp_image_is_valid (image))
if (! _gimp_image_is_valid (image_ID))
{
GtkTreeModel *model;
@ -302,7 +299,6 @@ gimp_image_combo_box_changed (GimpImageComboBox *combo_box)
gtk_list_store_clear (GTK_LIST_STORE (model));
gimp_image_combo_box_populate (combo_box);
}
g_object_unref (image);
}
}

View File

@ -666,7 +666,7 @@ gimp_image_metadata_save_finish (GimpImage *image,
*
* Retrieves a thumbnail from metadata if present.
*
* Returns: (transfer full) (nullable): a #GimpImage of the @file thumbnail.
* Returns: (transfer none) (nullable): a #GimpImage of the @file thumbnail.
*/
GimpImage *
gimp_image_metadata_load_thumbnail (GFile *file,
@ -705,8 +705,8 @@ gimp_image_metadata_load_thumbnail (GFile *file,
GimpLayer *layer;
image = gimp_image_new (gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
GIMP_RGB);
gdk_pixbuf_get_height (pixbuf),
GIMP_RGB);
gimp_image_undo_disable (image);
layer = gimp_layer_new_from_pixbuf (image, _("Background"),
@ -1059,14 +1059,8 @@ gimp_image_metadata_load_prepare_deprecated (gint32 image_id,
GFile *file,
GError **error)
{
GimpImage *image = gimp_image_new_by_id (image_id);
GimpMetadata *metadata;
metadata = gimp_image_metadata_load_prepare (image, mime_type, file, error);
g_object_unref (image);
return metadata;
return gimp_image_metadata_load_prepare (gimp_image_get_by_id (image_id),
mime_type, file, error);
}
/**
@ -1090,10 +1084,8 @@ gimp_image_metadata_load_finish_deprecated (gint32 image_id,
GimpMetadataLoadFlags flags,
gboolean interactive)
{
GimpImage *image = gimp_image_new_by_id (image_id);
gimp_image_metadata_load_finish (image, mime_type, metadata, flags, interactive);
g_object_unref (image);
gimp_image_metadata_load_finish (gimp_image_get_by_id (image_id),
mime_type, metadata, flags, interactive);
}
/**
@ -1127,14 +1119,8 @@ gimp_image_metadata_save_prepare_deprecated (gint32 image_id,
const gchar *mime_type,
GimpMetadataSaveFlags *suggested_flags)
{
GimpImage *image = gimp_image_new_by_id (image_id);
GimpMetadata *metadata;
metadata = gimp_image_metadata_save_prepare (image, mime_type, suggested_flags);
g_object_unref (image);
return metadata;
return gimp_image_metadata_save_prepare (gimp_image_get_by_id (image_id),
mime_type, suggested_flags);
}
/**
@ -1162,15 +1148,9 @@ gimp_image_metadata_save_finish_deprecated (gint32 image_id,
GFile *file,
GError **error)
{
GimpImage *image = gimp_image_new_by_id (image_id);
gboolean success;
success = gimp_image_metadata_save_finish (image, mime_type, metadata,
flags, file, error);
g_object_unref (image);
return success;
return gimp_image_metadata_save_finish (gimp_image_get_by_id (image_id),
mime_type, metadata,
flags, file, error);
}
/**
@ -1187,11 +1167,8 @@ gimp_image_metadata_load_thumbnail_deprecated (GFile *file,
GError **error)
{
GimpImage *image;
gint32 image_id;
image = gimp_image_metadata_load_thumbnail (file, error);
image_id = gimp_image_get_id (image);
g_object_unref (image);
return image_id;
return gimp_image_get_id (image);
}

View File

@ -126,7 +126,7 @@ _gimp_item_is_valid (gint32 item_ID)
*
* This procedure returns the item's image.
*
* Returns: (transfer full): The item's image.
* Returns: (transfer none): The item's image.
*
* Since: 2.8
**/
@ -152,7 +152,7 @@ gimp_item_get_image (GimpItem *item)
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
image = gimp_image_new_by_id (gimp_value_get_image_id (gimp_value_array_index (return_vals, 1)));
image = gimp_image_get_by_id (gimp_value_get_image_id (gimp_value_array_index (return_vals, 1)));
gimp_value_array_unref (return_vals);

View File

@ -427,7 +427,7 @@ gimp_item_combo_box_populate (GimpIntComboBox *combo_box)
}
}
g_list_free_full (images, g_object_unref);
g_list_free (images);
if (gtk_tree_model_get_iter_first (model, &iter))
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);

View File

@ -297,15 +297,14 @@ gimp_layer_new_deprecated (gint32 image_id,
gdouble opacity,
GimpLayerMode mode)
{
GimpImage *image = gimp_image_new_by_id (image_id);
GimpLayer *layer;
gint32 layer_id;
layer = gimp_layer_new (image, name, width, height,
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 (image);
g_object_unref (layer);
return layer_id;
@ -344,15 +343,14 @@ gimp_layer_new_from_pixbuf_deprecated (gint32 image_id,
gdouble progress_start,
gdouble progress_end)
{
GimpImage *image = gimp_image_new_by_id (image_id);
GimpLayer *layer;
gint32 layer_id;
layer = gimp_layer_new_from_pixbuf (image, name, pixbuf, opacity, mode,
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 (image);
g_object_unref (layer);
return layer_id;
@ -387,15 +385,14 @@ gimp_layer_new_from_surface_deprecated (gint32 image_id,
gdouble progress_start,
gdouble progress_end)
{
GimpImage *image = gimp_image_new_by_id (image_id);
GimpLayer *layer;
gint32 layer_id;
layer = gimp_layer_new_from_surface (image, name, surface,
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 (image);
g_object_unref (layer);
return layer_id;

View File

@ -116,20 +116,16 @@ gimp_param_image_id_validate (GParamSpec *pspec,
GValue *value)
{
GimpParamSpecImageID *ispec = GIMP_PARAM_SPEC_IMAGE_ID (pspec);
GimpImage *image;
gint image_id = value->data[0].v_int;
if (ispec->none_ok && (image_id == 0 || image_id == -1))
return FALSE;
image = gimp_image_new_by_id (image_id);
if (! gimp_image_is_valid (image))
if (! _gimp_image_is_valid (image_id))
{
value->data[0].v_int = -1;
g_object_unref (image);
return TRUE;
}
g_object_unref (image);
return FALSE;
}

View File

@ -1431,11 +1431,11 @@ gimp_procedure_validate_args (GimpProcedure *procedure,
if (arg_type == GIMP_TYPE_IMAGE_ID &&
spec_type == GIMP_TYPE_IMAGE)
{
GValue value = G_VALUE_INIT;
GimpImage *image = gimp_image_new_by_id (g_value_get_int (arg));
GValue value = G_VALUE_INIT;
g_value_init (&value, GIMP_TYPE_IMAGE);
g_value_take_object (&value, image);
g_value_set_object (&value,
gimp_image_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);

View File

@ -93,21 +93,19 @@ gimp_selection_float_deprecated (gint32 image_ID,
gint offx,
gint offy)
{
GimpImage *image;
GimpDrawable *drawable;
GimpLayer *selection;
gint32 selection_id = -1;
image = gimp_image_new_by_id (image_ID);
drawable = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_ID));
selection = gimp_selection_float (image, drawable,
selection = gimp_selection_float (gimp_image_get_by_id (image_ID),
drawable,
offx,
offy);
if (selection)
selection_id = gimp_item_get_id (GIMP_ITEM (selection));
g_object_unref (image);
g_object_unref (drawable);
g_object_unref (selection);

View File

@ -559,8 +559,6 @@ gimp_zoom_preview_draw_buffer (GimpPreview *preview,
g_free (sel);
g_free (src);
}
g_object_unref (image);
}
static void

View File

@ -170,9 +170,9 @@ package Gimp::CodeGen::pdb;
const_type => 'GimpImage *',
id => 1,
init_value => 'NULL',
out_annotate => '(transfer full)',
out_annotate => '(transfer none)',
get_value_func => '$var = gimp_value_get_image ($value, gimp)',
dup_value_func => '$var = gimp_image_new_by_id (gimp_value_get_image_id ($value))',
dup_value_func => '$var = gimp_image_get_by_id (gimp_value_get_image_id ($value))',
dup_value_func_d=> '$var = gimp_value_get_image_id ($value)',
set_value_func => 'gimp_value_set_image_id ($value, gimp_image_get_id ($var))',
take_value_func => 'gimp_value_set_image ($value, $var)',

View File

@ -129,7 +129,7 @@ run (const gchar *name,
run_mode = param[0].data.d_int32;
image_ID = param[1].data.d_int32;
drawable_ID = param[2].data.d_drawable;
image = gimp_image_new_by_id (image_ID);
image = gimp_image_get_by_id (image_ID);
drawable = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_ID));
switch (run_mode)
@ -138,7 +138,6 @@ run (const gchar *name,
gimp_get_data (PLUG_IN_PROC, &cvals);
if (! checkerboard_dialog (image, drawable))
{
g_object_unref (image);
g_object_unref (drawable);
return;
}
@ -179,7 +178,6 @@ run (const gchar *name,
}
g_object_unref (drawable);
g_object_unref (image);
values[0].data.d_status = status;
}

View File

@ -178,7 +178,7 @@ run (const gchar *name,
run_mode = param[0].data.d_int32;
image_ID = param[1].data.d_int32;
drawable_ID = param[2].data.d_drawable;
image = gimp_image_new_by_id (image_ID);
image = gimp_image_get_by_id (image_ID);
drawable = GIMP_DRAWABLE (gimp_item_new_by_id (drawable_ID));
if (run_mode == GIMP_RUN_NONINTERACTIVE)
@ -254,7 +254,6 @@ run (const gchar *name,
gimp_set_data (PLUG_IN_PROC, &grid_cfg, sizeof (grid_cfg));
}
g_object_unref (image);
g_object_unref (drawable);
values[0].type = GIMP_PDB_STATUS;