fix(calendar): avoid exception when FoldersOrder have invalid entries

pull/291/head
Francis Lachapelle 2020-12-18 11:22:42 -05:00
parent 7da4bc465f
commit c27be0fbe5
1 changed files with 8 additions and 7 deletions

View File

@ -138,13 +138,7 @@ _intValueFromHex (NSString *hexString)
sortedFolderNames = [NSMutableArray arrayWithCapacity: max]; sortedFolderNames = [NSMutableArray arrayWithCapacity: max];
for (count = max-1; count >= 0; count--) for (count = max-1; count >= 0; count--)
{ {
if ([[sortedFolders objectAtIndex: count] isKindOfClass: [NSString class]]) if ([[sortedFolders objectAtIndex: count] isKindOfClass: [SOGoAppointmentFolder class]])
{
// Calendar no longer exists; remove it from user's "FoldersOrder" setting
dirty = YES;
[sortedFolders removeObjectAtIndex: count];
}
else
{ {
folder = [sortedFolders objectAtIndex: count]; folder = [sortedFolders objectAtIndex: count];
folderName = [folder nameInContainer]; folderName = [folder nameInContainer];
@ -153,6 +147,13 @@ _intValueFromHex (NSString *hexString)
else else
[self errorWithFormat: @"Unexpected entry in FoldersOrder setting: %@", folder]; [self errorWithFormat: @"Unexpected entry in FoldersOrder setting: %@", folder];
} }
else
{
// Calendar no longer exists; remove it from user's "FoldersOrder" setting
[self errorWithFormat: @"Invalid folder in FoldersOrder setting: %@", [sortedFolders objectAtIndex: count]];
dirty = YES;
[sortedFolders removeObjectAtIndex: count];
}
} }
if (dirty) if (dirty)