[Xfce4-commits] <ristretto:ristretto-0.0> Fix memory leak in image class (unref animation-iter)

Stephan Arts noreply at xfce.org
Sun Oct 23 19:13:30 CEST 2011


Updating branch refs/heads/ristretto-0.0
         to 99f0917fc1d220dd6a2ef61a5f5f53fe2e839065 (commit)
       from 96ee95c3848f91e9693d4519e1c7d52f35ab4340 (commit)

commit 99f0917fc1d220dd6a2ef61a5f5f53fe2e839065
Author: Stephan Arts <stephan at thor.(none)>
Date:   Fri May 15 18:00:45 2009 +0200

    Fix memory leak in image class (unref animation-iter)

 ChangeLog   |    8 ++++++++
 src/image.c |   47 +++++++++++++++++++++++++++++++----------------
 2 files changed, 39 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 40e656d..10efd6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-05-15  Stephan Arts <stephan at xfce.org>
+
+	* src/image.c
+	  src/image.h
+	  src/picture_viewer.c: Implement state-machine, do not expose weird
+	  signals
+	* src/image.c: Unref animation_iter, fix memleak
+
 2009-05-02  Stephan Arts <stephan at xfce.org>
 
 	* src/image_cache.c: Remove images which return size=0 from the cache,
diff --git a/src/image.c b/src/image.c
index bf7c1d1..38333eb 100644
--- a/src/image.c
+++ b/src/image.c
@@ -344,7 +344,6 @@ cb_rstto_image_read_input_stream_ready (GObject *source_object, GAsyncResult *re
         if(gdk_pixbuf_loader_write (image->priv->loader, (const guchar *)image->priv->buffer, read_bytes, &error) == FALSE)
         {
             g_input_stream_close (G_INPUT_STREAM (source_object), NULL, NULL);
-            image->priv->loader = NULL;
             g_object_unref (image);
         }
         else
@@ -365,7 +364,6 @@ cb_rstto_image_read_input_stream_ready (GObject *source_object, GAsyncResult *re
             /* OK */
             g_input_stream_close (G_INPUT_STREAM (source_object), NULL, NULL);
             gdk_pixbuf_loader_close (image->priv->loader, NULL);
-            image->priv->loader = NULL;
             g_object_unref (image);
         }
         else
@@ -373,7 +371,6 @@ cb_rstto_image_read_input_stream_ready (GObject *source_object, GAsyncResult *re
             /* I/O ERROR */
             g_input_stream_close (G_INPUT_STREAM (source_object), NULL, NULL);
             gdk_pixbuf_loader_close (image->priv->loader, NULL);
-            image->priv->loader = NULL;
             g_object_unref (image);
         }
     }
@@ -462,6 +459,37 @@ rstto_image_unload (RsttoImage *image)
         image->priv->pixbuf = NULL;
     }
 
+    if (image->priv->thumbnail)
+    {
+        g_object_unref (image->priv->thumbnail);
+        image->priv->thumbnail = NULL;
+    }
+
+    if (image->priv->animation_timeout_id)
+    {
+        g_source_remove (image->priv->animation_timeout_id);
+        image->priv->animation_timeout_id = 0;
+    }
+
+    if (image->priv->animation)
+    {
+        g_object_unref (image->priv->animation);
+        image->priv->animation = NULL;
+    }
+
+    if (image->priv->iter)
+    {
+        g_object_unref (image->priv->iter);
+        image->priv->iter = NULL;
+    }
+
+    if (image->priv->transformations)
+    {
+        g_list_foreach (image->priv->transformations, (GFunc)g_object_unref, NULL);
+        g_list_free (image->priv->transformations);
+        image->priv->transformations = NULL;
+    }
+
     rstto_image_set_state (image, RSTTO_IMAGE_STATE_DEFAULT);
 }
 
@@ -711,22 +739,9 @@ cb_rstto_image_area_prepared (GdkPixbufLoader *loader, RsttoImage *image)
     }   
     else
     {
-        image->priv->iter = NULL;
-    }
-
-    if (image->priv->iter)
-    {
         image->priv->pixbuf = gdk_pixbuf_animation_iter_get_pixbuf (image->priv->iter);
         g_object_ref (image->priv->pixbuf);
     }
-    else
-    {
-        if (image->priv->loader)
-        {
-            image->priv->pixbuf = gdk_pixbuf_loader_get_pixbuf (image->priv->loader);
-            g_object_ref (image->priv->pixbuf);
-        }
-    }
 }
 
 /**


More information about the Xfce4-commits mailing list