From 313fe8ae9421b0eaa554f8de56a2d3f8989d40aa Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Mon, 11 Feb 2013 01:47:51 +0000 Subject: [PATCH] perform the rename callback in the main thread --- macosx/Torrent.m | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 9a0bdc2b6..f0994efd6 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -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) { - @autoreleasepool - { + @autoreleasepool { NSString * oldPath = [NSString stringWithUTF8String: oldPathCharString]; NSString * newName = [NSString stringWithUTF8String: newNameCharString]; - NSDictionary * contextDict = [(NSDictionary *)contextInfo autorelease]; - Torrent * torrentObject = [contextDict objectForKey: @"Torrent"]; - [torrentObject renameFinished: error == 0 withNodes: [contextDict objectForKey: @"Nodes"] completionHandler: [contextDict objectForKey: @"CompletionHandler"] oldPath: oldPath newName: newName]; + dispatch_async(dispatch_get_main_queue(), ^{ + NSDictionary * contextDict = [(NSDictionary *)contextInfo autorelease]; + Torrent * torrentObject = [contextDict objectForKey: @"Torrent"]; + [torrentObject renameFinished: error == 0 withNodes: [contextDict objectForKey: @"Nodes"] completionHandler: [contextDict objectForKey: @"CompletionHandler"] oldPath: oldPath newName: newName]; + }); } }