Ignore:
Timestamp:
Mar 13, 2012, 2:52:11 AM (10 years ago)
Author:
livings124
Message:

reverse r13248-r13250, since ARC doesn't support 32-bit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r13248 r13251  
    140140    NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: [[NSNumber alloc] initWithBool: active], @"Active",
    141141                                [[NSNumber alloc] initWithBool: byUser], @"ByUser", nil];
    142     [(__bridge Controller *)controller performSelectorOnMainThread: @selector(altSpeedToggledCallbackIsLimited:)
     142    [(Controller *)controller performSelectorOnMainThread: @selector(altSpeedToggledCallbackIsLimited:)
    143143        withObject: dict waitUntilDone: NO];
    144144}
     
    147147                                            void * controller)
    148148{
    149     [(__bridge Controller *)controller rpcCallback: type forTorrentStruct: torrentStruct];
     149    [(Controller *)controller rpcCallback: type forTorrentStruct: torrentStruct];
    150150    return TR_RPC_NOREMOVE; //we'll do the remove manually
    151151}
     
    153153static void sleepCallback(void * controller, io_service_t y, natural_t messageType, void * messageArgument)
    154154{
    155     [(__bridge Controller *)controller sleepCallback: messageType argument: messageArgument];
     155    [(Controller *)controller sleepCallback: messageType argument: messageArgument];
    156156}
    157157
     
    173173       
    174174        [alert runModal];
     175        [alert release];
    175176       
    176177        //kill ourselves right away
     
    182183   
    183184    //set custom value transformers
    184     ExpandedPathToPathTransformer * pathTransformer = [[ExpandedPathToPathTransformer alloc] init];
     185    ExpandedPathToPathTransformer * pathTransformer = [[[ExpandedPathToPathTransformer alloc] init] autorelease];
    185186    [NSValueTransformer setValueTransformer: pathTransformer forName: @"ExpandedPathToPathTransformer"];
    186187   
    187     ExpandedPathToIconTransformer * iconTransformer = [[ExpandedPathToIconTransformer alloc] init];
     188    ExpandedPathToIconTransformer * iconTransformer = [[[ExpandedPathToIconTransformer alloc] init] autorelease];
    188189    [NSValueTransformer setValueTransformer: iconTransformer forName: @"ExpandedPathToIconTransformer"];
    189190   
     
    203204        if ([alert runModal] == NSAlertSecondButtonReturn)
    204205            exit(0);
     206        [alert release];
    205207       
    206208        [[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningLegal"];
     
    341343        fSoundPlaying = NO;
    342344       
    343         tr_sessionSetAltSpeedFunc(fLib, altSpeedToggledCallback, (__bridge void *)(self));
     345        tr_sessionSetAltSpeedFunc(fLib, altSpeedToggledCallback, self);
    344346        if (usesSpeedLimitSched)
    345347            [fDefaults setBool: tr_sessionUsesAltSpeed(fLib) forKey: @"SpeedLimit"];
    346348       
    347         tr_sessionSetRPCCallback(fLib, rpcCallback, (__bridge void *)(self));
     349        tr_sessionSetRPCCallback(fLib, rpcCallback, self);
    348350       
    349351        [GrowlApplicationBridge setGrowlDelegate: self];
     
    367369    [toolbar setDisplayMode: NSToolbarDisplayModeIconOnly];
    368370    [fWindow setToolbar: toolbar];
     371    [toolbar release];
    369372   
    370373    [fWindow setDelegate: self]; //do manually to avoid placement issue
     
    436439    IONotificationPortRef notify;
    437440    io_object_t iterator;
    438     if ((fRootPort = IORegisterForSystemPower((__bridge void *)(self), & notify, sleepCallback, &iterator)))
     441    if ((fRootPort = IORegisterForSystemPower(self, & notify, sleepCallback, &iterator)))
    439442        CFRunLoopAddSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notify), kCFRunLoopCommonModes);
    440443    else
     
    466469                    [waitToStartTorrents addObject: torrent];
    467470               
     471                [torrent release];
    468472            }
    469473        }
     
    596600                [fDefaults setBool: ([[alert suppressionButton] state] != NSOnState) forKey: @"WarningDonate"];
    597601           
     602            [alert release];
    598603        }
    599604    }
     
    666671        if ([fAutoImportTimer isValid])
    667672            [fAutoImportTimer invalidate];
     673        [fAutoImportTimer release];
    668674    }
    669675   
     
    677683            NSURLDownload * download = [downloadDict objectForKey: @"Download"];
    678684            [download cancel];
    679         }
     685            [download release];
     686        }
     687        [fPendingTorrentDownloads release];
    680688    }
    681689   
     
    696704    [fTableView saveCollapsedGroups];
    697705   
     706    //remaining calls the same as dealloc
     707    [fInfoController release];
     708    [fMessageController release];
     709    [fPrefsController release];
     710   
     711    [fStatusBar release];
     712    [fFilterBar release];
     713   
     714    [fTorrents release];
     715    [fDisplayedTorrents release];
     716   
     717    [fAddingTransfers release];
     718   
     719    [fOverlayWindow release];
     720    [fBadger release];
     721   
     722    [fAutoImportedNames release];
     723   
     724    [fPreviewPanel release];
     725   
    698726    //complete cleanup
    699727    tr_sessionClose(fLib);
     
    723751    {
    724752        [download cancel];
    725        
    726         [fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
    727         if ([fPendingTorrentDownloads count] == 0)
    728             fPendingTorrentDownloads = nil;
    729753       
    730754        NSRunAlertPanel(NSLocalizedString(@"Torrent download failed", "Download not a torrent -> title"),
     
    733757            [[[[download request] URL] absoluteString] stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding]],
    734758            NSLocalizedString(@"OK", "Download not a torrent -> button"), nil, nil);
     759       
     760        [download release];
    735761    }
    736762    else
     
    741767-(void) download: (NSURLDownload *) download didCreateDestination: (NSString *) path
    742768{
    743     [(NSMutableDictionary *)[fPendingTorrentDownloads objectForKey: [[download request] URL]] setObject: path forKey: @"Path"];
     769    if (!fPendingTorrentDownloads)
     770        fPendingTorrentDownloads = [[NSMutableDictionary alloc] init];
     771   
     772    [fPendingTorrentDownloads setObject: [NSDictionary dictionaryWithObjectsAndKeys:
     773                    path, @"Path", download, @"Download", nil] forKey: [[download request] URL]];
    744774}
    745775
     
    754784    [fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
    755785    if ([fPendingTorrentDownloads count] == 0)
     786    {
     787        [fPendingTorrentDownloads release];
    756788        fPendingTorrentDownloads = nil;
     789    }
     790   
     791    [download release];
    757792}
    758793
     
    768803    [fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
    769804    if ([fPendingTorrentDownloads count] == 0)
     805    {
     806        [fPendingTorrentDownloads release];
    770807        fPendingTorrentDownloads = nil;
     808    }
     809   
     810    [download release];
    771811}
    772812
     
    862902                                                    deleteTorrent: deleteTorrentFile canToggleDelete: canToggleDelete];
    863903            [addController showWindow: self];
    864            
    865             if (!fAddWindows)
    866                 fAddWindows = [NSMutableSet set];
    867             [fAddWindows addObject: addController];
    868904        }
    869905        else
     
    874910            [torrent update];
    875911            [fTorrents addObject: torrent];
     912            [torrent release];
    876913           
    877914            if (!fAddingTransfers)
     
    887924{
    888925    Torrent * torrent = [addController torrent];
     926    [addController autorelease];
    889927   
    890928    if (add)
     
    894932        [torrent update];
    895933        [fTorrents addObject: torrent];
     934        [torrent release];
    896935       
    897936        if (!fAddingTransfers)
     
    904943    {
    905944        [torrent closeRemoveTorrent: NO];
    906     }
    907    
    908     [fAddWindows removeObject: addController];
    909     if ([fAddWindows count] == 0)
    910         fAddWindows = nil;
     945        [torrent release];
     946    }
    911947}
    912948
     
    946982                                                        controller: self];
    947983        [addController showWindow: self];
    948        
    949         if (!fAddWindows)
    950             fAddWindows = [NSMutableSet set];
    951         [fAddWindows addObject: addController];
    952984    }
    953985    else
     
    958990        [torrent update];
    959991        [fTorrents addObject: torrent];
     992        [torrent release];
    960993       
    961994        if (!fAddingTransfers)
     
    9701003{
    9711004    Torrent * torrent = [addController torrent];
     1005    [addController autorelease];
    9721006   
    9731007    if (add)
     
    9771011        [torrent update];
    9781012        [fTorrents addObject: torrent];
     1013        [torrent release];
    9791014       
    9801015        if (!fAddingTransfers)
     
    9871022    {
    9881023        [torrent closeRemoveTorrent: NO];
    989     }
    990    
    991     [fAddWindows removeObject: addController];
    992     if ([fAddWindows count] == 0)
    993         fAddWindows = nil;
     1024        [torrent release];
     1025    }
    9941026}
    9951027
     
    9971029{
    9981030    NSDictionary * dict = [notification userInfo];
    999     [self openFiles: [NSArray arrayWithObject: [dict objectForKey: @"File"]] addType: ADD_CREATED forcePath: [dict objectForKey: @"Path"]];
     1031    [self openFiles: [NSArray arrayWithObject: [dict objectForKey: @"File"]] addType: ADD_CREATED
     1032                        forcePath: [dict objectForKey: @"Path"]];
     1033    [dict release];
    10001034}
    10011035
     
    10031037{
    10041038    [self openFiles: [dictionary objectForKey: @"Filenames"] addType: [[dictionary objectForKey: @"AddType"] intValue] forcePath: nil];
     1039   
     1040    [dictionary release];
    10051041}
    10061042
     
    10541090    if ([[alert suppressionButton] state] == NSOnState)
    10551091        [fDefaults setBool: NO forKey: @"WarningInvalidOpen"];
     1092    [alert release];
    10561093}
    10571094
     
    10711108    if ([[alert suppressionButton] state] == NSOnState)
    10721109        [fDefaults setBool: NO forKey: @"WarningInvalidOpen"];
     1110    [alert release];
    10731111}
    10741112
     
    10911129    if ([[alert suppressionButton] state])
    10921130        [fDefaults setBool: NO forKey: @"WarningDuplicate"];
     1131    [alert release];
    10931132}
    10941133
     
    11151154    if ([[alert suppressionButton] state])
    11161155        [fDefaults setBool: NO forKey: @"WarningDuplicate"];
     1156    [alert release];
    11171157}
    11181158
     
    11411181        NSURLRequest * request = [NSURLRequest requestWithURL: [NSURL URLWithString: urlString]
    11421182                                    cachePolicy: NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval: 60];
    1143        
    1144         if ([fPendingTorrentDownloads objectForKey: [request URL]])
    1145         {
    1146             NSLog(@"Already downloading %@", [request URL]);
    1147             return;
    1148         }
    1149        
    1150         NSURLDownload * download = [[NSURLDownload alloc] initWithRequest: request delegate: self];
    1151        
    1152         if (!fPendingTorrentDownloads)
    1153             fPendingTorrentDownloads = [[NSMutableDictionary alloc] init];
    1154        
    1155         [fPendingTorrentDownloads setObject: [NSMutableDictionary dictionaryWithObject: download forKey: @"Download"] forKey: [request URL]];
     1183        [[NSURLDownload alloc] initWithRequest: request delegate: self];
    11561184    }
    11571185}
     
    11591187- (void) openURLShowSheet: (id) sender
    11601188{
    1161     if (!fUrlSheetController)
    1162     {
    1163         fUrlSheetController = [[URLSheetWindowController alloc] initWithController: self];
    1164        
    1165         [NSApp beginSheet: [fUrlSheetController window] modalForWindow: fWindow modalDelegate: self didEndSelector: @selector(urlSheetDidEnd:returnCode:contextInfo:) contextInfo: nil];
    1166     }
    1167 }
    1168 
    1169 - (void) urlSheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
     1189    [[[URLSheetWindowController alloc] initWithController: self] beginSheetForWindow: fWindow];
     1190}
     1191
     1192- (void) urlSheetDidEnd: (URLSheetWindowController *) controller url: (NSString *) urlString returnCode: (NSInteger) returnCode
    11701193{
    11711194    if (returnCode == 1)
    1172     {
    1173         NSString * urlString = [fUrlSheetController urlString];
    11741195        [self performSelectorOnMainThread: @selector(openURL:) withObject: urlString waitUntilDone: NO];
    1175     }
    1176    
    1177     fUrlSheetController = nil;
     1196   
     1197    [controller release];
    11781198}
    11791199
     
    12571277- (void) removeTorrents: (NSArray *) torrents deleteData: (BOOL) deleteData
    12581278{
     1279    [torrents retain];
    12591280
    12601281    if ([fDefaults boolForKey: @"CheckRemove"])
     
    13191340            NSBeginAlertSheet(title, NSLocalizedString(@"Remove", "Removal confirm panel -> button"),
    13201341                NSLocalizedString(@"Cancel", "Removal confirm panel -> button"), nil, fWindow, self,
    1321                 nil, @selector(removeSheetDidEnd:returnCode:contextInfo:), (__bridge void *)dict, message);
     1342                nil, @selector(removeSheetDidEnd:returnCode:contextInfo:), dict, message);
    13221343            return;
    13231344        }
     
    13321353    if (returnCode == NSAlertDefaultReturn)
    13331354        [self confirmRemoveTorrents: torrents deleteData: [[dict objectForKey: @"DeleteData"] boolValue]];
     1355    else
     1356        [torrents release];
     1357   
     1358    [dict release];
    13341359}
    13351360
     
    14191444   
    14201445    [self fullUpdateUI];
     1446   
     1447    #warning why do we need them retained?
     1448    [torrents autorelease];
    14211449}
    14221450
     
    14601488        }
    14611489       
    1462         NSAlert * alert = [[NSAlert alloc] init];
     1490        NSAlert * alert = [[[NSAlert alloc] init] autorelease];
    14631491        [alert setMessageText: message];
    14641492        [alert setInformativeText: info];
     
    14741502        if (returnCode != NSAlertFirstButtonReturn)
    14751503        {
     1504            [torrents release];
    14761505            return;
    14771506        }
     
    15211550    if ([torrents count] == 0)
    15221551    {
     1552        [torrents release];
    15231553        return;
    15241554    }
     
    15571587           
    15581588            [alert runModal];
     1589            [alert release];
    15591590        }
    15601591       
     
    22702301                        if (!newGroup)
    22712302                        {
    2272                             newGroup = [[TorrentGroup alloc] initWithGroup: groupValue];
     2303                            newGroup = [[[TorrentGroup alloc] initWithGroup: groupValue] autorelease];
    22732304                            [groupsByIndex setObject: newGroup forKey: [NSNumber numberWithInteger: groupValue]];
    22742305                            [fDisplayedTorrents addObject: newGroup];
     
    23162347            if (!group)
    23172348            {
    2318                 group = [[TorrentGroup alloc] initWithGroup: groupValue];
     2349                group = [[[TorrentGroup alloc] initWithGroup: groupValue] autorelease];
    23192350                [groupsByIndex setObject: group forKey: [NSNumber numberWithInteger: groupValue]];
    23202351                [fDisplayedTorrents addObject: group];
     
    23792410                if (!group)
    23802411                {
    2381                     group = [[TorrentGroup alloc] initWithGroup: groupValue];
     2412                    group = [[[TorrentGroup alloc] initWithGroup: groupValue] autorelease];
    23822413                    [groupsByIndex setObject: group forKey: [NSNumber numberWithInteger: groupValue]];
    23832414                }
     
    24472478    if (fAddingTransfers)
    24482479    {
     2480        [fAddingTransfers release];
    24492481        fAddingTransfers = nil;
    24502482    }
     
    24712503        [popover showRelativeToRect: [sender frame] ofView: sender preferredEdge: NSMaxYEdge];
    24722504       
     2505        [viewController release];
     2506        [popover release];
    24732507    }
    24742508    else
     
    25062540        for (NSInteger i = 0; i < groupMenuCount; i++)
    25072541        {
    2508             NSMenuItem * item = [groupMenu itemAtIndex: 0];
     2542            NSMenuItem * item = [[groupMenu itemAtIndex: 0] retain];
    25092543            [groupMenu removeItemAtIndex: 0];
    25102544            [menu addItem: item];
     2545            [item release];
    25112546        }
    25122547    }
     
    25272562            [item setRepresentedObject: [NSNumber numberWithInt: speedLimitActionValue[i]]];
    25282563            [menu addItem: item];
     2564            [item release];
    25292565        }
    25302566    }
     
    25442580            [item setRepresentedObject: [NSNumber numberWithFloat: ratioLimitActionValue[i]]];
    25452581            [menu addItem: item];
     2582            [item release];
    25462583        }
    25472584    }
     
    25902627            notificationName: GROWL_AUTO_SPEED_LIMIT iconData: nil priority: 0 isSticky: NO clickContext: nil];
    25912628   
     2629    [dict release];
    25922630}
    25932631
     
    26412679            if ([fAutoImportTimer isValid])
    26422680                [fAutoImportTimer invalidate];
     2681            [fAutoImportTimer release];
    26432682            fAutoImportTimer = nil;
    26442683        }
    26452684       
    26462685        //check again in 10 seconds in case torrent file wasn't complete
    2647         fAutoImportTimer = [NSTimer scheduledTimerWithTimeInterval: 10.0 target: self
    2648             selector: @selector(checkAutoImportDirectory) userInfo: nil repeats: NO];
     2686        fAutoImportTimer = [[NSTimer scheduledTimerWithTimeInterval: 10.0 target: self
     2687            selector: @selector(checkAutoImportDirectory) userInfo: nil repeats: NO] retain];
    26492688       
    26502689        [self checkAutoImportDirectory];
     
    26582697        if ([fAutoImportTimer isValid])
    26592698            [fAutoImportTimer invalidate];
     2699        [fAutoImportTimer release];
    26602700        fAutoImportTimer = nil;
    26612701    }
    26622702   
    2663     fAutoImportedNames = nil;
     2703    if (fAutoImportedNames)
     2704    {
     2705        [fAutoImportedNames release];
     2706        fAutoImportedNames = nil;
     2707    }
    26642708   
    26652709    [self checkAutoImportDirectory];
     
    27222766    }
    27232767   
     2768    [newNames release];
    27242769}
    27252770
     
    32593304    {
    32603305        [[fStatusBar view] removeFromSuperviewWithoutNeedingDisplay];
     3306        [fStatusBar release];
    32613307        fStatusBar = nil;
    32623308    }
     
    33563402    {
    33573403        [[fFilterBar view] removeFromSuperviewWithoutNeedingDisplay];
     3404        [fFilterBar release];
    33583405        fFilterBar = nil;
    33593406    }
     
    33843431- (void) beginPreviewPanelControl: (QLPreviewPanel *) panel
    33853432{
    3386     fPreviewPanel = panel;
     3433    fPreviewPanel = [panel retain];
    33873434    [fPreviewPanel setDelegate: self];
    33883435    [fPreviewPanel setDataSource: self];
     
    33913438- (void) endPreviewPanelControl: (QLPreviewPanel *) panel
    33923439{
     3440    [fPreviewPanel release];
    33933441    fPreviewPanel = nil;
    33943442}
     
    34673515   
    34683516    [item setView: button];
     3517    [button release];
    34693518   
    34703519    const NSSize buttonSize = NSMakeSize(36.0, 25.0);
     
    34723521    [item setMaxSize: buttonSize];
    34733522   
    3474     return item;
     3523    return [item autorelease];
    34753524}
    34763525
     
    35523601       
    35533602        NSSegmentedControl * segmentedControl = [[NSSegmentedControl alloc] initWithFrame: NSZeroRect];
    3554         [segmentedControl setCell: [[ToolbarSegmentedCell alloc] init]];
     3603        [segmentedControl setCell: [[[ToolbarSegmentedCell alloc] init] autorelease]];
    35553604        [groupItem setView: segmentedControl];
    35563605        NSSegmentedCell * segmentedCell = (NSSegmentedCell *)[segmentedControl cell];
     
    35833632                                        NSLocalizedString(@"Resume All", "All toolbar item -> label"), nil]];
    35843633       
     3634        [segmentedControl release];
    35853635       
    35863636        [groupItem setVisibilityPriority: NSToolbarItemVisibilityPriorityHigh];
    35873637       
    3588         return groupItem;
     3638        return [groupItem autorelease];
    35893639    }
    35903640    else if ([ident isEqualToString: TOOLBAR_PAUSE_RESUME_SELECTED])
     
    35933643       
    35943644        NSSegmentedControl * segmentedControl = [[NSSegmentedControl alloc] initWithFrame: NSZeroRect];
    3595         [segmentedControl setCell: [[ToolbarSegmentedCell alloc] init]];
     3645        [segmentedControl setCell: [[[ToolbarSegmentedCell alloc] init] autorelease]];
    35963646        [groupItem setView: segmentedControl];
    35973647        NSSegmentedCell * segmentedCell = (NSSegmentedCell *)[segmentedControl cell];
     
    36243674                                        NSLocalizedString(@"Resume Selected", "Selected toolbar item -> label"), nil]];
    36253675       
     3676        [segmentedControl release];
    36263677       
    36273678        [groupItem setVisibilityPriority: NSToolbarItemVisibilityPriorityHigh];
    36283679       
    3629         return groupItem;
     3680        return [groupItem autorelease];
    36303681    }
    36313682    else if ([ident isEqualToString: TOOLBAR_FILTER])
     
    42254276    [menu addItemWithTitle: NSLocalizedString(@"Speed Limit", "Dock item") action: @selector(toggleSpeedLimit:) keyEquivalent: @""];
    42264277   
    4227     return menu;
     4278    return [menu autorelease];
    42284279}
    42294280
     
    43884439                if (torrentStruct == [torrent torrentStruct])
    43894440                {
     4441                    [torrent retain];
    43904442                    break;
    43914443                }
     
    44024454            case TR_RPC_TORRENT_ADDED:
    44034455                [self performSelectorOnMainThread: @selector(rpcAddTorrentStruct:) withObject:
    4404                     [NSValue valueWithPointer: torrentStruct] waitUntilDone: NO];
     4456                    [[NSValue valueWithPointer: torrentStruct] retain] waitUntilDone: NO];
    44054457                break;
    44064458           
     
    44414493            default:
    44424494                NSAssert1(NO, @"Unknown RPC command received: %d", type);
     4495                [torrent release];
    44434496        }
    44444497    }
     
    44484501{
    44494502    tr_torrent * torrentStruct = (tr_torrent *)[torrentStructPtr pointerValue];
     4503    [torrentStructPtr release];
    44504504   
    44514505    NSString * location = nil;
     
    44644518    [torrent update];
    44654519    [fTorrents addObject: torrent];
     4520    [torrent release];
    44664521   
    44674522    if (!fAddingTransfers)
     
    44744529- (void) rpcRemoveTorrent: (Torrent *) torrent
    44754530{
    4476     [self confirmRemoveTorrents: [NSArray arrayWithObject: torrent] deleteData: NO];
     4531    [self confirmRemoveTorrents: [[NSArray arrayWithObject: torrent] retain] deleteData: NO];
     4532    [torrent release];
    44774533}
    44784534
    44794535- (void) rpcRemoveTorrentDeleteData: (Torrent *) torrent
    44804536{
    4481     [self confirmRemoveTorrents: [NSArray arrayWithObject: torrent] deleteData: YES];
     4537    [self confirmRemoveTorrents: [[NSArray arrayWithObject: torrent] retain] deleteData: YES];
     4538    [torrent release];
    44824539}
    44834540
     
    44854542{
    44864543    [torrent update];
     4544    [torrent release];
    44874545   
    44884546    [self updateUI];
     
    45014559    }
    45024560   
     4561    [torrent release];
    45034562}
    45044563
     
    45114570        [fInfoController updateInfoStats];
    45124571   
     4572    [torrent release];
    45134573}
    45144574
Note: See TracChangeset for help on using the changeset viewer.