From 6573f27ceca52d74d267eb2a64799d949ca01e76 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Thu, 2 Sep 2010 03:45:16 +0000 Subject: [PATCH] do our messagelist updates from sync on the ui thread rather than the sync thread. copy the incoming message list to deal with concurrent access issues. Patch by cketti++ --- src/com/fsck/k9/activity/MessageList.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index 97391093f..262110a77 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -2058,8 +2058,16 @@ public class MessageList addOrUpdateMessages(account, folder, messages, verifyAgainstSearch); } - private void addOrUpdateMessages(Account account, String folder, List messages, boolean verifyAgainstSearch) + private void addOrUpdateMessages(final Account account, final String folder, final List providedMessages, final boolean verifyAgainstSearch) { + // we copy the message list because the callback doesn't expect + // the callbacks to mutate it. + final List messages = new ArrayList(providedMessages); + + runOnUiThread(new Runnable() + { + public void run() + { boolean needsSort = false; final List messagesToAdd = new ArrayList(); List messagesToRemove = new ArrayList(); @@ -2133,6 +2141,8 @@ public class MessageList mHandler.sortMessages(); mHandler.resetUnreadCount(); } + } + }); } public MessageInfoHolder getMessage(Message message) {