Changeset 2218


Ignore:
Timestamp:
Jun 28, 2007, 1:36:30 AM (15 years ago)
Author:
livings124
Message:

fix some memory leaks and crashing when opening by dragging

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r2211 r2218  
    775775    int canAdd;
    776776    tr_info_t info;
    777     do
    778     {
    779         if ([files count] == 0) //no files left to open
    780         {
    781             [files release];
    782            
    783             [self updateTorrentHistory];
    784             return;
    785         }
    786    
    787         torrentPath = [[files objectAtIndex: 0] retain];
     777    while ([files count] > 0)
     778    {
     779        torrentPath = [files objectAtIndex: 0];
     780        if (tr_torrentParse(fLib, [torrentPath UTF8String], NULL, &info) == TR_OK)
     781            break;
     782       
     783        tr_metainfoFree(&info);
    788784        [files removeObjectAtIndex: 0];
    789     } while (tr_torrentParse(fLib, [torrentPath UTF8String], NULL, &info) != TR_OK);
     785    }
     786   
     787    //no files left to open
     788    if ([files count] <= 0)
     789    {
     790        [files release];
     791        [self updateTorrentHistory];
     792        return;
     793    }
    790794
    791795    NSOpenPanel * panel = [NSOpenPanel openPanel];
     
    801805    [panel setMessage: @"Select the download folder "];
    802806   
    803     NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: torrentPath, @"Path",
     807    NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: [torrentPath retain], @"Path",
    804808                                    files, @"Files", [NSNumber numberWithBool: delete], @"Delete", nil];
    805     [torrentPath release];
     809    tr_metainfoFree(&info);
    806810   
    807811    [panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: fWindow modalDelegate: self
     
    22032207        NSEnumerator * enumerator = [files objectEnumerator];
    22042208        NSString * file;
    2205         tr_torrent_t * tempTor;
    22062209        int canAdd;
    22072210        while ((file = [enumerator nextObject]))
     
    22102213            if (canAdd == TR_OK)
    22112214            {
    2212                 tr_torrentClose(tempTor);
    22132215                [filesToOpen addObject: file];
    2214                
    22152216                torrent = YES;
    22162217            }
  • trunk/macosx/DragOverlayWindow.m

    r2211 r2218  
    8585    tr_info_t info;
    8686    while ((file = [enumerator nextObject]))
     87    {
    8788        if (tr_torrentParse(fLib, [file UTF8String], NULL, &info) == TR_OK)
    8889        {
     
    9899            }
    99100        }
     101        tr_metainfoFree(&info);
     102    }
    100103   
    101104    if (count <= 0)
Note: See TracChangeset for help on using the changeset viewer.