Changeset 13622


Ignore:
Timestamp:
Nov 24, 2012, 3:34:45 AM (8 years ago)
Author:
livings124
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r13612 r13622  
    14771477        //we can't assume the window is active - RPC removal, for example
    14781478        [fBadger removeTorrent: torrent];
     1479    }
     1480   
     1481    //#5106 - don't try to remove torrents that have already been removed (fix for a bug, but better safe than crash anyway)
     1482    NSIndexSet * indexesToRemove = [torrents indexesOfObjectsWithOptions: NSEnumerationConcurrent passingTest: ^BOOL(Torrent * torrent, NSUInteger idx, BOOL * stop) {
     1483        return [fTorrents indexOfObjectIdenticalTo: torrent] != NSNotFound;
     1484    }];
     1485    if ([torrents count] != [indexesToRemove count])
     1486    {
     1487        NSLog(@"trying to remove %ld transfers, but %ld have already been removed", [torrents count], [torrents count] - [indexesToRemove count]);
     1488        torrents = [torrents objectsAtIndexes: indexesToRemove];
     1489       
     1490        if ([indexesToRemove count] == 0)
     1491        {
     1492            [self fullUpdateUI];
     1493            return;
     1494        }
    14791495    }
    14801496   
Note: See TracChangeset for help on using the changeset viewer.