Ignore:
Timestamp:
Mar 13, 2012, 3:39:56 AM (10 years ago)
Author:
livings124
Message:

more changes to make future porting to ARC easier

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r13253 r13254  
    753753        [download cancel];
    754754       
     755        [fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
     756        if ([fPendingTorrentDownloads count] == 0)
     757        {
     758            [fPendingTorrentDownloads release];
     759            fPendingTorrentDownloads = nil;
     760        }
     761       
    755762        NSRunAlertPanel(NSLocalizedString(@"Torrent download failed", "Download not a torrent -> title"),
    756763            [NSString stringWithFormat: NSLocalizedString(@"It appears that the file \"%@\" from %@ is not a torrent file.",
     
    768775-(void) download: (NSURLDownload *) download didCreateDestination: (NSString *) path
    769776{
    770     if (!fPendingTorrentDownloads)
    771         fPendingTorrentDownloads = [[NSMutableDictionary alloc] init];
    772    
    773     [fPendingTorrentDownloads setObject: [NSDictionary dictionaryWithObjectsAndKeys:
    774                     path, @"Path", download, @"Download", nil] forKey: [[download request] URL]];
     777    [(NSMutableDictionary *)[fPendingTorrentDownloads objectForKey: [[download request] URL]] setObject: path forKey: @"Path"];
    775778}
    776779
     
    12041207        NSURLRequest * request = [NSURLRequest requestWithURL: [NSURL URLWithString: urlString]
    12051208                                    cachePolicy: NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval: 60];
    1206         [[NSURLDownload alloc] initWithRequest: request delegate: self];
     1209       
     1210        if ([fPendingTorrentDownloads objectForKey: [request URL]])
     1211        {
     1212            NSLog(@"Already downloading %@", [request URL]);
     1213            return;
     1214        }
     1215       
     1216        NSURLDownload * download = [[NSURLDownload alloc] initWithRequest: request delegate: self];
     1217       
     1218        if (!fPendingTorrentDownloads)
     1219            fPendingTorrentDownloads = [[NSMutableDictionary alloc] init];
     1220        [fPendingTorrentDownloads setObject: [NSMutableDictionary dictionaryWithObject: download forKey: @"Download"] forKey: [request URL]];
    12071221    }
    12081222}
     
    12101224- (void) openURLShowSheet: (id) sender
    12111225{
    1212     [[[URLSheetWindowController alloc] initWithController: self] beginSheetForWindow: fWindow];
    1213 }
    1214 
    1215 - (void) urlSheetDidEnd: (URLSheetWindowController *) controller url: (NSString *) urlString returnCode: (NSInteger) returnCode
     1226    if (!fUrlSheetController)
     1227    {
     1228        fUrlSheetController = [[URLSheetWindowController alloc] initWithController: self];
     1229   
     1230        [NSApp beginSheet: [fUrlSheetController window] modalForWindow: fWindow modalDelegate: self didEndSelector: @selector(urlSheetDidEnd:returnCode:contextInfo:) contextInfo: nil];
     1231    }
     1232}
     1233
     1234- (void) urlSheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
    12161235{
    12171236    if (returnCode == 1)
     1237    {
     1238        NSString * urlString = [fUrlSheetController urlString];
    12181239        [self performSelectorOnMainThread: @selector(openURL:) withObject: urlString waitUntilDone: NO];
    1219    
    1220     [controller release];
     1240    }
     1241   
     1242    [fUrlSheetController release];
     1243    fUrlSheetController = nil;
    12211244}
    12221245
Note: See TracChangeset for help on using the changeset viewer.