From a55d0a691c89631993e80389147dd524de6f1b17 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 25 Apr 2017 18:17:23 +0200 Subject: [PATCH] while restoring state deal with conversations that don't have accounts --- .../conversations/services/XmppConnectionService.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index b8d433a5e..871ba9fe9 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -1450,9 +1450,15 @@ public class XmppConnectionService extends Service { accountLookupTable.put(account.getUuid(), account); } this.conversations.addAll(databaseBackend.getConversations(Conversation.STATUS_AVAILABLE)); - for (Conversation conversation : this.conversations) { + for(Iterator iterator = conversations.listIterator(); iterator.hasNext();) { + Conversation conversation = iterator.next(); Account account = accountLookupTable.get(conversation.getAccountUuid()); - conversation.setAccount(account); + if (account != null) { + conversation.setAccount(account); + } else { + Log.e(Config.LOGTAG,"unable to restore Conversations with "+conversation.getJid()); + iterator.remove(); + } } Runnable runnable = new Runnable() { @Override