/pidgin/main: 1a2cf8aef4a8: Image store: implement missing clean...

Tomasz Wasilczyk twasilczyk at pidgin.im
Wed Apr 9 18:43:31 EDT 2014


Changeset: 1a2cf8aef4a856cb738959f98dfe4235179181e9
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-10 00:43 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/1a2cf8aef4a8

Description:

Image store: implement missing cleanup function

diffstat:

 libpurple/image-store.c |  15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diffs (40 lines):

diff --git a/libpurple/image-store.c b/libpurple/image-store.c
--- a/libpurple/image-store.c
+++ b/libpurple/image-store.c
@@ -26,7 +26,7 @@
 
 #define TEMP_IMAGE_TIMEOUT 5
 
-static GHashTable *id_to_image;
+static GHashTable *id_to_image = NULL;
 static guint last_id = 0;
 
 /* keys: timeout handle */
@@ -35,6 +35,14 @@ static GHashTable *temp_images = NULL;
 /* keys: img id */
 static GSList *perm_images = NULL;
 
+static void
+image_reset_id(gpointer _id)
+{
+	g_return_if_fail(id_to_image != NULL);
+
+	g_hash_table_remove(id_to_image, _id);
+}
+
 static guint
 image_set_id(PurpleImage *image)
 {
@@ -52,10 +60,9 @@ image_set_id(PurpleImage *image)
 			break;
 	}
 
-	g_object_set_data(G_OBJECT(image), "purple-image-store-id",
-		GINT_TO_POINTER(last_id));
+	g_object_set_data_full(G_OBJECT(image), "purple-image-store-id",
+		GINT_TO_POINTER(last_id), image_reset_id);
 	g_hash_table_insert(id_to_image, GINT_TO_POINTER(last_id), image);
-	/* TODO: hook map removal after object destruction */
 	return last_id;
 }
 



More information about the Commits mailing list