Changeset 509


Ignore:
Timestamp:
Jul 3, 2006, 2:30:20 AM (16 years ago)
Author:
livings124
Message:

When quitting, check time a little bit differently.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r508 r509  
    319319    [fBadger clearBadge];
    320320
     321    //stop running transfers
     322    [fTorrents makeObjectsPerformSelector: @selector(stopTransferForQuit)];
     323
    321324    //end quickly if updated version will open
    322325    if (fUpdateInProgress)
    323326        return;
    324327
    325     //stop running transfers and wait for them to stop (5 seconds timeout)
    326     [fTorrents makeObjectsPerformSelector: @selector(stopTransferForQuit)];
    327 
     328    //wait for running transfers to stop (5 seconds timeout)
    328329    NSDate * start = [NSDate date];
    329330    Torrent * torrent;
    330     while ([fTorrents count] > 0)
    331     {
    332         torrent = [fTorrents objectAtIndex: 0];
    333         while( [[NSDate date] timeIntervalSinceDate: start] < 5 &&
    334                 ![torrent isPaused] )
    335         {
    336             usleep( 100000 );
     331    BOOL timeUp = NO;
     332    int i;
     333    for (i = 0; i < [fTorrents count]; i++)
     334    {
     335        if (timeUp)
     336            break;
     337   
     338        torrent = [fTorrents objectAtIndex: i];
     339        while (![torrent isPaused] && !(timeUp = [start timeIntervalSinceNow] <= -5.0))
     340        {
     341            usleep(100000);
    337342            [torrent update];
    338343        }
    339         [fTorrents removeObject: torrent];
    340     }
     344    }
     345    [fTorrents release];
    341346}
    342347
Note: See TracChangeset for help on using the changeset viewer.