diff src/protocols/msn/dialog.c @ 13905:4e44ecb866bd

[gaim-migrate @ 16394] msn_session_sync_users() iterates over the buddy list, following the ->next pointers of the groups, contacts, and buddies. msn_show_sync_issue(), if called, removed the buddy for which it was called, in preparation for the buddy either being added to the server list or confirmed-to-be-removed. This could lead to the buddy pointer being released and ->next therefore being junk. The buddy is now not removed until the user responds to the action dialog presented via msn_show_sync_issue(). I'm unclear why gtkgaim got away with this exercise in memory stomping but Adium/libgaim crashed every time, but it's safer in any case. I also changed some foo->bar to gaim_foo_get_bar(). committer: Tailor Script <tailor@pidgin.im>
author Evan Schoenberg <evan.s@dreskin.net>
date Sun, 02 Jul 2006 09:37:25 +0000
parents 90f488e08216
children 6fc412e59214
line wrap: on
line diff
--- a/src/protocols/msn/dialog.c	Sat Jul 01 23:21:12 2006 +0000
+++ b/src/protocols/msn/dialog.c	Sun Jul 02 09:37:25 2006 +0000
@@ -34,9 +34,31 @@
 
 } MsnAddRemData;
 
+/* Remove the buddy referenced by the MsnAddRemData before the serverside list is changed.
+ * If the buddy will be added, he'll be added back; if he will be removed, he won't be. */
+static void
+msn_complete_sync_issue(MsnAddRemData *data)
+{
+	GaimBuddy *buddy;
+	GaimGroup *group = NULL;
+
+	if (data->group != NULL)
+		group = gaim_find_group(data->group);
+	
+	if (group != NULL)
+		buddy = gaim_find_buddy_in_group(gaim_connection_get_account(data->gc), data->who, group);
+	else
+		buddy = gaim_find_buddy(gaim_connection_get_account(data->gc), data->who);
+	
+	if (buddy != NULL)
+		gaim_blist_remove_buddy(buddy);
+}
+
 static void
 msn_add_cb(MsnAddRemData *data)
 {
+	msn_complete_sync_issue(data);
+
 	if (g_list_find(gaim_connections_get_all(), data->gc) != NULL)
 	{
 		MsnSession *session = data->gc->proto_data;
@@ -55,6 +77,8 @@
 static void
 msn_rem_cb(MsnAddRemData *data)
 {
+	msn_complete_sync_issue(data);
+
 	if (g_list_find(gaim_connections_get_all(), data->gc) != NULL)
 	{
 		MsnSession *session = data->gc->proto_data;
@@ -78,8 +102,6 @@
 	GaimAccount *account;
 	MsnAddRemData *data;
 	char *msg, *reason;
-	GaimBuddy *buddy;
-	GaimGroup *group = NULL;
 
 	account = session->account;
 	gc = gaim_account_get_connection(account);
@@ -114,17 +136,6 @@
 						_("Yes"), G_CALLBACK(msn_add_cb),
 						_("No"), G_CALLBACK(msn_rem_cb));
 
-	if (group_name != NULL)
-		group = gaim_find_group(group_name);
-
-	if (group != NULL)
-		buddy = gaim_find_buddy_in_group(account, passport, group);
-	else
-		buddy = gaim_find_buddy(account, passport);
-
-	if (buddy != NULL)
-		gaim_blist_remove_buddy(buddy);
-
 	g_free(reason);
 	g_free(msg);
 }