From 6a03e62f5284ea8473eef8e7dc88107b48860763 Mon Sep 17 00:00:00 2001 From: Art O Cathain Date: Tue, 31 Mar 2015 20:10:25 +0100 Subject: [PATCH 1/2] ensure account also removed from memories on delete --- .../java/com/fsck/k9/activity/Accounts.java | 2 +- .../fsck/k9/controller/MessagingController.java | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) 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..17629dec4 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,18 @@ public class MessagingController implements Runnable { return memory; } + synchronized void removeAccount(Account account) { + Iterator> memIt = memories.entrySet().iterator(); + + while (memIt.hasNext()) { + Entry memoryEntry = memIt.next(); + + if (memoryEntry.getValue().account.getUuid().equals(account.getUuid())) { + memIt.remove(); + } + } + } + @Override public synchronized void synchronizeMailboxStarted(Account account, String folder) { Memory memory = getMemory(account, folder); From 1ec2c5b095cf88e80d79cfdfeb242f35f138ddcd Mon Sep 17 00:00:00 2001 From: Art O Cathain Date: Tue, 31 Mar 2015 20:29:51 +0100 Subject: [PATCH 2/2] Clarify --- .../main/java/com/fsck/k9/controller/MessagingController.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 17629dec4..5cdfac0c9 100644 --- a/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java +++ b/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java @@ -5475,7 +5475,9 @@ public class MessagingController implements Runnable { while (memIt.hasNext()) { Entry memoryEntry = memIt.next(); - if (memoryEntry.getValue().account.getUuid().equals(account.getUuid())) { + String uuidForMemory = memoryEntry.getValue().account.getUuid(); + + if (uuidForMemory.equals(account.getUuid())) { memIt.remove(); } }