Przeglądaj źródła

Merge branch 'refactor_downloader_config' into 5.x

DreamPiggy 8 lat temu
rodzic
commit
00a0e01a32

+ 1 - 0
SDWebImage/SDWebImageDownloaderConfig.h

@@ -25,6 +25,7 @@ typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) {
 
 /**
  Gets/Sets the default downloader config used for shared instance or initialization when it does not provide any downloader config. Such as `SDWebImageDownloader.sharedDownloader`.
+ @note You can modify the property on default downloader config, which can be used for later created downloader instance. The already created downloader instance does not get affected.
  @note You should not pass nil to this value.
  */
 @property (nonatomic, class, nonnull) SDWebImageDownloaderConfig *defaultDownloaderConfig;

+ 3 - 2
SDWebImage/SDWebImageDownloaderConfig.m

@@ -13,9 +13,10 @@ static SDWebImageDownloaderConfig * _defaultDownloaderConfig;
 @implementation SDWebImageDownloaderConfig
 
 + (SDWebImageDownloaderConfig *)defaultDownloaderConfig {
-    if (!_defaultDownloaderConfig) {
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
         _defaultDownloaderConfig = [SDWebImageDownloaderConfig new];
-    }
+    });
     return _defaultDownloaderConfig;
 }