Ignore:
Timestamp:
Feb 11, 2012, 5:13:46 AM (10 years ago)
Author:
livings124
Message:

replace NSAutoreleasePool objects with @autoreleasepool blocks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r13187 r13219  
    44314431- (void) rpcCallback: (tr_rpc_callback_type) type forTorrentStruct: (struct tr_torrent *) torrentStruct
    44324432{
    4433     NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    4434    
    4435     //get the torrent
    4436     Torrent * torrent = nil;
    4437     if (torrentStruct != NULL && (type != TR_RPC_TORRENT_ADDED && type != TR_RPC_SESSION_CHANGED && type != TR_RPC_SESSION_CLOSE))
    4438     {
    4439         for (torrent in fTorrents)
    4440             if (torrentStruct == [torrent torrentStruct])
     4433    @autoreleasepool
     4434    {
     4435        //get the torrent
     4436        Torrent * torrent = nil;
     4437        if (torrentStruct != NULL && (type != TR_RPC_TORRENT_ADDED && type != TR_RPC_SESSION_CHANGED && type != TR_RPC_SESSION_CLOSE))
     4438        {
     4439            for (torrent in fTorrents)
     4440                if (torrentStruct == [torrent torrentStruct])
     4441                {
     4442                    [torrent retain];
     4443                    break;
     4444                }
     4445           
     4446            if (!torrent)
    44414447            {
    4442                 [torrent retain];
     4448                NSLog(@"No torrent found matching the given torrent struct from the RPC callback!");
     4449                return;
     4450            }
     4451        }
     4452       
     4453        switch (type)
     4454        {
     4455            case TR_RPC_TORRENT_ADDED:
     4456                [self performSelectorOnMainThread: @selector(rpcAddTorrentStruct:) withObject:
     4457                    [[NSValue valueWithPointer: torrentStruct] retain] waitUntilDone: NO];
    44434458                break;
    4444             }
    4445        
    4446         if (!torrent)
    4447         {
    4448             [pool drain];
    4449            
    4450             NSLog(@"No torrent found matching the given torrent struct from the RPC callback!");
    4451             return;
    4452         }
    4453     }
    4454    
    4455     switch (type)
    4456     {
    4457         case TR_RPC_TORRENT_ADDED:
    4458             [self performSelectorOnMainThread: @selector(rpcAddTorrentStruct:) withObject:
    4459                 [[NSValue valueWithPointer: torrentStruct] retain] waitUntilDone: NO];
    4460             break;
    4461        
    4462         case TR_RPC_TORRENT_STARTED:
    4463         case TR_RPC_TORRENT_STOPPED:
    4464             [self performSelectorOnMainThread: @selector(rpcStartedStoppedTorrent:) withObject: torrent waitUntilDone: NO];
    4465             break;
    4466        
    4467         case TR_RPC_TORRENT_REMOVING:
    4468             [self performSelectorOnMainThread: @selector(rpcRemoveTorrent:) withObject: torrent waitUntilDone: NO];
    4469             break;
    4470        
    4471         case TR_RPC_TORRENT_TRASHING:
    4472             [self performSelectorOnMainThread: @selector(rpcRemoveTorrentDeleteData:) withObject: torrent waitUntilDone: NO];
    4473             break;
    4474        
    4475         case TR_RPC_TORRENT_CHANGED:
    4476             [self performSelectorOnMainThread: @selector(rpcChangedTorrent:) withObject: torrent waitUntilDone: NO];
    4477             break;
    4478        
    4479         case TR_RPC_TORRENT_MOVED:
    4480             [self performSelectorOnMainThread: @selector(rpcMovedTorrent:) withObject: torrent waitUntilDone: NO];
    4481             break;
    4482        
    4483         case TR_RPC_SESSION_QUEUE_POSITIONS_CHANGED:
    4484             [self performSelectorOnMainThread: @selector(rpcUpdateQueue) withObject: nil waitUntilDone: NO];
    4485             break;
    4486        
    4487         case TR_RPC_SESSION_CHANGED:
    4488             [fPrefsController performSelectorOnMainThread: @selector(rpcUpdatePrefs) withObject: nil waitUntilDone: NO];
    4489             break;
    4490        
    4491         case TR_RPC_SESSION_CLOSE:
    4492             fQuitRequested = YES;
    4493             [NSApp performSelectorOnMainThread: @selector(terminate:) withObject: self waitUntilDone: NO];
    4494             break;
    4495        
    4496         default:
    4497             NSAssert1(NO, @"Unknown RPC command received: %d", type);
    4498             [torrent release];
    4499     }
    4500    
    4501     [pool drain];
     4459           
     4460            case TR_RPC_TORRENT_STARTED:
     4461            case TR_RPC_TORRENT_STOPPED:
     4462                [self performSelectorOnMainThread: @selector(rpcStartedStoppedTorrent:) withObject: torrent waitUntilDone: NO];
     4463                break;
     4464           
     4465            case TR_RPC_TORRENT_REMOVING:
     4466                [self performSelectorOnMainThread: @selector(rpcRemoveTorrent:) withObject: torrent waitUntilDone: NO];
     4467                break;
     4468           
     4469            case TR_RPC_TORRENT_TRASHING:
     4470                [self performSelectorOnMainThread: @selector(rpcRemoveTorrentDeleteData:) withObject: torrent waitUntilDone: NO];
     4471                break;
     4472           
     4473            case TR_RPC_TORRENT_CHANGED:
     4474                [self performSelectorOnMainThread: @selector(rpcChangedTorrent:) withObject: torrent waitUntilDone: NO];
     4475                break;
     4476           
     4477            case TR_RPC_TORRENT_MOVED:
     4478                [self performSelectorOnMainThread: @selector(rpcMovedTorrent:) withObject: torrent waitUntilDone: NO];
     4479                break;
     4480           
     4481            case TR_RPC_SESSION_QUEUE_POSITIONS_CHANGED:
     4482                [self performSelectorOnMainThread: @selector(rpcUpdateQueue) withObject: nil waitUntilDone: NO];
     4483                break;
     4484           
     4485            case TR_RPC_SESSION_CHANGED:
     4486                [fPrefsController performSelectorOnMainThread: @selector(rpcUpdatePrefs) withObject: nil waitUntilDone: NO];
     4487                break;
     4488           
     4489            case TR_RPC_SESSION_CLOSE:
     4490                fQuitRequested = YES;
     4491                [NSApp performSelectorOnMainThread: @selector(terminate:) withObject: self waitUntilDone: NO];
     4492                break;
     4493           
     4494            default:
     4495                NSAssert1(NO, @"Unknown RPC command received: %d", type);
     4496                [torrent release];
     4497        }
     4498    }
    45024499}
    45034500
Note: See TracChangeset for help on using the changeset viewer.