Commit 372094ae authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

fixed to check the *new* guide position to be within bounds, not the old

2003-03-30  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpimage-resize.c (gimp_image_resize): fixed to check
	the *new* guide position to be within bounds, not the old
	one. Cleanup.

	* app/core/gimpimage-undo-push.c (undo_pop_image_guide): undo
	guide removal and moves manually instead of calling
	gimp_image_[add|move]_guide() because the latter may run into
	g_return_if_fail(position <= gimage->width/height) if the undo
	step is part of a resize or crop undo group.
parent 5eccc360
2003-03-30 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-resize.c (gimp_image_resize): fixed to check
the *new* guide position to be within bounds, not the old
one. Cleanup.
* app/core/gimpimage-undo-push.c (undo_pop_image_guide): undo
guide removal and moves manually instead of calling
gimp_image_[add|move]_guide() because the latter may run into
g_return_if_fail(position <= gimage->width/height) if the undo
step is part of a resize or crop undo group.
2003-03-30 Michael Natterer <mitch@gimp.org>
 
* app/display/gimpdisplayshell-callbacks.c
......@@ -45,11 +45,8 @@ gimp_image_resize (GimpImage *gimage,
gint offset_x,
gint offset_y)
{
GimpChannel *channel;
GimpLayer *layer;
GimpLayer *floating_layer;
GList *list;
GList *guide_list;
GimpLayer *floating_layer;
GList *list;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (new_width > 0 && new_height > 0);
......@@ -78,44 +75,43 @@ gimp_image_resize (GimpImage *gimage,
list;
list = g_list_next (list))
{
channel = (GimpChannel *) list->data;
GimpChannel *channel = list->data;
gimp_channel_resize (channel, new_width, new_height, offset_x, offset_y);
}
/* Reposition or remove any guides */
guide_list = gimage->guides;
while (guide_list)
list = gimage->guides;
while (list)
{
GimpGuide *guide;
GimpGuide *guide = list->data;
gboolean remove_guide = FALSE;
gint new_position;
guide = (GimpGuide *) guide_list->data;
guide_list = g_list_next (guide_list);
list = g_list_next (list);
switch (guide->orientation)
{
case GIMP_ORIENTATION_HORIZONTAL:
new_position = guide->position + offset_y;
if (guide->position < 0 || guide->position > new_height)
gimp_image_remove_guide (gimage, guide, TRUE);
else
gimp_image_move_guide (gimage, guide, new_position, TRUE);
if (new_position < 0 || new_position > new_height)
remove_guide = TRUE;
break;
case GIMP_ORIENTATION_VERTICAL:
new_position = guide->position + offset_x;
if (guide->position < 0 || guide->position > new_width)
gimp_image_remove_guide (gimage, guide, TRUE);
else
gimp_image_move_guide (gimage, guide, new_position, TRUE);
if (new_position < 0 || new_position > new_width)
remove_guide = TRUE;
break;
default:
g_error ("Unknown guide orientation\n");
}
if (remove_guide)
gimp_image_remove_guide (gimage, guide, TRUE);
else
gimp_image_move_guide (gimage, guide, new_position, TRUE);
}
/* Don't forget the selection mask! */
......@@ -128,7 +124,7 @@ gimp_image_resize (GimpImage *gimage,
list;
list = g_list_next (list))
{
layer = (GimpLayer *) list->data;
GimpLayer *layer = list->data;
gimp_layer_translate (layer, offset_x, offset_y, TRUE);
}
......
......@@ -683,11 +683,22 @@ undo_pop_image_guide (GimpUndo *undo,
old_position = gu->guide->position;
if (gu->guide->position == -1)
gimp_image_add_guide (undo->gimage, gu->guide, gu->position);
{
undo->gimage->guides = g_list_prepend (undo->gimage->guides, gu->guide);
gu->guide->position = gu->position;
gimp_image_guide_ref (gu->guide);
gimp_image_update_guide (undo->gimage, gu->guide);
}
else if (gu->position == -1)
gimp_image_remove_guide (undo->gimage, gu->guide, FALSE);
{
gimp_image_remove_guide (undo->gimage, gu->guide, FALSE);
}
else
gimp_image_move_guide (undo->gimage, gu->guide, gu->position, FALSE);
{
gimp_image_update_guide (undo->gimage, gu->guide);
gu->guide->position = gu->position;
gimp_image_update_guide (undo->gimage, gu->guide);
}
gu->position = old_position;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment