Merge pull request #2154 from dreampiggy/improve_avoid_invalidate_shared_downloader

Avoid user accidentally invalidates the session used in shared downloader
This commit is contained in:
DreamPiggy 2018-01-05 15:10:16 +08:00 committed by GitHub
commit 8f456ff08c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View File

@ -250,6 +250,7 @@ typedef SDHTTPHeadersDictionary * _Nullable (^SDWebImageDownloaderHeadersFilterB
* Invalidates the managed session, optionally canceling pending operations. * Invalidates the managed session, optionally canceling pending operations.
* @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 * @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
* @param cancelPendingOperations Whether or not to cancel pending operations. * @param cancelPendingOperations Whether or not to cancel pending operations.
* @note Calling this method on the shared downloader has no effect.
*/ */
- (void)invalidateSessionAndCancel:(BOOL)cancelPendingOperations; - (void)invalidateSessionAndCancel:(BOOL)cancelPendingOperations;

View File

@ -108,6 +108,9 @@
} }
- (void)invalidateSessionAndCancel:(BOOL)cancelPendingOperations { - (void)invalidateSessionAndCancel:(BOOL)cancelPendingOperations {
if (self == [SDWebImageDownloader sharedDownloader]) {
return;
}
if (cancelPendingOperations) { if (cancelPendingOperations) {
[self.session invalidateAndCancel]; [self.session invalidateAndCancel];
} else { } else {