gimp r24699 - in trunk: . app/core



Author: neo
Date: Thu Jan 24 09:38:44 2008
New Revision: 24699
URL: http://svn.gnome.org/viewvc/gimp?rev=24699&view=rev

Log:
2008-01-24  Sven Neumann  <sven gimp org>

	* app/core/gimpimage.c
	* app/core/gimpimage-undo.c: fixed handling of the image undo
	counter for the case where the user has undone the image to a
	state before the last save and then pushes a new undo. Fixes
	bug #509822.



Modified:
   trunk/ChangeLog
   trunk/app/core/gimpimage-undo.c
   trunk/app/core/gimpimage.c

Modified: trunk/app/core/gimpimage-undo.c
==============================================================================
--- trunk/app/core/gimpimage-undo.c	(original)
+++ trunk/app/core/gimpimage-undo.c	Thu Jan 24 09:38:44 2008
@@ -150,11 +150,10 @@
   /* If the image was dirty, but could become clean by redo-ing
    * some actions, then it should now become 'infinitely' dirty.
    * This is because we've just nuked the actions that would allow
-   * the image to become clean again.  The only hope for salvation
-   * is to save the image now!  -- austin
+   * the image to become clean again.
    */
   if (image->dirty < 0)
-    image->dirty = 10000;
+    image->dirty = 100000;
 
   /* The same applies to the case where the image would become clean
    * due to undo actions, but since user can't undo without an undo
@@ -195,15 +194,6 @@
   /*  nuke the redo stack  */
   gimp_image_undo_free_redo (image);
 
-  /* If the image was dirty, but could become clean by redo-ing
-   * some actions, then it should now become 'infinitely' dirty.
-   * This is because we've just nuked the actions that would allow
-   * the image to become clean again.  The only hope for salvation
-   * is to save the image now!  -- austin
-   */
-  if (image->dirty < 0)
-    image->dirty = 10000;
-
   undo_group = gimp_undo_stack_new (image);
 
   gimp_object_set_name (GIMP_OBJECT (undo_group), name);
@@ -246,11 +236,11 @@
 }
 
 GimpUndo *
-gimp_image_undo_push (GimpImage        *image,
-                      GType             object_type,
-                      GimpUndoType      undo_type,
-                      const gchar      *name,
-                      GimpDirtyMask     dirty_mask,
+gimp_image_undo_push (GimpImage     *image,
+                      GType          object_type,
+                      GimpUndoType   undo_type,
+                      const gchar   *name,
+                      GimpDirtyMask  dirty_mask,
                       ...)
 {
   GParameter *params   = NULL;
@@ -292,15 +282,6 @@
   /*  nuke the redo stack  */
   gimp_image_undo_free_redo (image);
 
-  /* If the image was dirty, but could become clean by redo-ing
-   * some actions, then it should now become 'infinitely' dirty.
-   * This is because we've just nuked the actions that would allow
-   * the image to become clean again.  The only hope for salvation
-   * is to save the image now!  -- austin
-   */
-  if (image->dirty < 0)
-    image->dirty = 10000;
-
   if (image->pushing_undo_group == GIMP_UNDO_GROUP_NONE)
     {
       gimp_undo_stack_push_undo (image->undo_stack, undo);
@@ -473,9 +454,7 @@
 static void
 gimp_image_undo_free_redo (GimpImage *image)
 {
-  GimpContainer *container;
-
-  container = image->redo_stack->undos;
+  GimpContainer *container = image->redo_stack->undos;
 
 #ifdef DEBUG_IMAGE_UNDO
   g_printerr ("redo_steps: %d    redo_bytes: %ld\n",
@@ -483,6 +462,9 @@
               (glong) gimp_object_get_memsize (GIMP_OBJECT (container), NULL));
 #endif
 
+  if (gimp_container_is_empty (container))
+    return;
+
   while (gimp_container_num_children (container) > 0)
     {
       GimpUndo *freed = gimp_undo_stack_free_bottom (image->redo_stack,
@@ -499,6 +481,19 @@
 
       g_object_unref (freed);
     }
+
+  /* We need to use <= here because the undo counter has already been
+   * incremented at this point.
+   */
+  if (image->dirty <= 0)
+    {
+      /* If the image was dirty, but could become clean by redo-ing
+       * some actions, then it should now become 'infinitely' dirty.
+       * This is because we've just nuked the actions that would allow
+       * the image to become clean again.
+       */
+      image->dirty = 100000;
+    }
 }
 
 static GimpDirtyMask

Modified: trunk/app/core/gimpimage.c
==============================================================================
--- trunk/app/core/gimpimage.c	(original)
+++ trunk/app/core/gimpimage.c	Thu Jan 24 09:38:44 2008
@@ -1912,11 +1912,11 @@
  *
  *   The image is dirty (ie, needs saving) if counter is non-zero.
  *
- *   If the counter is around 10000, this is due to undo-ing back
- *   before a saved version, then mutating the image (thus destroying
+ *   If the counter is around 100000, this is due to undo-ing back
+ *   before a saved version, then changing the image (thus destroying
  *   the redo stack).  Once this has happened, it's impossible to get
  *   the image back to the state on disk, since the redo info has been
- *   freed.  See undo.c for the gorey details.
+ *   freed.  See gimpimage-undo.c for the gory details.
  */
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]