Authored by DreamPiggy

Avoid user accidentally invalidates the session used in shared downloader

@@ -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 {