Quellcode durchsuchen

Revert operation remove logic

zhongwuzw vor 7 Jahren
Ursprung
Commit
593feb664c
1 geänderte Dateien mit 8 neuen und 3 gelöschten Zeilen
  1. 8 3
      SDWebImage/UIView+WebCacheOperation.m

+ 8 - 3
SDWebImage/UIView+WebCacheOperation.m

@@ -46,12 +46,17 @@ typedef NSMapTable<NSString *, id<SDWebImageOperation>> SDOperationsDictionary;
         // Cancel in progress downloader from queue
         SDOperationsDictionary *operationDictionary = [self sd_operationDictionary];
         id<SDWebImageOperation> operation;
+        
         @synchronized (self) {
             operation = [operationDictionary objectForKey:key];
-            [operationDictionary removeObjectForKey:key];
         }
-        if ([operation conformsToProtocol:@protocol(SDWebImageOperation)]) {
-            [operation cancel];
+        if (operation) {
+            if ([operation conformsToProtocol:@protocol(SDWebImageOperation)]) {
+                [operation cancel];
+            }
+            @synchronized (self) {
+                [operationDictionary removeObjectForKey:key];
+            }
         }
     }
 }