From 1ce9d716358218d804f24e7bf040218a9da9e90c Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Thu, 24 Sep 2015 13:21:23 -0400 Subject: [PATCH] (fix) add robustness to part states handling --- UI/Scheduler/UIxCalListingActions.m | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/UI/Scheduler/UIxCalListingActions.m b/UI/Scheduler/UIxCalListingActions.m index bacb6036c..9975a8be6 100644 --- a/UI/Scheduler/UIxCalListingActions.m +++ b/UI/Scheduler/UIxCalListingActions.m @@ -328,16 +328,24 @@ static NSArray *tasksFields = nil; iCalPersonPartStat stat; NSUInteger count, max; - if ([[theRecord objectForKey: @"c_partmails"] length] > 0 && - [[theRecord objectForKey: @"c_partstates"] length] > 0) + states = nil; + + if ([[theRecord objectForKey: @"c_partmails"] length] > 0) { mails = [[theRecord objectForKey: @"c_partmails"] componentsSeparatedByString: @"\n"]; - states = [[theRecord objectForKey: @"c_partstates"] componentsSeparatedByString: @"\n"]; + + // We add some robustness here, in case the quick table had c_partmails defined but + // no corresponding c_partstates entries. This can happen if folks toy around the database + // or if Funambol was used in the past, with a broken connector. + if ([[theRecord objectForKey: @"c_partstates"] length] > 0) + states = [[theRecord objectForKey: @"c_partstates"] componentsSeparatedByString: @"\n"]; + max = [mails count]; statesDescription = [NSMutableArray arrayWithCapacity: max]; + for (count = 0; count < max; count++) { - stat = [[states objectAtIndex: count] intValue]; + stat = (states ? [[states objectAtIndex: count] intValue] : 0); [statesDescription addObject: [[iCalPerson descriptionForParticipationStatus: stat] lowercaseString]]; }