From ff8d23dacf86cc20da201430d38424fdfffe8793 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Thu, 4 Jan 2018 20:11:20 +0800 Subject: [PATCH] Avoid user accidentally invalidates the session used in shared downloader --- SDWebImage/SDWebImageDownloader.h | 1 + SDWebImage/SDWebImageDownloader.m | 3 +++ 2 files changed, 4 insertions(+) diff --git a/SDWebImage/SDWebImageDownloader.h b/SDWebImage/SDWebImageDownloader.h index ac7e5219..77a0ee8d 100644 --- a/SDWebImage/SDWebImageDownloader.h +++ b/SDWebImage/SDWebImageDownloader.h @@ -250,6 +250,7 @@ typedef SDHTTPHeadersDictionary * _Nullable (^SDWebImageDownloaderHeadersFilterB * 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 * @param cancelPendingOperations Whether or not to cancel pending operations. + * @note Calling this method on the shared downloader has no effect. */ - (void)invalidateSessionAndCancel:(BOOL)cancelPendingOperations; diff --git a/SDWebImage/SDWebImageDownloader.m b/SDWebImage/SDWebImageDownloader.m index 472559ca..3adc937c 100644 --- a/SDWebImage/SDWebImageDownloader.m +++ b/SDWebImage/SDWebImageDownloader.m @@ -108,6 +108,9 @@ } - (void)invalidateSessionAndCancel:(BOOL)cancelPendingOperations { + if (self == [SDWebImageDownloader sharedDownloader]) { + return; + } if (cancelPendingOperations) { [self.session invalidateAndCancel]; } else {