From de4c391ec2eba36667a8ed7622f57f1877dda934 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Wed, 5 Sep 2001 23:04:33 +0000 Subject: Adjust the default_account index correctly. 2001-09-05 Jeffrey Stedfast * mail-config.c (mail_config_remove_account): Adjust the default_account index correctly. 2001-09-05 Jeffrey Stedfast * mail-config.c (mail_config_get_accounts): Added a g_assert to make sure that config wasn't NULL. This is meant to help debug bug #4911 and friends. * component-factory.c (owner_set_cb): Do not mail_config_init() here as we've already called this in main() in main.c. svn path=/trunk/; revision=12640 --- mail/mail-config.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'mail/mail-config.c') diff --git a/mail/mail-config.c b/mail/mail-config.c index 1ae74ae0e8..68b310daa0 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -461,7 +461,7 @@ config_read (void) default_num = bonobo_config_get_long_with_default (config->db, "/Mail/Accounts/default_account", 0, NULL); - + mail_config_set_default_account_num (default_num); #ifdef ENABLE_NNTP @@ -1438,6 +1438,8 @@ mail_config_get_account_by_transport_url (const char *transport_url) const GSList * mail_config_get_accounts (void) { + g_assert (config != NULL); + return config->accounts; } @@ -1658,15 +1660,23 @@ remove_account_shortcuts (MailConfigAccount *account) const GSList * mail_config_remove_account (MailConfigAccount *account) { + int index; + /* Removing the current default, so make the first account the default */ - if (account == mail_config_get_default_account ()) + if (account == mail_config_get_default_account ()) { config->default_account = 0; - + } else { + /* adjust the default to make sure it points to the same one */ + index = g_slist_index (config->accounts, account); + if (config->default_account > index) + config->default_account--; + } + config->accounts = g_slist_remove (config->accounts, account); remove_account_shortcuts (account); account_destroy (account); - + return config->accounts; } -- cgit v1.2.3