Skip to content

Commit b466322

Browse files
Don't crash when disconnecting an account while a catchup finishes
1 parent 060db00 commit b466322

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

Monal/Classes/MLXMPPManager.m

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -585,33 +585,26 @@ -(void) connectAccountWithDictionary:(NSDictionary*) account
585585

586586
-(void) disconnectAccount:(NSNumber*) accountID withExplicitLogout:(BOOL) explicitLogout
587587
{
588-
int index = 0;
589-
int pos = -1;
590588
xmpp* account;
591589
@synchronized(_connectedXMPP) {
592590
for(xmpp* xmppAccount in _connectedXMPP)
593-
{
594591
if(xmppAccount.accountID.intValue == accountID.intValue)
595592
{
596593
account = xmppAccount;
597-
pos=index;
598594
break;
599595
}
600-
index++;
601-
}
602-
603-
if((pos >= 0) && (pos < (int)[_connectedXMPP count]))
604-
{
605-
[_connectedXMPP removeObjectAtIndex:pos];
606-
DDLogVerbose(@"removed account at pos %d", pos);
607-
}
608596
}
597+
609598
if(account)
610599
{
611600
DDLogVerbose(@"got account and cleaning up.. ");
612601
[account disconnect:explicitLogout];
613-
account = nil;
614602
DDLogVerbose(@"done cleaning up account ");
603+
604+
@synchronized(_connectedXMPP) {
605+
[_connectedXMPP removeObject:account];
606+
DDLogVerbose(@"removed account from _connectedXMPP");
607+
}
615608
}
616609
}
617610

0 commit comments

Comments
 (0)