diff --git a/ChangeLog b/ChangeLog index 8fcc64644b..38817bc91d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2004-07-07 Michael Natterer + + Made the undo system robust against the currently pushed undo + being too large according to prefs settings. Fixes bug #145379. + + * app/core/gimpimage-undo.[ch] (gimp_image_undo_push_undo) + (gimp_image_undo_group_end): emit "undo-event" *before* calling + gimp_image_undo_free_space() so the undo history doesn't try to + remove an item that has never been added. + + (gimp_image_undo_push_undo): added boolean return value indicating + if the undo could be pushed (FALSE means the undo was to large + and was discarded right away). + + (gimp_image_undo_push_item): return NULL if the above returned + FALSE. + + * app/core/gimpimage-undo-push.c (gimp_image_undo_push_text_layer): + changed accordingly. + 2004-07-07 Manish Singh * plug-ins/common/jpeg.c: Don't try to load EXIF data if any warnings diff --git a/app/core/gimpimage-undo-push.c b/app/core/gimpimage-undo-push.c index 97e786b66f..9385e39680 100644 --- a/app/core/gimpimage-undo-push.c +++ b/app/core/gimpimage-undo-push.c @@ -1762,9 +1762,7 @@ gimp_image_undo_push_text_layer (GimpImage *gimage, undo = gimp_text_undo_new (layer, pspec, undo_desc); - gimp_image_undo_push_undo (gimage, undo); - - return TRUE; + return gimp_image_undo_push_undo (gimage, undo); } diff --git a/app/core/gimpimage-undo.c b/app/core/gimpimage-undo.c index dfdf929325..3643952c6f 100644 --- a/app/core/gimpimage-undo.c +++ b/app/core/gimpimage-undo.c @@ -170,13 +170,13 @@ gimp_image_undo_group_end (GimpImage *gimage) { gimage->pushing_undo_group = GIMP_UNDO_GROUP_NONE; - gimp_image_undo_free_space (gimage); - /* Do it here, since undo_push doesn't emit this event while in * the middle of a group */ gimp_image_undo_event (gimage, GIMP_UNDO_EVENT_UNDO_PUSHED, gimp_undo_stack_peek (gimage->undo_stack)); + + gimp_image_undo_free_space (gimage); } return TRUE; @@ -245,19 +245,20 @@ gimp_image_undo_push_item (GimpImage *gimage, pop_func, free_func); } - gimp_image_undo_push_undo (gimage, undo); + if (gimp_image_undo_push_undo (gimage, undo)) + return undo; - return undo; + return NULL; } -void +gboolean gimp_image_undo_push_undo (GimpImage *gimage, GimpUndo *undo) { - g_return_if_fail (GIMP_IS_IMAGE (gimage)); - g_return_if_fail (GIMP_IS_UNDO (undo)); - g_return_if_fail (undo->gimage == gimage); - g_return_if_fail (gimage->undo_freeze_count == 0); + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_UNDO (undo), FALSE); + g_return_val_if_fail (undo->gimage == gimage, FALSE); + g_return_val_if_fail (gimage->undo_freeze_count == 0, FALSE); /* nuke the redo stack */ gimp_image_undo_free_redo (gimage); @@ -275,9 +276,13 @@ gimp_image_undo_push_undo (GimpImage *gimage, { gimp_undo_stack_push_undo (gimage->undo_stack, undo); + gimp_image_undo_event (gimage, GIMP_UNDO_EVENT_UNDO_PUSHED, undo); + gimp_image_undo_free_space (gimage); - gimp_image_undo_event (gimage, GIMP_UNDO_EVENT_UNDO_PUSHED, undo); + /* freeing undo space may have freed the newly pushed undo */ + if (gimp_undo_stack_peek (gimage->undo_stack) == undo) + return TRUE; } else { @@ -286,7 +291,11 @@ gimp_image_undo_push_undo (GimpImage *gimage, undo_group = GIMP_UNDO_STACK (gimp_undo_stack_peek (gimage->undo_stack)); gimp_undo_stack_push_undo (undo_group, undo); + + return TRUE; } + + return FALSE; } diff --git a/app/core/gimpimage-undo.h b/app/core/gimpimage-undo.h index fd9a039c02..70710813da 100644 --- a/app/core/gimpimage-undo.h +++ b/app/core/gimpimage-undo.h @@ -47,7 +47,7 @@ GimpUndo * gimp_image_undo_push_item (GimpImage *gimage, gboolean dirties_image, GimpUndoPopFunc pop_func, GimpUndoFreeFunc free_func); -void gimp_image_undo_push_undo (GimpImage *gimage, +gboolean gimp_image_undo_push_undo (GimpImage *gimage, GimpUndo *undo);