Fix cancel not cancelling connection

This commit is contained in:
Olivier Poitrey 2012-11-06 14:04:12 +01:00
parent cceb56353c
commit 541f3a1284
2 changed files with 3 additions and 4 deletions

View File

@ -91,7 +91,7 @@ NSString *const kCompletedCallbackKey = @"completed";
return _downloadQueue.maxConcurrentOperationCount;
}
- (NSOperation *)downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(void (^)(NSUInteger, long long))progressBlock completed:(void (^)(UIImage *, NSError *, BOOL))completedBlock
- (id<SDWebImageOperation>)downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(void (^)(NSUInteger, long long))progressBlock completed:(void (^)(UIImage *, NSError *, BOOL))completedBlock
{
__block SDWebImageDownloaderOperation *operation;
__weak SDWebImageDownloader *wself = self;
@ -134,13 +134,12 @@ NSString *const kCompletedCallbackKey = @"completed";
[self.downloadQueue addOperation:operation];
}];
return operation;
}
- (void)addProgressCallback:(void (^)(NSUInteger, long long))progressBlock andCompletedBlock:(void (^)(UIImage *, NSError *, BOOL))completedBlock forURL:(NSURL *)url createCallback:(void (^)())createCallback
{
dispatch_barrier_async(self.barrierQueue, ^
dispatch_barrier_sync(self.barrierQueue, ^
{
BOOL first = NO;
if (!self.URLCallbacks[url])

View File

@ -97,7 +97,7 @@
SDWebImageDownloaderOptions downloaderOptions = 0;
if (options & SDWebImageLowPriority) downloaderOptions |= SDWebImageDownloaderLowPriority;
if (options & SDWebImageProgressiveDownload) downloaderOptions |= SDWebImageDownloaderProgressiveDownload;
id<SDWebImageOperation> subOperation = [self.imageDownloader downloadImageWithURL:url options:downloaderOptions progress:progressBlock completed:^(UIImage *downloadedImage, NSError *error, BOOL finished)
__block id<SDWebImageOperation> subOperation = [self.imageDownloader downloadImageWithURL:url options:downloaderOptions progress:progressBlock completed:^(UIImage *downloadedImage, NSError *error, BOOL finished)
{
dispatch_async(dispatch_get_main_queue(), ^
{