From 7f03e0453862d7ac95509ef7a48b5f4f188e4f27 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Mon, 4 Mar 2013 04:12:54 +0000 Subject: [PATCH] a tiny bit more safety by assigning the torrent directly, instead of getting the index --- macosx/Controller.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/macosx/Controller.m b/macosx/Controller.m index 0a2847ccc..ba0b79029 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -4740,19 +4740,19 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy @autoreleasepool { //get the torrent - Torrent * torrent = nil; + __block Torrent * torrent = nil; if (torrentStruct != NULL && (type != TR_RPC_TORRENT_ADDED && type != TR_RPC_SESSION_CHANGED && type != TR_RPC_SESSION_CLOSE)) { - const NSUInteger index = [fTorrents indexOfObjectWithOptions:NSEnumerationConcurrent passingTest: ^BOOL(Torrent * checkTorrent, NSUInteger idx, BOOL * stop) { - return torrentStruct == [checkTorrent torrentStruct]; + [fTorrents enumerateObjectsWithOptions: NSEnumerationConcurrent usingBlock: ^(Torrent * checkTorrent, NSUInteger idx, BOOL *stop) { + if (torrentStruct == [checkTorrent torrentStruct]) + torrent = checkTorrent; }]; - if (index == NSNotFound) + if (!torrent) { NSLog(@"No torrent found matching the given torrent struct from the RPC callback!"); return; } - torrent = [fTorrents objectAtIndex: index]; } dispatch_async(dispatch_get_main_queue(), ^{ -- 2.40.0