Changeset 2225


Ignore:
Timestamp:
Jun 29, 2007, 1:49:41 AM (15 years ago)
Author:
livings124
Message:

hopefully fix a nasty memory leak and a bunch of redundant code

Location:
trunk/macosx
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r2223 r2225  
    312312                [fTorrents addObject: torrent];
    313313                [torrent release];
    314                 NSLog(@"%u", (long)[torrent retainCount]);
     314                NSLog(@"history restore: %u", (long)[torrent retainCount]);
    315315            }
    316316       
     
    552552   
    553553    enumerator = [fTorrents objectEnumerator];
    554     Torrent * torrent;
    555     while ((torrent = [enumerator nextObject]))
    556         [torrent endTorrent];
     554    //Torrent * torrent;
     555    /*while ((torrent = [enumerator nextObject]))
     556        [torrent endTorrent];*/
    557557   
    558558    [fTorrents removeAllObjects];
     
    11251125        if (!lowestOrderValue || [lowestOrderValue compare: currentOrderValue] == NSOrderedDescending)
    11261126            lowestOrderValue = currentOrderValue;
    1127        
     1127        NSLog(@"before");
    11281128        [fTorrents removeObject: torrent];
    1129         [fDisplayedTorrents removeObject: torrent];
    1130         [torrent endTorrent];
     1129        [fDisplayedTorrents removeObject: torrent];NSLog(@"after");
    11311130    }
    11321131    [torrents release];
  • trunk/macosx/FileOutlineView.m

    r2191 r2225  
    2525#import "FileOutlineView.h"
    2626#import "FileBrowserCell.h"
     27#import "InfoWindowController.h"
    2728#import "Torrent.h"
    2829
     
    104105        NSDictionary * item = [self itemAtRow: row];
    105106        if ([[item objectForKey: @"IsFolder"] boolValue]
    106                 || ![[item objectForKey: @"Torrent"] canChangeDownloadCheckForFiles: [item objectForKey: @"Indexes"]])
     107                || ![[(InfoWindowController *)[[self window] windowController] selectedTorrent]
     108                        canChangeDownloadCheckForFiles: [item objectForKey: @"Indexes"]])
    107109            [fNormalColor set];
    108110        else
     
    132134    NSDictionary * item;
    133135    int i, priority;
     136    Torrent * torrent = [(InfoWindowController *)[[self window] windowController] selectedTorrent];
    134137    for (i = 0; i < [self numberOfRows]; i++)
    135138    {
     
    138141            item = [self itemAtRow: i];
    139142            if (![[item objectForKey: @"IsFolder"] boolValue]
    140                 && [[item objectForKey: @"Torrent"] canChangeDownloadCheckForFiles: [item objectForKey: @"Indexes"]])
     143                && [torrent canChangeDownloadCheckForFiles: [item objectForKey: @"Indexes"]])
    141144            {
    142145                priority = [[item objectForKey: @"Priority"] intValue];
  • trunk/macosx/FilePriorityCell.m

    r2192 r2225  
    11#import "FilePriorityCell.h"
     2#import "InfoWindowController.h"
    23#import "Torrent.h"
    34
     
    3233   
    3334    //only for when clicking manually
    34     Torrent * torrent = [fItem objectForKey: @"Torrent"];
     35    Torrent * torrent = [[[[self controlView] window] windowController] selectedTorrent];
    3536    NSIndexSet * indexes = [fItem objectForKey: @"Indexes"];
    3637    if (![torrent canChangeDownloadCheckForFiles: indexes])
     
    5152- (void) drawWithFrame: (NSRect) cellFrame inView: (NSView *) controlView
    5253{
    53     Torrent * torrent = [fItem objectForKey: @"Torrent"];
     54    Torrent * torrent = [(InfoWindowController *)[[[self controlView] window] windowController] selectedTorrent];
    5455    NSIndexSet * indexSet = [fItem objectForKey: @"Indexes"];
    5556   
  • trunk/macosx/InfoWindowController.h

    r2189 r2225  
    6767
    6868- (void) updateInfoForTorrents: (NSArray *) torrents;
     69- (Torrent *) selectedTorrent;
    6970- (void) updateInfoStats;
    7071
  • trunk/macosx/InfoWindowController.m

    r2199 r2225  
    310310}
    311311
     312- (Torrent *) selectedTorrent
     313{
     314    return fTorrents && [fTorrents count] > 0 ? [fTorrents objectAtIndex: 0] : nil;
     315}
     316
    312317- (void) updateInfoStats
    313318{
  • trunk/macosx/Torrent.h

    r2223 r2225  
    4040   
    4141    int fID;
    42     BOOL fInitialized;
    4342   
    4443    BOOL         fResumeOnWake;
     
    7675
    7776- (NSDictionary *) history;
    78 
    79 - (void) endTorrent;
    8077
    8178- (void) changeIncompleteDownloadFolder: (NSString *) folder;
  • trunk/macosx/Torrent.m

    r2223 r2225  
    189189}
    190190
    191 #warning need for now :(
    192 - (void) endTorrent
    193 {
    194     if (fInitialized)
    195     {
    196         tr_torrentClose(fHandle);
    197         fInitialized = NO;
    198     }
    199 }
    200 
    201191- (void) dealloc
    202192{
     
    205195    if (fHandle)
    206196    {
    207         if (fInitialized)
    208             tr_torrentClose(fHandle);
     197        tr_torrentClose(fHandle);
    209198       
    210199        if (fDownloadFolder)
     
    14861475        filesShouldDownload: (NSArray *) filesShouldDownload filePriorities: (NSArray *) filePriorities;
    14871476{
    1488     fInitialized = NO;
    14891477    if (!(self = [super init]))
    14901478        return nil;
    14911479   
    1492     NSLog(@"%d", (long)[self retainCount]);
     1480    NSLog(@"init %d", (long)[self retainCount]);
    14931481    static_lastid++;
    14941482    fID = static_lastid;
     
    15411529        return nil;
    15421530    }
    1543     fInitialized = YES;
    15441531   
    15451532    fInfo = tr_torrentInfo(fHandle);
     
    16011588    for (i = 0; i < MAX_PIECES; i++)
    16021589        fPieces[i] = BLANK_PIECE;
    1603 
     1590    NSLog(@"end1 %d", (long)[self retainCount]);
    16041591    [self update];
     1592    NSLog(@"end2 %d", (long)[self retainCount]);
    16051593    return self;
    16061594}
     
    16821670        [siblings addObject: dict];
    16831671       
    1684         [dict setObject: self forKey: @"Torrent"];
    16851672        if (isFolder)
    16861673        {
Note: See TracChangeset for help on using the changeset viewer.