1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-26 07:52:38 +00:00

perform the rename callback in the main thread

This commit is contained in:
Mitchell Livingston 2013-02-11 01:47:51 +00:00
parent 196bbafadb
commit 313fe8ae94

View file

@ -94,14 +94,15 @@ void metadataCallback(tr_torrent * torrent, void * torrentData)
void renameCallback(tr_torrent * torrent, const char * oldPathCharString, const char * newNameCharString, int error, void * contextInfo) void renameCallback(tr_torrent * torrent, const char * oldPathCharString, const char * newNameCharString, int error, void * contextInfo)
{ {
@autoreleasepool @autoreleasepool {
{
NSString * oldPath = [NSString stringWithUTF8String: oldPathCharString]; NSString * oldPath = [NSString stringWithUTF8String: oldPathCharString];
NSString * newName = [NSString stringWithUTF8String: newNameCharString]; NSString * newName = [NSString stringWithUTF8String: newNameCharString];
dispatch_async(dispatch_get_main_queue(), ^{
NSDictionary * contextDict = [(NSDictionary *)contextInfo autorelease]; NSDictionary * contextDict = [(NSDictionary *)contextInfo autorelease];
Torrent * torrentObject = [contextDict objectForKey: @"Torrent"]; Torrent * torrentObject = [contextDict objectForKey: @"Torrent"];
[torrentObject renameFinished: error == 0 withNodes: [contextDict objectForKey: @"Nodes"] completionHandler: [contextDict objectForKey: @"CompletionHandler"] oldPath: oldPath newName: newName]; [torrentObject renameFinished: error == 0 withNodes: [contextDict objectForKey: @"Nodes"] completionHandler: [contextDict objectForKey: @"CompletionHandler"] oldPath: oldPath newName: newName];
});
} }
} }