changeset 26648:660660e0e8c6

2009.04.23 - flos <lonicerae(at)gmail.com> * Fixed a bug of updating buddy who is not in user's buddy list
author SHiNE CsyFeK <csyfek@gmail.com>
date Thu, 23 Apr 2009 15:20:23 +0000
parents 33f4330401d5
children 96f82c75f1c0
files libpurple/protocols/qq/ChangeLog libpurple/protocols/qq/buddy_info.c
diffstat 2 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/qq/ChangeLog	Wed Apr 22 18:39:41 2009 +0000
+++ b/libpurple/protocols/qq/ChangeLog	Thu Apr 23 15:20:23 2009 +0000
@@ -1,3 +1,6 @@
+2009.04.23 - flos <lonicerae(at)gmail.com>
+	* Fixed a bug of updating buddy who is not in user's buddy list
+
 2009.02.25 - flos <lonicerae(at)gmail.com>
 	* Changed text 'ZipCode' to 'Postal Code'
 
--- a/libpurple/protocols/qq/buddy_info.c	Wed Apr 22 18:39:41 2009 +0000
+++ b/libpurple/protocols/qq/buddy_info.c	Thu Apr 23 15:20:23 2009 +0000
@@ -606,21 +606,21 @@
 /* after getting info or modify myself, refresh the buddy list accordingly */
 static void update_buddy_info(PurpleConnection *gc, gchar **segments)
 {
-	PurpleBuddy *buddy;
-	qq_data *qd;
-	qq_buddy_data *bd;
+	PurpleBuddy *buddy = NULL;
+	qq_data *qd = NULL;
+	qq_buddy_data *bd = NULL;
 	guint32 uid;
 	gchar *who;
 	gchar *alias_utf8;
+
 	PurpleAccount *account = purple_connection_get_account(gc);
-
 	qd = (qq_data *)purple_connection_get_protocol_data(gc);
 
 	uid = strtoul(segments[QQ_INFO_UID], NULL, 10);
 	who = uid_to_purple_name(uid);
-
 	qq_filter_str(segments[QQ_INFO_NICK]);
 	alias_utf8 = qq_to_utf8(segments[QQ_INFO_NICK], QQ_CHARSET_DEFAULT);
+
 	if (uid == qd->uid) {	/* it is me */
 		purple_debug_info("QQ", "Got my info\n");
 		qd->my_icon = strtol(segments[QQ_INFO_FACE], NULL, 10);
@@ -631,12 +631,14 @@
 		buddy = qq_buddy_find_or_new(gc, uid);
 	} else {
 		buddy = purple_find_buddy(gc->account, who);
+		/* purple_debug_info("QQ", "buddy=%p\n", (void*)buddy); */
 	}
 
 	/* if the buddy is null, the api will catch it and return null here */
 	bd = purple_buddy_get_protocol_data(buddy);
+	/* purple_debug_info("QQ", "bd=%p\n", (void*)bd); */
 
-	if (buddy == NULL || bd) {
+	if (bd == NULL || buddy == NULL) {
 		g_free(who);
 		g_free(alias_utf8);
 		return;
@@ -646,6 +648,7 @@
 	bd->age = strtol(segments[QQ_INFO_AGE], NULL, 10);
 	bd->gender = strtol(segments[QQ_INFO_GENDER], NULL, 10);
 	bd->face = strtol(segments[QQ_INFO_FACE], NULL, 10);
+
 	if (alias_utf8 != NULL) {
 		if (bd->nickname) g_free(bd->nickname);
 		bd->nickname = g_strdup(alias_utf8);