From 0143512e007c9ab72cafcdf29b5f29a0c7c471bc Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 22 Sep 2009 18:00:37 -0400 Subject: [PATCH] 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 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/shell-texture-cache.c b/src/shell-texture-cache.c index 946021b9e..8ad8c1443 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);