[gnome-shell] Don't leak when loading an already-cached item



commit 0143512e007c9ab72cafcdf29b5f29a0c7c471bc
Author: Colin Walters <walters verbum org>
Date:   Tue Sep 22 18:00:37 2009 -0400

    Don't leak when loading an already-cached item
    
    A previous patch fixed a leak when loading items which shouldn't
    be cached, but we also had a leak if two requests for the same
    item were outstanding.  In that case we load the pixbuf twice,
    but should discard subsequent loads when we notice we've already
    cached it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=595321

 src/shell-texture-cache.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/src/shell-texture-cache.c b/src/shell-texture-cache.c
index 946021b..8ad8c14 100644
--- a/src/shell-texture-cache.c
+++ b/src/shell-texture-cache.c
@@ -710,7 +710,7 @@ on_pixbuf_loaded (GObject      *source,
   AsyncTextureLoadData *data;
   GdkPixbuf *pixbuf;
   GError *error = NULL;
-  CoglHandle texdata;
+  CoglHandle texdata = NULL;
   CacheKey *key;
 
   data = user_data;
@@ -743,20 +743,20 @@ on_pixbuf_loaded (GObject      *source,
 
       if (!g_hash_table_lookup_extended (cache->priv->keyed_cache, key,
                                          &orig_key, &value))
-        g_hash_table_insert (cache->priv->keyed_cache, key,
-                             texdata);
+        {
+          cogl_handle_ref (texdata);
+          g_hash_table_insert (cache->priv->keyed_cache, key,
+                               texdata);
+        }
       else
         cache_key_destroy (key);
-
-      set_texture_cogl_texture (data->texture, texdata);
-    }
-  else
-    {
-      set_texture_cogl_texture (data->texture, texdata);
-      cogl_handle_unref (texdata);
     }
 
+    set_texture_cogl_texture (data->texture, texdata);
+
 out:
+  if (texdata)
+    cogl_handle_unref (texdata);
   if (data->icon)
     {
       gtk_icon_info_free (data->icon_info);



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