From 6a3285795a52ae0d177d079e9ee23bb092ef76d7 Mon Sep 17 00:00:00 2001 From: Will Song Date: Thu, 27 Nov 2014 20:26:10 -0600 Subject: [PATCH] removing the account connected to the default account removes the default account as well --- src/command/commands.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/command/commands.c b/src/command/commands.c index e217e7e8..c294a16b 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -206,13 +206,19 @@ cmd_account(gchar **args, struct cmd_help_t help) if(!account_name) { cons_show("Usage: %s", help.usage); } else { + char *def = prefs_get_string(PREF_DEFAULT_ACCOUNT); if(accounts_remove(account_name)){ cons_show("Account %s removed.", account_name); + if(def && strcmp(def, account_name) == 0){ + prefs_set_string(PREF_DEFAULT_ACCOUNT, NULL); + cons_show("Default account removed because the corresponding account was removed."); + } } else { cons_show("Failed to remove account %s.", account_name); cons_show("Either the account does not exist, or an unknown error occurred."); } cons_show(""); + g_free(def); } } else if (strcmp(command, "enable") == 0) { char *account_name = args[1];