2
0
Эх сурвалжийг харах

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 9 жил өмнө
parent
commit
55a9ca4771

+ 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)
     }