[gimp] Iterate over all an image's items recursively
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Iterate over all an image's items recursively
- Date: Sun, 2 Aug 2009 15:46:56 +0000 (UTC)
commit 87d463aed093139672d41f468e45522f9b2ce1b6
Author: Michael Natterer <mitch gimp org>
Date: Sun Aug 2 17:44:05 2009 +0200
Iterate over all an image's items recursively
Use gimp_image_get_layer,channel,vectors_list() instead of
gimp_image_get_layer,channel,vectors_iter(). As a side-effect,
simplified some code that was making sure we don't modify the list
returned by the old functions (the new functions return newly
allocated lists so we can safely remove items from the image while
iterating it). Some places will need adjusting once we really have
item trees.
app/core/gimpimage-convert.c | 15 ++++++----
app/core/gimpimage-crop.c | 25 +++++++++-------
app/core/gimpimage-duplicate.c | 31 +++++++++++++++-----
app/core/gimpimage-flip.c | 37 +++++++++++++++---------
app/core/gimpimage-item-list.c | 25 ++++++++++------
app/core/gimpimage-resize.c | 55 +++++++++++++++++++++++------------
app/core/gimpimage-rotate.c | 29 +++++++++++--------
app/core/gimpimage-scale.c | 61 +++++++++++++++++++---------------------
8 files changed, 167 insertions(+), 111 deletions(-)
---
diff --git a/app/core/gimpimage-convert.c b/app/core/gimpimage-convert.c
index 738dcfb..7f99418 100644
--- a/app/core/gimpimage-convert.c
+++ b/app/core/gimpimage-convert.c
@@ -766,6 +766,7 @@ gimp_image_convert (GimpImage *image,
{
QuantizeObj *quantobj = NULL;
GimpImageBaseType old_type;
+ GList *all_layers;
GList *list;
const gchar *undo_desc = NULL;
gint nth_layer, n_layers;
@@ -797,7 +798,9 @@ gimp_image_convert (GimpImage *image,
gimp_set_busy (image->gimp);
- n_layers = gimp_container_get_n_children (GIMP_CONTAINER (image->layers));
+ all_layers = gimp_image_get_layer_list (image);
+
+ n_layers = g_list_length (all_layers);
switch (new_type)
{
@@ -866,7 +869,7 @@ gimp_image_convert (GimpImage *image,
num_found_cols = 0;
/* Build the histogram */
- for (list = gimp_image_get_layer_iter (image), nth_layer = 0;
+ for (list = all_layers, nth_layer = 0;
list;
list = g_list_next (list), nth_layer++)
{
@@ -951,7 +954,7 @@ gimp_image_convert (GimpImage *image,
if (quantobj)
quantobj->n_layers = n_layers;
- for (list = gimp_image_get_layer_iter (image), nth_layer = 0;
+ for (list = all_layers, nth_layer = 0;
list;
list = g_list_next (list), nth_layer++)
{
@@ -1025,9 +1028,7 @@ gimp_image_convert (GimpImage *image,
remap_table, &num_entries);
/* Convert all layers */
- for (list = gimp_image_get_layer_iter (image);
- list;
- list = g_list_next (list))
+ for (list = all_layers; list; list = g_list_next (list))
{
remap_indexed_layer (list->data, remap_table, num_entries);
}
@@ -1086,6 +1087,8 @@ gimp_image_convert (GimpImage *image,
gimp_image_mode_changed (image);
g_object_thaw_notify (G_OBJECT (image));
+ g_list_free (all_layers);
+
gimp_unset_busy (image->gimp);
return TRUE;
diff --git a/app/core/gimpimage-crop.c b/app/core/gimpimage-crop.c
index f509a18..9cdaa5e 100644
--- a/app/core/gimpimage-crop.c
+++ b/app/core/gimpimage-crop.c
@@ -118,9 +118,16 @@ gimp_image_crop (GimpImage *image,
}
else
{
+ GList *all_layers;
+ GList *all_channels;
+ GList *all_vectors;
GimpItem *item;
GList *list;
+ all_layers = gimp_image_get_layer_list (image);
+ all_channels = gimp_image_get_channel_list (image);
+ all_vectors = gimp_image_get_vectors_list (image);
+
g_object_freeze_notify (G_OBJECT (image));
if (crop_layers)
@@ -145,9 +152,7 @@ gimp_image_crop (GimpImage *image,
NULL);
/* Resize all channels */
- for (list = gimp_image_get_channel_iter (image);
- list;
- list = g_list_next (list))
+ for (list = all_channels; list; list = g_list_next (list))
{
item = (GimpItem *) list->data;
@@ -155,9 +160,7 @@ gimp_image_crop (GimpImage *image,
}
/* Resize all vectors */
- for (list = gimp_image_get_vectors_iter (image);
- list;
- list = g_list_next (list))
+ for (list = all_vectors; list; list = g_list_next (list))
{
item = (GimpItem *) list->data;
@@ -169,14 +172,10 @@ gimp_image_crop (GimpImage *image,
width, height, -x1, -y1);
/* crop all layers */
- list = gimp_image_get_layer_iter (image);
-
- while (list)
+ for (list = all_layers; list; list = g_list_next (list))
{
item = (GimpItem *) list->data;
- list = g_list_next (list);
-
gimp_item_translate (item, -x1, -y1, TRUE);
if (crop_layers)
@@ -281,6 +280,10 @@ gimp_image_crop (GimpImage *image,
previous_height);
g_object_thaw_notify (G_OBJECT (image));
+
+ g_list_free (all_layers);
+ g_list_free (all_channels);
+ g_list_free (all_vectors);
}
gimp_unset_busy (image->gimp);
diff --git a/app/core/gimpimage-duplicate.c b/app/core/gimpimage-duplicate.c
index 392083f..d802e74 100644
--- a/app/core/gimpimage-duplicate.c
+++ b/app/core/gimpimage-duplicate.c
@@ -202,6 +202,7 @@ gimp_image_duplicate_layers (GimpImage *image,
{
GimpLayer *active_layer = NULL;
GimpLayer *floating_selection;
+ GList *all_layers;
GList *list;
gint count;
@@ -209,11 +210,11 @@ gimp_image_duplicate_layers (GimpImage *image,
floating_selection = gimp_image_get_floating_selection (image);
if (floating_selection)
- {
- *floating_sel_drawable = gimp_layer_get_floating_sel_drawable (floating_selection);
- }
+ *floating_sel_drawable = gimp_layer_get_floating_sel_drawable (floating_selection);
+
+ all_layers = gimp_image_get_layer_list (image);
- for (list = gimp_image_get_layer_iter (image), count = 0;
+ for (list = all_layers, count = 0;
list;
list = g_list_next (list))
{
@@ -248,6 +249,8 @@ gimp_image_duplicate_layers (GimpImage *image,
gimp_image_add_layer (new_image, new_layer, count++, FALSE);
}
+ g_list_free (all_layers);
+
return active_layer;
}
@@ -258,10 +261,13 @@ gimp_image_duplicate_channels (GimpImage *image,
GimpDrawable **new_floating_sel_drawable)
{
GimpChannel *active_channel = NULL;
+ GList *all_channels;
GList *list;
gint count;
- for (list = gimp_image_get_channel_iter (image), count = 0;
+ all_channels = gimp_image_get_channel_list (image);
+
+ for (list = all_channels, count = 0;
list;
list = g_list_next (list))
{
@@ -277,7 +283,7 @@ gimp_image_duplicate_channels (GimpImage *image,
gimp_object_get_name (GIMP_OBJECT (channel)));
if (gimp_image_get_active_channel (image) == channel)
- active_channel = (new_channel);
+ active_channel = new_channel;
if (floating_sel_drawable == GIMP_DRAWABLE (channel))
*new_floating_sel_drawable = GIMP_DRAWABLE (new_channel);
@@ -285,6 +291,8 @@ gimp_image_duplicate_channels (GimpImage *image,
gimp_image_add_channel (new_image, new_channel, count++, FALSE);
}
+ g_list_free (all_channels);
+
return active_channel;
}
@@ -293,10 +301,13 @@ gimp_image_duplicate_vectors (GimpImage *image,
GimpImage *new_image)
{
GimpVectors *active_vectors = NULL;
+ GList *all_vectors;
GList *list;
gint count;
- for (list = gimp_image_get_vectors_iter (image), count = 0;
+ all_vectors = gimp_image_get_vectors_list (image);
+
+ for (list = all_vectors, count = 0;
list;
list = g_list_next (list))
{
@@ -317,6 +328,8 @@ gimp_image_duplicate_vectors (GimpImage *image,
gimp_image_add_vectors (new_image, new_vectors, count++, FALSE);
}
+ g_list_free (all_vectors);
+
return active_vectors;
}
@@ -369,7 +382,9 @@ gimp_image_duplicate_guides (GimpImage *image,
{
GList *list;
- for (list = gimp_image_get_guides (image); list; list = g_list_next (list))
+ for (list = gimp_image_get_guides (image);
+ list;
+ list = g_list_next (list))
{
GimpGuide *guide = list->data;
gint position = gimp_guide_get_position (guide);
diff --git a/app/core/gimpimage-flip.c b/app/core/gimpimage-flip.c
index 52b5a28..10a5971 100644
--- a/app/core/gimpimage-flip.c
+++ b/app/core/gimpimage-flip.c
@@ -42,6 +42,9 @@ gimp_image_flip (GimpImage *image,
GimpOrientationType flip_type,
GimpProgress *progress)
{
+ GList *all_layers;
+ GList *all_channels;
+ GList *all_vectors;
GList *list;
gdouble axis;
gdouble progress_max;
@@ -68,17 +71,19 @@ gimp_image_flip (GimpImage *image,
return;
}
- progress_max = (gimp_container_get_n_children (image->channels) +
- gimp_container_get_n_children (image->layers) +
- gimp_container_get_n_children (image->vectors) +
+ all_layers = gimp_image_get_layer_list (image);
+ all_channels = gimp_image_get_channel_list (image);
+ all_vectors = gimp_image_get_vectors_list (image);
+
+ progress_max = (g_list_length (all_layers) +
+ g_list_length (all_channels) +
+ g_list_length (all_vectors) +
1 /* selection */);
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_FLIP, NULL);
/* Flip all channels */
- for (list = gimp_image_get_channel_iter (image);
- list;
- list = g_list_next (list))
+ for (list = all_channels; list; list = g_list_next (list))
{
GimpItem *item = list->data;
@@ -89,9 +94,7 @@ gimp_image_flip (GimpImage *image,
}
/* Flip all vectors */
- for (list = gimp_image_get_vectors_iter (image);
- list;
- list = g_list_next (list))
+ for (list = all_vectors; list; list = g_list_next (list))
{
GimpItem *item = list->data;
@@ -109,9 +112,7 @@ gimp_image_flip (GimpImage *image,
gimp_progress_set_value (progress, progress_current++ / progress_max);
/* Flip all layers */
- for (list = gimp_image_get_layer_iter (image);
- list;
- list = g_list_next (list))
+ for (list = all_layers; list; list = g_list_next (list))
{
GimpItem *item = list->data;
@@ -122,7 +123,9 @@ gimp_image_flip (GimpImage *image,
}
/* Flip all Guides */
- for (list = gimp_image_get_guides (image); list; list = g_list_next (list))
+ for (list = gimp_image_get_guides (image);
+ list;
+ list = g_list_next (list))
{
GimpGuide *guide = list->data;
gint position = gimp_guide_get_position (guide);
@@ -149,7 +152,9 @@ gimp_image_flip (GimpImage *image,
}
/* Flip all sample points */
- for (list = gimp_image_get_sample_points (image); list; list = g_list_next (list))
+ for (list = gimp_image_get_sample_points (image);
+ list;
+ list = g_list_next (list))
{
GimpSamplePoint *sample_point = list->data;
@@ -170,5 +175,9 @@ gimp_image_flip (GimpImage *image,
gimp_image_undo_group_end (image);
+ g_list_free (all_layers);
+ g_list_free (all_channels);
+ g_list_free (all_vectors);
+
gimp_unset_busy (image->gimp);
}
diff --git a/app/core/gimpimage-item-list.c b/app/core/gimpimage-item-list.c
index b59c0fc..b4f0a43 100644
--- a/app/core/gimpimage-item-list.c
+++ b/app/core/gimpimage-item-list.c
@@ -162,6 +162,7 @@ gimp_image_item_list_get_list (const GimpImage *image,
GimpItemTypeMask type,
GimpItemSet set)
{
+ GList *all_items;
GList *list;
GList *return_list = NULL;
@@ -170,41 +171,47 @@ gimp_image_item_list_get_list (const GimpImage *image,
if (type & GIMP_ITEM_TYPE_LAYERS)
{
- for (list = gimp_image_get_layer_iter (image);
- list;
- list = g_list_next (list))
+ all_items = gimp_image_get_layer_list (image);
+
+ for (list = all_items; list; list = g_list_next (list))
{
GimpItem *item = list->data;
if (item != exclude && gimp_item_is_in_set (item, set))
return_list = g_list_prepend (return_list, item);
}
+
+ g_list_free (all_items);
}
if (type & GIMP_ITEM_TYPE_CHANNELS)
{
- for (list = gimp_image_get_channel_iter (image);
- list;
- list = g_list_next (list))
+ all_items = gimp_image_get_channel_list (image);
+
+ for (list = all_items; list; list = g_list_next (list))
{
GimpItem *item = list->data;
if (item != exclude && gimp_item_is_in_set (item, set))
return_list = g_list_prepend (return_list, item);
}
+
+ g_list_free (all_items);
}
if (type & GIMP_ITEM_TYPE_VECTORS)
{
- for (list = gimp_image_get_vectors_iter (image);
- list;
- list = g_list_next (list))
+ all_items = gimp_image_get_vectors_list (image);
+
+ for (list = all_items; list; list = g_list_next (list))
{
GimpItem *item = list->data;
if (item != exclude && gimp_item_is_in_set (item, set))
return_list = g_list_prepend (return_list, item);
}
+
+ g_list_free (all_items);
}
return g_list_reverse (return_list);
diff --git a/app/core/gimpimage-resize.c b/app/core/gimpimage-resize.c
index 3813d08..c4fcc37 100644
--- a/app/core/gimpimage-resize.c
+++ b/app/core/gimpimage-resize.c
@@ -65,6 +65,9 @@ gimp_image_resize_with_layers (GimpImage *image,
GimpItemSet layer_set,
GimpProgress *progress)
{
+ GList *all_layers;
+ GList *all_channels;
+ GList *all_vectors;
GList *list;
GList *resize_layers;
gdouble progress_max;
@@ -78,9 +81,13 @@ gimp_image_resize_with_layers (GimpImage *image,
gimp_set_busy (image->gimp);
- progress_max = (gimp_container_get_n_children (image->channels) +
- gimp_container_get_n_children (image->layers) +
- gimp_container_get_n_children (image->vectors) +
+ all_layers = gimp_image_get_layer_list (image);
+ all_channels = gimp_image_get_channel_list (image);
+ all_vectors = gimp_image_get_vectors_list (image);
+
+ progress_max = (g_list_length (all_layers) +
+ g_list_length (all_channels) +
+ g_list_length (all_vectors) +
1 /* selection */);
g_object_freeze_notify (G_OBJECT (image));
@@ -110,9 +117,7 @@ gimp_image_resize_with_layers (GimpImage *image,
NULL);
/* Resize all channels */
- for (list = gimp_image_get_channel_iter (image);
- list;
- list = g_list_next (list))
+ for (list = all_channels; list; list = g_list_next (list))
{
GimpItem *item = list->data;
@@ -124,9 +129,7 @@ gimp_image_resize_with_layers (GimpImage *image,
}
/* Resize all vectors */
- for (list = gimp_image_get_vectors_iter (image);
- list;
- list = g_list_next (list))
+ for (list = all_vectors; list; list = g_list_next (list))
{
GimpItem *item = list->data;
@@ -145,9 +148,7 @@ gimp_image_resize_with_layers (GimpImage *image,
gimp_progress_set_value (progress, progress_current++ / progress_max);
/* Reposition all layers */
- for (list = gimp_image_get_layer_iter (image);
- list;
- list = g_list_next (list))
+ for (list = all_layers; list; list = g_list_next (list))
{
GimpItem *item = list->data;
gint old_offset_x;
@@ -169,7 +170,9 @@ gimp_image_resize_with_layers (GimpImage *image,
g_list_free (resize_layers);
/* Reposition or remove all guides */
- for (list = gimp_image_get_guides (image); list; list = g_list_next (list))
+ for (list = gimp_image_get_guides (image);
+ list;
+ list = g_list_next (list))
{
GimpGuide *guide = list->data;
gboolean remove_guide = FALSE;
@@ -200,7 +203,9 @@ gimp_image_resize_with_layers (GimpImage *image,
}
/* Reposition or remove sample points */
- for (list = gimp_image_get_sample_points (image); list; list = g_list_next (list))
+ for (list = gimp_image_get_sample_points (image);
+ list;
+ list = g_list_next (list))
{
GimpSamplePoint *sample_point = list->data;
gboolean remove_sample_point = FALSE;
@@ -232,6 +237,10 @@ gimp_image_resize_with_layers (GimpImage *image,
g_object_thaw_notify (G_OBJECT (image));
+ g_list_free (all_layers);
+ g_list_free (all_channels);
+ g_list_free (all_vectors);
+
gimp_unset_busy (image->gimp);
}
@@ -240,25 +249,33 @@ gimp_image_resize_to_layers (GimpImage *image,
GimpContext *context,
GimpProgress *progress)
{
- GList *list = gimp_image_get_layer_iter (image);
+ GList *all_layers;
+ GList *list;
GimpItem *item;
gint min_x, max_x;
gint min_y, max_y;
- if (!list)
+ g_return_if_fail (GIMP_IS_IMAGE (image));
+ g_return_if_fail (GIMP_IS_CONTEXT (context));
+ g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
+
+ all_layers = gimp_image_get_layer_list (image);
+
+ if (! all_layers)
return;
+ list = all_layers;
+
/* figure out starting values */
item = list->data;
+
min_x = gimp_item_get_offset_x (item);
min_y = gimp_item_get_offset_y (item);
max_x = gimp_item_get_offset_x (item) + gimp_item_get_width (item);
max_y = gimp_item_get_offset_y (item) + gimp_item_get_height (item);
/* Respect all layers */
- for (list = g_list_next (list);
- list;
- list = g_list_next (list))
+ for (list = g_list_next (list); list; list = g_list_next (list))
{
item = list->data;
diff --git a/app/core/gimpimage-rotate.c b/app/core/gimpimage-rotate.c
index 43b48cd..a41122d 100644
--- a/app/core/gimpimage-rotate.c
+++ b/app/core/gimpimage-rotate.c
@@ -53,6 +53,9 @@ gimp_image_rotate (GimpImage *image,
GimpRotationType rotate_type,
GimpProgress *progress)
{
+ GList *all_layers;
+ GList *all_channels;
+ GList *all_vectors;
GList *list;
gdouble center_x;
gdouble center_y;
@@ -78,9 +81,13 @@ gimp_image_rotate (GimpImage *image,
center_x = previous_image_width / 2.0;
center_y = previous_image_height / 2.0;
- progress_max = (gimp_container_get_n_children (image->channels) +
- gimp_container_get_n_children (image->layers) +
- gimp_container_get_n_children (image->vectors) +
+ all_layers = gimp_image_get_layer_list (image);
+ all_channels = gimp_image_get_channel_list (image);
+ all_vectors = gimp_image_get_vectors_list (image);
+
+ progress_max = (g_list_length (all_layers) +
+ g_list_length (all_channels) +
+ g_list_length (all_vectors) +
1 /* selection */);
g_object_freeze_notify (G_OBJECT (image));
@@ -113,9 +120,7 @@ gimp_image_rotate (GimpImage *image,
}
/* Rotate all channels */
- for (list = gimp_image_get_channel_iter (image);
- list;
- list = g_list_next (list))
+ for (list = all_channels; list; list = g_list_next (list))
{
GimpItem *item = list->data;
@@ -128,9 +133,7 @@ gimp_image_rotate (GimpImage *image,
}
/* Rotate all vectors */
- for (list = gimp_image_get_vectors_iter (image);
- list;
- list = g_list_next (list))
+ for (list = all_vectors; list; list = g_list_next (list))
{
GimpItem *item = list->data;
@@ -167,9 +170,7 @@ gimp_image_rotate (GimpImage *image,
}
/* Rotate all layers */
- for (list = gimp_image_get_layer_iter (image);
- list;
- list = g_list_next (list))
+ for (list = all_layers; list; list = g_list_next (list))
{
GimpItem *item = list->data;
gint off_x;
@@ -226,6 +227,10 @@ gimp_image_rotate (GimpImage *image,
g_object_thaw_notify (G_OBJECT (image));
+ g_list_free (all_layers);
+ g_list_free (all_channels);
+ g_list_free (all_vectors);
+
gimp_unset_busy (image->gimp);
}
diff --git a/app/core/gimpimage-scale.c b/app/core/gimpimage-scale.c
index 4375ad4..657ce0b 100644
--- a/app/core/gimpimage-scale.c
+++ b/app/core/gimpimage-scale.c
@@ -51,8 +51,10 @@ gimp_image_scale (GimpImage *image,
GimpProgress *progress)
{
GimpProgress *sub_progress;
+ GList *all_layers;
+ GList *all_channels;
+ GList *all_vectors;
GList *list;
- GList *remove = NULL;
gint old_width;
gint old_height;
gint offset_x;
@@ -70,9 +72,13 @@ gimp_image_scale (GimpImage *image,
sub_progress = gimp_sub_progress_new (progress);
- progress_steps = (gimp_container_get_n_children (image->channels) +
- gimp_container_get_n_children (image->layers) +
- gimp_container_get_n_children (image->vectors) +
+ all_layers = gimp_image_get_layer_list (image);
+ all_channels = gimp_image_get_channel_list (image);
+ all_vectors = gimp_image_get_vectors_list (image);
+
+ progress_steps = (g_list_length (all_layers) +
+ g_list_length (all_channels) +
+ g_list_length (all_vectors) +
1 /* selection */);
g_object_freeze_notify (G_OBJECT (image));
@@ -103,9 +109,7 @@ gimp_image_scale (GimpImage *image,
NULL);
/* Scale all channels */
- for (list = gimp_image_get_channel_iter (image);
- list;
- list = g_list_next (list))
+ for (list = all_channels; list; list = g_list_next (list))
{
GimpItem *item = list->data;
@@ -118,9 +122,7 @@ gimp_image_scale (GimpImage *image,
}
/* Scale all vectors */
- for (list = gimp_image_get_vectors_iter (image);
- list;
- list = g_list_next (list))
+ for (list = all_vectors; list; list = g_list_next (list))
{
GimpItem *item = list->data;
@@ -141,9 +143,7 @@ gimp_image_scale (GimpImage *image,
interpolation_type, sub_progress);
/* Scale all layers */
- for (list = gimp_image_get_layer_iter (image);
- list;
- list = g_list_next (list))
+ for (list = all_layers; list; list = g_list_next (list))
{
GimpItem *item = list->data;
@@ -159,24 +159,10 @@ gimp_image_scale (GimpImage *image,
* here. Upstream warning implemented in resize_check_layer_scaling(),
* which offers the user the chance to bail out.
*/
- remove = g_list_prepend (remove, item);
+ gimp_image_remove_layer (image, GIMP_LAYER (item), TRUE, NULL);
}
}
- /* We defer removing layers lost to scaling until now so as not to mix
- * the operations of iterating over and removal from image->layers.
- */
- remove = g_list_reverse (remove);
-
- for (list = remove; list; list = g_list_next (list))
- {
- GimpLayer *layer = list->data;
-
- gimp_image_remove_layer (image, layer, TRUE, NULL);
- }
-
- g_list_free (remove);
-
/* Scale all Guides */
for (list = gimp_image_get_guides (image); list; list = g_list_next (list))
{
@@ -214,6 +200,10 @@ gimp_image_scale (GimpImage *image,
gimp_image_undo_group_end (image);
+ g_list_free (all_layers);
+ g_list_free (all_channels);
+ g_list_free (all_vectors);
+
g_object_unref (sub_progress);
gimp_image_size_changed_detailed (image,
@@ -254,6 +244,7 @@ gimp_image_scale_check (const GimpImage *image,
gint64 *new_memsize)
{
GList *drawables;
+ GList *all_layers;
GList *list;
gint64 current_size;
gint64 scalable_size;
@@ -330,15 +321,21 @@ gimp_image_scale_check (const GimpImage *image,
if (new_size > current_size && new_size > max_memsize)
return GIMP_IMAGE_SCALE_TOO_BIG;
- for (list = gimp_image_get_layer_iter (image);
- list;
- list = g_list_next (list))
+ all_layers = gimp_image_get_layer_list (image);
+
+ for (list = all_layers; list; list = g_list_next (list))
{
GimpItem *item = list->data;
if (! gimp_item_check_scaling (item, new_width, new_height))
- return GIMP_IMAGE_SCALE_TOO_SMALL;
+ {
+ g_list_free (all_layers);
+
+ return GIMP_IMAGE_SCALE_TOO_SMALL;
+ }
}
+ g_list_free (all_layers);
+
return GIMP_IMAGE_SCALE_OK;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]