changeset 30401:8e060965d69f

pidgin: Fix a crash when accessing the Set Moods tool menu when having disconnected mood-capable accounts. Fixes #11946
author Marcus Lundblad <ml@update.uu.se>
date Wed, 19 May 2010 18:47:58 +0000
parents 7396d2fe66dd
children 03e930ec90d0
files ChangeLog pidgin/gtkblist.c
diffstat 2 files changed, 27 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed May 19 16:00:39 2010 +0000
+++ b/ChangeLog	Wed May 19 18:47:58 2010 +0000
@@ -6,6 +6,7 @@
 
 	Pidgin:
 	* Restore the tray icon's blinking functionality.
+	* Fix a crash setting moods when an account is disconnected.
 
 	Bonjour:
 	* Fix a crash on disconnect.
--- a/pidgin/gtkblist.c	Wed May 19 16:00:39 2010 +0000
+++ b/pidgin/gtkblist.c	Wed May 19 18:47:58 2010 +0000
@@ -3487,29 +3487,31 @@
 	
 	for (; accounts ; accounts = g_list_delete_link(accounts, accounts)) {
 		PurpleAccount *account = (PurpleAccount *) accounts->data;
-		PurpleConnection *gc = purple_account_get_connection(account);
-
-		if (gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS) {
-			PurplePluginProtocolInfo *prpl_info =
-				PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
-			PurpleMood *mood = NULL;
-
-			/* PURPLE_CONNECTION_SUPPORT_MOODS would not be set if the prpl doesn't
-			 * have get_moods, so using PURPLE_PROTOCOL_PLUGIN_HAS_FUNC isn't necessary
-			 * here */
-			for (mood = prpl_info->get_moods(account) ;
-			    mood->mood != NULL ; mood++) {
-				int mood_count =
-						GPOINTER_TO_INT(g_hash_table_lookup(mood_counts, mood->mood));
-
-				if (!g_hash_table_lookup(global_moods, mood->mood)) {
-					g_hash_table_insert(global_moods, (gpointer)mood->mood, mood);
+		if (purple_account_is_connected(account)) {
+			PurpleConnection *gc = purple_account_get_connection(account);
+
+			if (gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS) {
+				PurplePluginProtocolInfo *prpl_info =
+					PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
+				PurpleMood *mood = NULL;
+
+				/* PURPLE_CONNECTION_SUPPORT_MOODS would not be set if the prpl doesn't
+				 * have get_moods, so using PURPLE_PROTOCOL_PLUGIN_HAS_FUNC isn't necessary
+				 * here */
+				for (mood = prpl_info->get_moods(account) ;
+				    mood->mood != NULL ; mood++) {
+					int mood_count =
+							GPOINTER_TO_INT(g_hash_table_lookup(mood_counts, mood->mood));
+
+					if (!g_hash_table_lookup(global_moods, mood->mood)) {
+						g_hash_table_insert(global_moods, (gpointer)mood->mood, mood);
+					}
+					g_hash_table_insert(mood_counts, (gpointer)mood->mood,
+					    GINT_TO_POINTER(mood_count + 1));
 				}
-				g_hash_table_insert(mood_counts, (gpointer)mood->mood,
-				    GINT_TO_POINTER(mood_count + 1));
+
+				num_accounts++;
 			}
-
-			num_accounts++;
 		}
 	}
 
@@ -3547,8 +3549,9 @@
 	for (; accounts ; accounts = g_list_delete_link(accounts, accounts)) {
 		PurpleAccount *account = (PurpleAccount *) accounts->data;
 
-		if (purple_account_get_connection(account)->flags &
-		    PURPLE_CONNECTION_SUPPORT_MOODS) {
+		if (purple_account_is_connected(account) &&
+		    (purple_account_get_connection(account)->flags &
+		     PURPLE_CONNECTION_SUPPORT_MOODS)) {
 			PurplePresence *presence = purple_account_get_presence(account);
 			PurpleStatus *status = purple_presence_get_status(presence, "mood");
 			const gchar *curr_mood = purple_status_get_attr_string(status, PURPLE_MOOD_NAME);