From 439a61a75ab4a7d9792d2aac9f821588a2a2a07e Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sat, 26 Jan 2019 23:09:42 +0100 Subject: fix crash while onTaskRemoved --- .../pixart/messenger/services/XmppConnectionService.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index c34afff07..bf4ffcd0a 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -1322,13 +1322,15 @@ public class XmppConnectionService extends Service { private void logoutAndSave(boolean stop) { int activeAccounts = 0; - for (final Account account : accounts) { - if (account.getStatus() != Account.State.DISABLED) { - databaseBackend.writeRoster(account.getRoster()); - activeAccounts++; - } - if (account.getXmppConnection() != null) { - new Thread(() -> disconnect(account, false)).start(); + if (accounts != null) { + for (final Account account : accounts) { + if (account.getStatus() != Account.State.DISABLED) { + databaseBackend.writeRoster(account.getRoster()); + activeAccounts++; + } + if (account.getXmppConnection() != null) { + new Thread(() -> disconnect(account, false)).start(); + } } } if (stop || activeAccounts == 0) { -- cgit v1.2.3