Replaced #1537 - fixed a potential retain cycle in `SDWebImageManager`.
Showing
1 changed file
with
3 additions
and
2 deletions
@@ -168,7 +168,7 @@ | @@ -168,7 +168,7 @@ | ||
168 | // ignore image read from NSURLCache if image if cached but force refreshing | 168 | // ignore image read from NSURLCache if image if cached but force refreshing |
169 | downloaderOptions |= SDWebImageDownloaderIgnoreCachedResponse; | 169 | downloaderOptions |= SDWebImageDownloaderIgnoreCachedResponse; |
170 | } | 170 | } |
171 | - id subOperation = [self.imageDownloader downloadImageWithURL:url options:downloaderOptions progress:progressBlock completed:^(UIImage *downloadedImage, NSData *downloadedData, NSError *error, BOOL finished) { | 171 | + SDWebImageDownloadToken *subOperationToken = [self.imageDownloader downloadImageWithURL:url options:downloaderOptions progress:progressBlock completed:^(UIImage *downloadedImage, NSData *downloadedData, NSError *error, BOOL finished) { |
172 | __strong __typeof(weakOperation) strongOperation = weakOperation; | 172 | __strong __typeof(weakOperation) strongOperation = weakOperation; |
173 | if (!strongOperation || strongOperation.isCancelled) { | 173 | if (!strongOperation || strongOperation.isCancelled) { |
174 | // Do nothing if the operation was cancelled | 174 | // Do nothing if the operation was cancelled |
@@ -224,8 +224,9 @@ | @@ -224,8 +224,9 @@ | ||
224 | [self safelyRemoveOperationFromRunning:strongOperation]; | 224 | [self safelyRemoveOperationFromRunning:strongOperation]; |
225 | } | 225 | } |
226 | }]; | 226 | }]; |
227 | + __weak typeof(subOperationToken)weakSubOperationToken = subOperationToken; | ||
227 | operation.cancelBlock = ^{ | 228 | operation.cancelBlock = ^{ |
228 | - [self.imageDownloader cancel:subOperation]; | 229 | + [self.imageDownloader cancel:weakSubOperationToken]; |
229 | __strong __typeof(weakOperation) strongOperation = weakOperation; | 230 | __strong __typeof(weakOperation) strongOperation = weakOperation; |
230 | [self safelyRemoveOperationFromRunning:strongOperation]; | 231 | [self safelyRemoveOperationFromRunning:strongOperation]; |
231 | }; | 232 | }; |
-
Please register or login to post a comment