1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-23 16:18:50 -05:00

Merge pull request #601 from artbristol/art/fix-race-alternative

Remove references to Account instance when account is deleted
This commit is contained in:
cketti 2015-03-31 21:33:47 +02:00
commit 79b06cd0cc
2 changed files with 20 additions and 1 deletions

View File

@ -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);

View File

@ -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<Entry<String, Memory>> memIt = memories.entrySet().iterator();
while (memIt.hasNext()) {
Entry<String, Memory> 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);