Committed by
GitHub
Merge pull request #2154 from dreampiggy/improve_avoid_invalidate_shared_downloader
Avoid user accidentally invalidates the session used in shared downloader
Showing
2 changed files
with
4 additions
and
0 deletions
@@ -250,6 +250,7 @@ typedef SDHTTPHeadersDictionary * _Nullable (^SDWebImageDownloaderHeadersFilterB | @@ -250,6 +250,7 @@ typedef SDHTTPHeadersDictionary * _Nullable (^SDWebImageDownloaderHeadersFilterB | ||
250 | * Invalidates the managed session, optionally canceling pending operations. | 250 | * Invalidates the managed session, optionally canceling pending operations. |
251 | * @note If you use custom downloader instead of the shared downloader, you need call this method when you do not use it to avoid memory leak | 251 | * @note If you use custom downloader instead of the shared downloader, you need call this method when you do not use it to avoid memory leak |
252 | * @param cancelPendingOperations Whether or not to cancel pending operations. | 252 | * @param cancelPendingOperations Whether or not to cancel pending operations. |
253 | + * @note Calling this method on the shared downloader has no effect. | ||
253 | */ | 254 | */ |
254 | - (void)invalidateSessionAndCancel:(BOOL)cancelPendingOperations; | 255 | - (void)invalidateSessionAndCancel:(BOOL)cancelPendingOperations; |
255 | 256 |
@@ -108,6 +108,9 @@ | @@ -108,6 +108,9 @@ | ||
108 | } | 108 | } |
109 | 109 | ||
110 | - (void)invalidateSessionAndCancel:(BOOL)cancelPendingOperations { | 110 | - (void)invalidateSessionAndCancel:(BOOL)cancelPendingOperations { |
111 | + if (self == [SDWebImageDownloader sharedDownloader]) { | ||
112 | + return; | ||
113 | + } | ||
111 | if (cancelPendingOperations) { | 114 | if (cancelPendingOperations) { |
112 | [self.session invalidateAndCancel]; | 115 | [self.session invalidateAndCancel]; |
113 | } else { | 116 | } else { |
-
Please register or login to post a comment