From cb407367bedb91eef6c4a78ff60b6974421068fe Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Wed, 7 Oct 2015 10:08:54 -0700 Subject: [PATCH] Cancel image requests in ASMultiplexImageNode.clearFetchedData --- AsyncDisplayKit/ASMultiplexImageNode.mm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/AsyncDisplayKit/ASMultiplexImageNode.mm b/AsyncDisplayKit/ASMultiplexImageNode.mm index 06ecd298c2..648c9bb7a0 100644 --- a/AsyncDisplayKit/ASMultiplexImageNode.mm +++ b/AsyncDisplayKit/ASMultiplexImageNode.mm @@ -170,7 +170,8 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent return [self initWithCache:nil downloader:nil]; // satisfy compiler } -- (void)dealloc { +- (void)dealloc +{ [_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. [self _setDisplayedImageIdentifier:nil withImage:nil]; - if (_phImageRequestOperation) { - [_phImageRequestOperation cancel]; - _phImageRequestOperation = nil; - } + [_phImageRequestOperation cancel]; if (_downloadIdentifier) { [_downloader cancelImageDownloadForIdentifier:_downloadIdentifier]; @@ -196,6 +194,14 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent [super clearFetchedData]; 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 _loadedImageIdentifier = nil; self.image = nil;