1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

Fix a theoretical concurrency issue by generating an index set directly instead of enumerating objects and filling an index set.

This commit is contained in:
Mitchell Livingston 2012-01-08 18:58:47 +00:00
parent bb16b6b4e2
commit a43f649935

View file

@ -2416,10 +2416,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
}
//remove empty groups
NSMutableIndexSet * removeIndexes = [NSMutableIndexSet indexSet];
[fDisplayedTorrents enumerateObjectsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, originalGroupCount)] options: NSEnumerationConcurrent usingBlock: ^(id obj, NSUInteger idx, BOOL * stop) {
if ([[(TorrentGroup *)obj torrents] count] == 0)
[removeIndexes addIndex: idx];
NSIndexSet * removeIndexes = [fDisplayedTorrents indexesOfObjectsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, originalGroupCount)] options: NSEnumerationConcurrent passingTest: ^BOOL(id obj, NSUInteger idx, BOOL * stop) {
return [[(TorrentGroup *)obj torrents] count] == 0;
}];
if ([removeIndexes count] > 0)