Cancel image requests in ASMultiplexImageNode.clearFetchedData

This commit is contained in:
Adlai Holler
2015-10-07 10:08:54 -07:00
parent cdfd5c1fdd
commit cb407367be

View File

@@ -170,7 +170,8 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
return [self initWithCache:nil downloader:nil]; // satisfy compiler return [self initWithCache:nil downloader:nil]; // satisfy compiler
} }
- (void)dealloc { - (void)dealloc
{
[_phImageRequestOperation cancel]; [_phImageRequestOperation cancel];
} }
@@ -180,10 +181,7 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
[super clearContents]; // This actually clears the contents, so we need to do this first for our displayedImageIdentifier to be meaningful. [super clearContents]; // This actually clears the contents, so we need to do this first for our displayedImageIdentifier to be meaningful.
[self _setDisplayedImageIdentifier:nil withImage:nil]; [self _setDisplayedImageIdentifier:nil withImage:nil];
if (_phImageRequestOperation) {
[_phImageRequestOperation cancel]; [_phImageRequestOperation cancel];
_phImageRequestOperation = nil;
}
if (_downloadIdentifier) { if (_downloadIdentifier) {
[_downloader cancelImageDownloadForIdentifier:_downloadIdentifier]; [_downloader cancelImageDownloadForIdentifier:_downloadIdentifier];
@@ -196,6 +194,14 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
[super clearFetchedData]; [super clearFetchedData];
if ([self _shouldClearFetchedImageData]) { if ([self _shouldClearFetchedImageData]) {
[_phImageRequestOperation cancel];
if (_downloadIdentifier) {
[_downloader cancelImageDownloadForIdentifier:_downloadIdentifier];
_downloadIdentifier = nil;
}
// setting this to nil makes the node fetch images the next time its display starts // setting this to nil makes the node fetch images the next time its display starts
_loadedImageIdentifier = nil; _loadedImageIdentifier = nil;
self.image = nil; self.image = nil;