changeset 32489:60d879806964

Be a bit more specific about removing non-local MSN objects, which HanzZ thinks should fix a leak somewhere.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 02 Sep 2011 19:50:58 +0000
parents c200251415d3
children 67addaf8677f
files libpurple/protocols/msn/msg.c libpurple/protocols/msn/msn.c libpurple/protocols/msn/object.c libpurple/protocols/msn/object.h libpurple/protocols/msn/slpcall.c libpurple/protocols/msn/user.c
diffstat 6 files changed, 18 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/msg.c	Fri Sep 02 18:05:24 2011 +0000
+++ b/libpurple/protocols/msn/msg.c	Fri Sep 02 19:50:58 2011 +0000
@@ -970,7 +970,7 @@
 			msn_slplink_request_object(slplink, smile, got_emoticon, NULL, obj);
 		}
 
-		msn_object_destroy(obj);
+		msn_object_destroy(obj, FALSE);
 		obj =   NULL;
 		who =   NULL;
 		sha1 = NULL;
@@ -1025,7 +1025,7 @@
 		slplink = msn_session_get_slplink(session, who);
 		msn_slplink_request_object(slplink, data, got_wink_cb, NULL, obj);
 
-		msn_object_destroy(obj);
+		msn_object_destroy(obj, FALSE);
 
 
 	} else if (!strcmp(id, "3")) {
@@ -1045,7 +1045,7 @@
 		slplink = msn_session_get_slplink(session, who);
 		msn_slplink_request_object(slplink, data, got_voiceclip_cb, NULL, obj);
 
-		msn_object_destroy(obj);
+		msn_object_destroy(obj, FALSE);
 
 	} else if (!strcmp(id, "4")) {
 		/* Action */
--- a/libpurple/protocols/msn/msn.c	Fri Sep 02 18:05:24 2011 +0000
+++ b/libpurple/protocols/msn/msn.c	Fri Sep 02 19:50:58 2011 +0000
@@ -1453,7 +1453,7 @@
 static void msn_emoticon_destroy(MsnEmoticon *emoticon)
 {
 	if (emoticon->obj)
-		msn_object_destroy(emoticon->obj);
+		msn_object_destroy(emoticon->obj, FALSE);
 	g_free(emoticon->smile);
 	g_free(emoticon);
 }
--- a/libpurple/protocols/msn/object.c	Fri Sep 02 18:05:24 2011 +0000
+++ b/libpurple/protocols/msn/object.c	Fri Sep 02 19:50:58 2011 +0000
@@ -103,7 +103,7 @@
 	if (obj->creator == NULL || obj->size == 0 || obj->type == 0
 	 || obj->sha1d == NULL) {
 		purple_debug_error("msn", "Discarding invalid msnobj: '%s'\n", str);
-		msn_object_destroy(obj);
+		msn_object_destroy(obj, FALSE);
 		return NULL;
 	}
 
@@ -111,12 +111,12 @@
 		/* Location/friendly are required for non-buddyicon objects */
 		if (obj->type != MSN_OBJECT_USERTILE) {
 			purple_debug_error("msn", "Discarding invalid msnobj: '%s'\n", str);
-			msn_object_destroy(obj);
+			msn_object_destroy(obj, FALSE);
 			return NULL;
 		/* Buddy icon object can contain Url/Url1 instead */
 		} else if (obj->url == NULL || obj->url1 == NULL) {
 			purple_debug_error("msn", "Discarding invalid msnobj: '%s'\n", str);
-			msn_object_destroy(obj);
+			msn_object_destroy(obj, FALSE);
 			return NULL;
 		}
 	}
@@ -193,10 +193,13 @@
 }
 
 void
-msn_object_destroy(MsnObject *obj)
+msn_object_destroy(MsnObject *obj, gboolean only_remote)
 {
 	g_return_if_fail(obj != NULL);
 
+	if (only_remote && obj->local)
+		return;
+
 	g_free(obj->creator);
 	g_free(obj->location);
 	g_free(obj->friendly);
--- a/libpurple/protocols/msn/object.h	Fri Sep 02 18:05:24 2011 +0000
+++ b/libpurple/protocols/msn/object.h	Fri Sep 02 19:50:58 2011 +0000
@@ -86,9 +86,10 @@
 /**
  * Destroys an MsnObject structure.
  *
- * @param obj The object structure.
+ * @param obj         The object structure.
+ * @param only_remote Only destroy non-local objects.
  */
-void msn_object_destroy(MsnObject *obj);
+void msn_object_destroy(MsnObject *obj, gboolean only_remote);
 
 /**
  * Outputs a string representation of an MsnObject.
--- a/libpurple/protocols/msn/slpcall.c	Fri Sep 02 18:05:24 2011 +0000
+++ b/libpurple/protocols/msn/slpcall.c	Fri Sep 02 19:50:58 2011 +0000
@@ -485,7 +485,7 @@
 			if (img)
 				purple_imgstore_ref(img);
 		}
-		msn_object_destroy(obj);
+		msn_object_destroy(obj, FALSE);
 
 		if (img != NULL) {
 			/* DATA PREP */
--- a/libpurple/protocols/msn/user.c	Fri Sep 02 18:05:24 2011 +0000
+++ b/libpurple/protocols/msn/user.c	Fri Sep 02 19:50:58 2011 +0000
@@ -76,7 +76,7 @@
 	}
 
 	if (user->msnobj != NULL)
-		msn_object_destroy(user->msnobj);
+		msn_object_destroy(user->msnobj, FALSE);
 
 	g_free(user->passport);
 	g_free(user->friendly_name);
@@ -588,8 +588,8 @@
 {
 	g_return_if_fail(user != NULL);
 
-	if (user->msnobj != NULL && !msn_object_find_local(msn_object_get_sha1(obj)))
-		msn_object_destroy(user->msnobj);
+	if (user->msnobj != NULL)
+		msn_object_destroy(user->msnobj, TRUE);
 
 	user->msnobj = obj;