From 51ee0c1f2d8d7d16592b15868f088021a2f1b366 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Fri, 4 Apr 2003 23:22:04 +0000 Subject: Don't start emitting ACCOUNT_ADDED signals until we've added all of the * e-account-list.c (gconf_accounts_changed): Don't start emitting ACCOUNT_ADDED signals until we've added all of the new accounts to our list. Otherwise if the signal handler calls e_account_list_get_default_account() it will end up causing the first account in the list to become the default. #40675 svn path=/trunk/; revision=20680 --- e-util/ChangeLog | 8 ++++++++ e-util/e-account-list.c | 18 +++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'e-util') diff --git a/e-util/ChangeLog b/e-util/ChangeLog index 8d78374234..dc8b1f130e 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,11 @@ +2003-04-04 Dan Winship + + * e-account-list.c (gconf_accounts_changed): Don't start emitting + ACCOUNT_ADDED signals until we've added all of the new accounts to + our list. Otherwise if the signal handler calls + e_account_list_get_default_account() it will end up causing the + first account in the list to become the default. #40675 + 2003-04-04 Chris Toshok * ename/e-name-western.c (e_name_western_extract_middle): fix abr. diff --git a/e-util/e-account-list.c b/e-util/e-account-list.c index 825601f2af..acb9093cb4 100644 --- a/e-util/e-account-list.c +++ b/e-util/e-account-list.c @@ -130,7 +130,7 @@ gconf_accounts_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data) { EAccountList *account_list = user_data; - GSList *list, *l; + GSList *list, *l, *new_accounts = NULL; EAccount *account; EList *old_accounts; EIterator *iter; @@ -164,14 +164,26 @@ gconf_accounts_changed (GConfClient *client, guint cnxn_id, /* Must be a new account */ account = e_account_new_from_xml (l->data); e_list_append (E_LIST (account_list), account); - g_signal_emit (account_list, signals[ACCOUNT_ADDED], 0, account); - g_object_unref (account); + new_accounts = g_slist_prepend (new_accounts, account); next: g_free (uid); g_object_unref (iter); } + /* Now emit signals for each added account. (We do this after + * adding all of them because otherwise if the signal handler + * calls e_account_list_get_default_account() it will end up + * causing the first account in the list to become the + * default.) + */ + for (l = new_accounts; l; l = l->next) { + account = l->data; + g_signal_emit (account_list, signals[ACCOUNT_ADDED], 0, account); + g_object_unref (account); + } + g_slist_free (new_accounts); + /* Anything left in old_accounts must have been deleted */ for (iter = e_list_get_iterator (old_accounts); e_iterator_is_valid (iter); -- cgit v1.2.3