From decc0926b753318119ab9e9e573f6c171be9ed7e Mon Sep 17 00:00:00 2001 From: Alif Kuan Date: Sat, 14 Nov 2015 09:31:56 +0800 Subject: [PATCH] issue of "Collection<> was mutated while being enumerated" has fixed --- Extensions/Roster/XMPPRoster.m | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Extensions/Roster/XMPPRoster.m b/Extensions/Roster/XMPPRoster.m index 65c3d89990..4818fd10d5 100644 --- a/Extensions/Roster/XMPPRoster.m +++ b/Extensions/Roster/XMPPRoster.m @@ -41,10 +41,13 @@ - (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)prese #pragma mark - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -@implementation XMPPRoster +@implementation XMPPRoster{ + Boolean inEnumerating; +} - (id)init { + inEnumerating = NO; return [self initWithRosterStorage:nil dispatchQueue:NULL]; } @@ -768,12 +771,12 @@ - (void)handleFetchRosterQueryIQ:(XMPPIQ *)iq withInfo:(XMPPBasicTrackingInfo *) [xmppRosterStorage endRosterPopulationForXMPPStream:xmppStream]; // Process any premature presence elements we received. - + inEnumerating = YES; for (XMPPPresence *presence in earlyPresenceElements) { [self xmppStream:xmppStream didReceivePresence:presence]; } - + inEnumerating = NO; [earlyPresenceElements removeAllObjects]; } @@ -930,8 +933,8 @@ - (void)xmppStream:(XMPPStream *)sender didSendPresence:(XMPPPresence *)presence // So there's no need to refetch the roster. [xmppRosterStorage clearAllResourcesForXMPPStream:xmppStream]; - - [earlyPresenceElements removeAllObjects]; + if(inEnumerating == NO) + [earlyPresenceElements removeAllObjects]; } } @@ -952,8 +955,8 @@ - (void)xmppStreamDidDisconnect:(XMPPStream *)sender withError:(NSError *)error [self _setRequestedRoster:NO]; [self _setHasRoster:NO]; - - [earlyPresenceElements removeAllObjects]; + if(inEnumerating == NO) + [earlyPresenceElements removeAllObjects]; } #ifdef _XMPP_MUC_H