Skip to content

Commit

Permalink
[networkimage] Explicitly clear the delegate and cancel the operation.
Browse files Browse the repository at this point in the history
clearDelegatesAndCancel acquires a lock and may block the application's
main thread.
  • Loading branch information
jverkoey committed Jul 26, 2011
1 parent c9132eb commit 0d7316f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/networkimage/src/NINetworkImageView.m
Expand Up @@ -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];
}


Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 0d7316f

Please sign in to comment.