Mercurial > pidgin
changeset 27416:22dd196b9a0c
Close up scope on some variables and more correctly handle the
all-but-impossible case of purple_chat_new returning NULL.
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Fri, 10 Jul 2009 04:46:37 +0000 |
parents | 2e6482e80a16 |
children | 429fce11f244 |
files | pidgin/gtkblist.c |
diffstat | 1 files changed, 27 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/gtkblist.c Fri Jul 10 04:35:20 2009 +0000 +++ b/pidgin/gtkblist.c Fri Jul 10 04:46:37 2009 +0000 @@ -6967,12 +6967,9 @@ static void add_chat_cb(GtkWidget *w, PidginAddChatData *data) { - GHashTable *components; GList *tmp; PurpleChat *chat; - PurpleGroup *group; - const char *group_name; - const char *value; + GHashTable *components; components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); @@ -6988,7 +6985,8 @@ } else { - value = gtk_entry_get_text(tmp->data); + const char *value = gtk_entry_get_text(tmp->data); + if (*value != '\0') g_hash_table_replace(components, g_strdup(g_object_get_data(tmp->data, "identifier")), @@ -6997,28 +6995,31 @@ } chat = purple_chat_new(data->chat_data.rq_data.account, - gtk_entry_get_text(GTK_ENTRY(data->alias_entry)), - components); - - group_name = pidgin_text_combo_box_entry_get_text(data->group_combo); - - group = NULL; - if ((group_name != NULL) && (*group_name != '\0') && ((group = purple_find_group(group_name)) == NULL)) - { - group = purple_group_new(group_name); - purple_blist_add_group(group, NULL); - } - - if (chat != NULL) - { + gtk_entry_get_text(GTK_ENTRY(data->alias_entry)), + components); + + if (chat != NULL) { + PurpleGroup *group; + const char *group_name; + + group_name = pidgin_text_combo_box_entry_get_text(data->group_combo); + + group = NULL; + if ((group_name != NULL) && (*group_name != '\0') && + ((group = purple_find_group(group_name)) == NULL)) + { + group = purple_group_new(group_name); + purple_blist_add_group(group, NULL); + } + purple_blist_add_chat(chat, group, NULL); - } - - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->autojoin))) - purple_blist_node_set_bool((PurpleBlistNode*)chat, "gtk-autojoin", TRUE); - - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->persistent))) - purple_blist_node_set_bool((PurpleBlistNode*)chat, "gtk-persistent", TRUE); + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->autojoin))) + purple_blist_node_set_bool((PurpleBlistNode*)chat, "gtk-autojoin", TRUE); + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->persistent))) + purple_blist_node_set_bool((PurpleBlistNode*)chat, "gtk-persistent", TRUE); + } gtk_widget_destroy(data->chat_data.rq_data.window); g_free(data->chat_data.default_chat_name);