From 0d7316face69fdc064634e447c5e88eef50866c7 Mon Sep 17 00:00:00 2001 From: jverkoey Date: Tue, 26 Jul 2011 15:43:46 -0700 Subject: [PATCH] [networkimage] Explicitly clear the delegate and cancel the operation. clearDelegatesAndCancel acquires a lock and may block the application's main thread. --- src/networkimage/src/NINetworkImageView.m | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/networkimage/src/NINetworkImageView.m b/src/networkimage/src/NINetworkImageView.m index 519da74de..69aae4e46 100644 --- a/src/networkimage/src/NINetworkImageView.m +++ b/src/networkimage/src/NINetworkImageView.m @@ -68,11 +68,11 @@ @implementation NINetworkImageView - (void)cancelOperation { if ([self.operation isKindOfClass:[ASIHTTPRequest class]]) { ASIHTTPRequest* request = (ASIHTTPRequest *)self.operation; - [request clearDelegatesAndCancel]; - - } else { - [self.operation cancel]; + // Clear the delegate so that we don't receive a didFail notification when we cancel the + // operation. + request.delegate = nil; } + [self.operation cancel]; } @@ -189,9 +189,7 @@ - (void)_didFinishLoadingWithImage: (UIImage *)image contentMode: contentMode scaleOptions: scaleOptions]; - // Store the image in the memory cache, possibly with an expiration date. The expiration - // date will allow the image to be released from memory if it expires whenever we receive - // a memory warning. + // Store the image in the memory cache, possibly with an expiration date. [self.imageMemoryCache storeObject: image withName: cacheKey expiresAfter: expirationDate];