Explorar o código

Set the webURL to nil for nil resources

Delete the associated WebURL when a nil `Resource` is set on an ImageView.
This should prevent that the imageView is updated with the wrong image if a download previously started completes after the image is set again to nil.
Pierluigi %!s(int64=9) %!d(string=hai) anos
pai
achega
55a9ca4771
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      Sources/ImageView+Kingfisher.swift

+ 2 - 1
Sources/ImageView+Kingfisher.swift

@@ -59,6 +59,7 @@ extension Kingfisher where Base: ImageView {
     {
         guard let resource = resource else {
             base.image = placeholder
+            setWebURL(nil)
             completionHandler?(nil, nil, .none, nil)
             return .empty
         }
@@ -155,7 +156,7 @@ extension Kingfisher where Base: ImageView {
         return objc_getAssociatedObject(base, &lastURLKey) as? URL
     }
     
-    fileprivate func setWebURL(_ url: URL) {
+    fileprivate func setWebURL(_ url: URL?) {
         objc_setAssociatedObject(base, &lastURLKey, url, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
     }