diff --git a/k9mail/src/main/java/com/fsck/k9/activity/Accounts.java b/k9mail/src/main/java/com/fsck/k9/activity/Accounts.java index 2fe55a6a1..ff5028a83 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/Accounts.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/Accounts.java @@ -1074,7 +1074,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener { // are currently not inserted to be left } MessagingController.getInstance(getApplication()) - .notifyAccountCancel(Accounts.this, realAccount); + .deleteAccount(Accounts.this, realAccount); Preferences.getPreferences(Accounts.this) .deleteAccount(realAccount); K9.setServicesEnabled(Accounts.this); diff --git a/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java b/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java index ece8a2b5b..5cdfac0c9 100644 --- a/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java +++ b/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java @@ -5126,6 +5126,11 @@ public class MessagingController implements Runnable { notificationData.remove(account.getAccountNumber()); } + public void deleteAccount(Context context, Account account) { + notifyAccountCancel(context, account); + memorizingListener.removeAccount(account); + } + /** * Save a draft message. * @param account Account we are saving for. @@ -5464,6 +5469,20 @@ public class MessagingController implements Runnable { return memory; } + synchronized void removeAccount(Account account) { + Iterator> memIt = memories.entrySet().iterator(); + + while (memIt.hasNext()) { + Entry memoryEntry = memIt.next(); + + String uuidForMemory = memoryEntry.getValue().account.getUuid(); + + if (uuidForMemory.equals(account.getUuid())) { + memIt.remove(); + } + } + } + @Override public synchronized void synchronizeMailboxStarted(Account account, String folder) { Memory memory = getMemory(account, folder);