# HG changeset patch # User Marcus Lundblad # Date 1274294878 0 # Node ID 8e060965d69faa6acfae76518ee5bcaf325e4a4d # Parent 7396d2fe66dd96580b0cd53648edac02e4e314a8 pidgin: Fix a crash when accessing the Set Moods tool menu when having disconnected mood-capable accounts. Fixes #11946 diff -r 7396d2fe66dd -r 8e060965d69f ChangeLog --- 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. diff -r 7396d2fe66dd -r 8e060965d69f pidgin/gtkblist.c --- 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);