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:
parent
831cd4a3da
commit
96e1688e6f
2 changed files with 20 additions and 16 deletions
|
@ -774,20 +774,24 @@ 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
|
||||
torrentPath = [files objectAtIndex: 0];
|
||||
if (tr_torrentParse(fLib, [torrentPath UTF8String], NULL, &info) == TR_OK)
|
||||
break;
|
||||
|
||||
tr_metainfoFree(&info);
|
||||
[files removeObjectAtIndex: 0];
|
||||
}
|
||||
|
||||
//no files left to open
|
||||
if ([files count] <= 0)
|
||||
{
|
||||
[files release];
|
||||
|
||||
[self updateTorrentHistory];
|
||||
return;
|
||||
}
|
||||
|
||||
torrentPath = [[files objectAtIndex: 0] retain];
|
||||
[files removeObjectAtIndex: 0];
|
||||
} while (tr_torrentParse(fLib, [torrentPath UTF8String], NULL, &info) != TR_OK);
|
||||
|
||||
NSOpenPanel * panel = [NSOpenPanel openPanel];
|
||||
|
||||
[panel setPrompt: NSLocalizedString(@"Select", "Open torrent -> prompt")];
|
||||
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue