#5106 Work around for crash when seeding completes and the transfer is auto-removed.

This commit is contained in:
Mitchell Livingston
2012-11-24 03:34:45 +00:00
parent b1309bc927
commit 06fb61cbda

View File

@@ -1478,6 +1478,22 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
[fBadger removeTorrent: torrent];
}
//#5106 - don't try to remove torrents that have already been removed (fix for a bug, but better safe than crash anyway)
NSIndexSet * indexesToRemove = [torrents indexesOfObjectsWithOptions: NSEnumerationConcurrent passingTest: ^BOOL(Torrent * torrent, NSUInteger idx, BOOL * stop) {
return [fTorrents indexOfObjectIdenticalTo: torrent] != NSNotFound;
}];
if ([torrents count] != [indexesToRemove count])
{
NSLog(@"trying to remove %ld transfers, but %ld have already been removed", [torrents count], [torrents count] - [indexesToRemove count]);
torrents = [torrents objectsAtIndexes: indexesToRemove];
if ([indexesToRemove count] == 0)
{
[self fullUpdateUI];
return;
}
}
[fTorrents removeObjectsInArray: torrents];
//set up helpers to remove from the table