Merge pull request #2386 from zhongwuzw/fix-nullable
Fix nullable key when cancel image load operation
This commit is contained in:
commit
dbbfbd715a
|
@ -27,8 +27,7 @@
|
||||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
|
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
|
||||||
|
|
||||||
if (cell == nil) {
|
if (cell == nil) {
|
||||||
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier]
|
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier];
|
||||||
autorelease];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here we use the provided sd_setImageWithURL: method to load the web image
|
// Here we use the provided sd_setImageWithURL: method to load the web image
|
||||||
|
|
|
@ -42,18 +42,21 @@ typedef NSMapTable<NSString *, id<SDWebImageOperation>> SDOperationsDictionary;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)sd_cancelImageLoadOperationWithKey:(nullable NSString *)key {
|
- (void)sd_cancelImageLoadOperationWithKey:(nullable NSString *)key {
|
||||||
// Cancel in progress downloader from queue
|
if (key) {
|
||||||
SDOperationsDictionary *operationDictionary = [self sd_operationDictionary];
|
// Cancel in progress downloader from queue
|
||||||
id<SDWebImageOperation> operation;
|
SDOperationsDictionary *operationDictionary = [self sd_operationDictionary];
|
||||||
@synchronized (self) {
|
id<SDWebImageOperation> operation;
|
||||||
operation = [operationDictionary objectForKey:key];
|
|
||||||
}
|
|
||||||
if (operation) {
|
|
||||||
if ([operation conformsToProtocol:@protocol(SDWebImageOperation)]){
|
|
||||||
[operation cancel];
|
|
||||||
}
|
|
||||||
@synchronized (self) {
|
@synchronized (self) {
|
||||||
[operationDictionary removeObjectForKey:key];
|
operation = [operationDictionary objectForKey:key];
|
||||||
|
}
|
||||||
|
if (operation) {
|
||||||
|
if ([operation conformsToProtocol:@protocol(SDWebImageOperation)]) {
|
||||||
|
[operation cancel];
|
||||||
|
}
|
||||||
|
@synchronized (self) {
|
||||||
|
[operationDictionary removeObjectForKey:key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue