app: fix handling of guides and sample points in gimpimage-resize.c

Don't iterate the lists with for() because the loops can remove items,
which makes us say g_list_next() on a removed list item. Instead, use
while() and get the next item before possibly removing the current
one.
This commit is contained in:
Michael Natterer 2014-07-10 00:08:14 +02:00
parent e9e33421e2
commit 99ccf7223b
1 changed files with 10 additions and 6 deletions

View File

@ -188,14 +188,16 @@ 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))
list = gimp_image_get_guides (image);
while (list)
{
GimpGuide *guide = list->data;
gboolean remove_guide = FALSE;
gint new_position = gimp_guide_get_position (guide);
list = g_list_next (list);
switch (gimp_guide_get_orientation (guide))
{
case GIMP_ORIENTATION_HORIZONTAL:
@ -221,15 +223,17 @@ 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))
list = gimp_image_get_sample_points (image);
while (list)
{
GimpSamplePoint *sample_point = list->data;
gboolean remove_sample_point = FALSE;
gint new_x = sample_point->x;
gint new_y = sample_point->y;
list = g_list_next (list);
new_y += offset_y;
if ((sample_point->y < 0) || (sample_point->y > new_height))
remove_sample_point = TRUE;