From 602099cfd37f1864df97b3abeeedde0e7372106f Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Fri, 5 Nov 2010 01:16:35 +0000 Subject: [PATCH] Be more careful about deleting messages from the MessageListAdapter - don't do it from something that's not the UI thread --- src/com/fsck/k9/activity/MessageList.java | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index 83a6d692d..04a59c3e2 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -2288,20 +2288,23 @@ public class MessageList } public void pruneDirtyMessages() { - Iterator iter = mAdapter.messages.iterator(); - while (iter.hasNext()) + synchronized (mAdapter.messages) { - MessageInfoHolder holder = iter.next(); - if (holder.dirty) + Iterator iter = mAdapter.messages.iterator(); + while (iter.hasNext()) { - if (holder.selected) + MessageInfoHolder holder = iter.next(); + if (holder.dirty) { - mSelectedCount--; - toggleBatchButtons(); + if (holder.selected) + { + mSelectedCount--; + toggleBatchButtons(); + } + mAdapter.removeMessage(holder); } - iter.remove(); } - } + } } public void removeMessages(List holders)