1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-24 16:52:39 +00:00

fix some memory leaks and crashing when opening by dragging

This commit is contained in:
Mitchell Livingston 2007-06-28 01:36:30 +00:00
parent 831cd4a3da
commit 96e1688e6f
2 changed files with 20 additions and 16 deletions

View file

@ -774,19 +774,23 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
NSString * torrentPath;
int canAdd;
tr_info_t info;
do
while ([files count] > 0)
{
if ([files count] == 0) //no files left to open
{
[files release];
torrentPath = [files objectAtIndex: 0];
if (tr_torrentParse(fLib, [torrentPath UTF8String], NULL, &info) == TR_OK)
break;
[self updateTorrentHistory];
return;
}
torrentPath = [[files objectAtIndex: 0] retain];
tr_metainfoFree(&info);
[files removeObjectAtIndex: 0];
} while (tr_torrentParse(fLib, [torrentPath UTF8String], NULL, &info) != TR_OK);
}
//no files left to open
if ([files count] <= 0)
{
[files release];
[self updateTorrentHistory];
return;
}
NSOpenPanel * panel = [NSOpenPanel openPanel];
@ -800,9 +804,9 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
"Open torrent -> select destination folder"), [NSString stringWithUTF8String: info.name]]];
[panel setMessage: @"Select the download folder "];
NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: torrentPath, @"Path",
NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: [torrentPath retain], @"Path",
files, @"Files", [NSNumber numberWithBool: delete], @"Delete", nil];
[torrentPath release];
tr_metainfoFree(&info);
[panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: fWindow modalDelegate: self
didEndSelector: @selector(folderChoiceClosed:returnCode:contextInfo:) contextInfo: dictionary];
@ -2202,16 +2206,13 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
NSArray * files = [pasteboard propertyListForType: NSFilenamesPboardType];
NSEnumerator * enumerator = [files objectEnumerator];
NSString * file;
tr_torrent_t * tempTor;
int canAdd;
while ((file = [enumerator nextObject]))
{
canAdd = tr_torrentParse(fLib, [file UTF8String], NULL, NULL);
if (canAdd == TR_OK)
{
tr_torrentClose(tempTor);
[filesToOpen addObject: file];
torrent = YES;
}
else if (canAdd == TR_EDUPLICATE)

View file

@ -84,6 +84,7 @@
NSEnumerator * enumerator = [files objectEnumerator];
tr_info_t info;
while ((file = [enumerator nextObject]))
{
if (tr_torrentParse(fLib, [file UTF8String], NULL, &info) == TR_OK)
{
count++;
@ -97,6 +98,8 @@
folder = info.multifile;
}
}
tr_metainfoFree(&info);
}
if (count <= 0)
return;