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,19 +774,23 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
NSString * torrentPath;
|
NSString * torrentPath;
|
||||||
int canAdd;
|
int canAdd;
|
||||||
tr_info_t info;
|
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)
|
||||||
[files release];
|
break;
|
||||||
|
|
||||||
[self updateTorrentHistory];
|
tr_metainfoFree(&info);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
torrentPath = [[files objectAtIndex: 0] retain];
|
|
||||||
[files removeObjectAtIndex: 0];
|
[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];
|
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]]];
|
"Open torrent -> select destination folder"), [NSString stringWithUTF8String: info.name]]];
|
||||||
[panel setMessage: @"Select the download folder "];
|
[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];
|
files, @"Files", [NSNumber numberWithBool: delete], @"Delete", nil];
|
||||||
[torrentPath release];
|
tr_metainfoFree(&info);
|
||||||
|
|
||||||
[panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: fWindow modalDelegate: self
|
[panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: fWindow modalDelegate: self
|
||||||
didEndSelector: @selector(folderChoiceClosed:returnCode:contextInfo:) contextInfo: dictionary];
|
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];
|
NSArray * files = [pasteboard propertyListForType: NSFilenamesPboardType];
|
||||||
NSEnumerator * enumerator = [files objectEnumerator];
|
NSEnumerator * enumerator = [files objectEnumerator];
|
||||||
NSString * file;
|
NSString * file;
|
||||||
tr_torrent_t * tempTor;
|
|
||||||
int canAdd;
|
int canAdd;
|
||||||
while ((file = [enumerator nextObject]))
|
while ((file = [enumerator nextObject]))
|
||||||
{
|
{
|
||||||
canAdd = tr_torrentParse(fLib, [file UTF8String], NULL, NULL);
|
canAdd = tr_torrentParse(fLib, [file UTF8String], NULL, NULL);
|
||||||
if (canAdd == TR_OK)
|
if (canAdd == TR_OK)
|
||||||
{
|
{
|
||||||
tr_torrentClose(tempTor);
|
|
||||||
[filesToOpen addObject: file];
|
[filesToOpen addObject: file];
|
||||||
|
|
||||||
torrent = YES;
|
torrent = YES;
|
||||||
}
|
}
|
||||||
else if (canAdd == TR_EDUPLICATE)
|
else if (canAdd == TR_EDUPLICATE)
|
||||||
|
|
|
@ -84,6 +84,7 @@
|
||||||
NSEnumerator * enumerator = [files objectEnumerator];
|
NSEnumerator * enumerator = [files objectEnumerator];
|
||||||
tr_info_t info;
|
tr_info_t info;
|
||||||
while ((file = [enumerator nextObject]))
|
while ((file = [enumerator nextObject]))
|
||||||
|
{
|
||||||
if (tr_torrentParse(fLib, [file UTF8String], NULL, &info) == TR_OK)
|
if (tr_torrentParse(fLib, [file UTF8String], NULL, &info) == TR_OK)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
|
@ -97,6 +98,8 @@
|
||||||
folder = info.multifile;
|
folder = info.multifile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tr_metainfoFree(&info);
|
||||||
|
}
|
||||||
|
|
||||||
if (count <= 0)
|
if (count <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue