From 6284e4070d97109cce1b8a3e9779bc007725ec4b Mon Sep 17 00:00:00 2001 From: Andrew Vyazovoy Date: Wed, 27 Mar 2013 22:33:20 +0700 Subject: [PATCH 1/3] Fixed typo. --- SDWebImage/SDImageCache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDWebImage/SDImageCache.h b/SDWebImage/SDImageCache.h index 1c50fdd1..5b5fcd65 100644 --- a/SDWebImage/SDImageCache.h +++ b/SDWebImage/SDImageCache.h @@ -20,7 +20,7 @@ enum SDImageCacheType */ SDImageCacheTypeDisk, /** - * The image was obtained from the disk cache. + * The image was obtained from the memory cache. */ SDImageCacheTypeMemory }; From ee9af6406cc52fccaac75fd760d28ca6ee7fb86a Mon Sep 17 00:00:00 2001 From: Andrew Vyazovoy Date: Wed, 27 Mar 2013 23:43:42 +0700 Subject: [PATCH 2/3] SDWebImageDownloaderQueueMode type renamed. Fixed typo. Added description for renamed type. Type renamed because "queue" notion is a FIFO only, but LIFO is a stack, and if we give the type a neutral name, we can avoid logical inconsistencies. --- Examples/SDWebImage Demo/MasterViewController.m | 2 +- SDWebImage/SDWebImageDownloader.h | 16 +++++++++++----- SDWebImage/SDWebImageDownloader.m | 6 +++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Examples/SDWebImage Demo/MasterViewController.m b/Examples/SDWebImage Demo/MasterViewController.m index 8d7edba4..4fd6ce3e 100644 --- a/Examples/SDWebImage Demo/MasterViewController.m +++ b/Examples/SDWebImage Demo/MasterViewController.m @@ -333,7 +333,7 @@ nil]; } [SDWebImageManager.sharedManager.imageDownloader setValue:@"SDWebImage Demo" forHTTPHeaderField:@"AppName"]; - SDWebImageManager.sharedManager.imageDownloader.queueMode = SDWebImageDownloaderLIFOQueueMode; + SDWebImageManager.sharedManager.imageDownloader.executionOrder = SDWebImageDownloaderLIFOExecutionOrder; return self; } diff --git a/SDWebImage/SDWebImageDownloader.h b/SDWebImage/SDWebImageDownloader.h index 3fdf9480..7f5ff0c6 100644 --- a/SDWebImage/SDWebImageDownloader.h +++ b/SDWebImage/SDWebImageDownloader.h @@ -28,9 +28,15 @@ typedef enum typedef enum { - SDWebImageDownloaderFILOQueueMode, - SDWebImageDownloaderLIFOQueueMode -} SDWebImageDownloaderQueueMode; + SDWebImageDownloaderFIFOExecutionOrder, + /** + * Default value. All download operations will execute in queue style (first-in-first-out). + */ + SDWebImageDownloaderLIFOExecutionOrder + /** + * All download operations will execute in stack style (last-in-first-out). + */ +} SDWebImageDownloaderExecutionOrder; extern NSString *const SDWebImageDownloadStartNotification; extern NSString *const SDWebImageDownloadStopNotification; @@ -46,9 +52,9 @@ typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data, @property (assign, nonatomic) NSInteger maxConcurrentDownloads; /** - * Changes download operations unqueue mode. Default value is `SDWebImageDownloaderFILOQueueMode`. + * Changes download operations execution order. Default value is `SDWebImageDownloaderFIFOExecutionOrder`. */ -@property (assign, nonatomic) SDWebImageDownloaderQueueMode queueMode; +@property (assign, nonatomic) SDWebImageDownloaderExecutionOrder executionOrder; + (SDWebImageDownloader *)sharedDownloader; diff --git a/SDWebImage/SDWebImageDownloader.m b/SDWebImage/SDWebImageDownloader.m index ae8c9eb0..af17cd23 100644 --- a/SDWebImage/SDWebImageDownloader.m +++ b/SDWebImage/SDWebImageDownloader.m @@ -67,7 +67,7 @@ static NSString *const kCompletedCallbackKey = @"completed"; { if ((self = [super init])) { - _queueMode = SDWebImageDownloaderFILOQueueMode; + _executionOrder = SDWebImageDownloaderFIFOExecutionOrder; _downloadQueue = NSOperationQueue.new; _downloadQueue.maxConcurrentOperationCount = 2; _URLCallbacks = NSMutableDictionary.new; @@ -158,9 +158,9 @@ static NSString *const kCompletedCallbackKey = @"completed"; [sself removeCallbacksForURL:url]; }]; [wself.downloadQueue addOperation:operation]; - if (wself.queueMode == SDWebImageDownloaderLIFOQueueMode) + if (wself.executionOrder == SDWebImageDownloaderLIFOExecutionOrder) { - // Emulate LIFO queue mode by systematically adding new operations as last operation's dependency + // Emulate LIFO execution order by systematically adding new operations as last operation's dependency [wself.lastAddedOperation addDependency:operation]; wself.lastAddedOperation = operation; } From c77652755a347aca3bb55be29687239a40c461d4 Mon Sep 17 00:00:00 2001 From: Andrew Vyazovoy Date: Wed, 27 Mar 2013 23:44:47 +0700 Subject: [PATCH 3/3] Potential strong cycle fixed. --- Examples/SDWebImage Demo/DetailViewController.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Examples/SDWebImage Demo/DetailViewController.m b/Examples/SDWebImage Demo/DetailViewController.m index 0d23f88f..18952975 100644 --- a/Examples/SDWebImage Demo/DetailViewController.m +++ b/Examples/SDWebImage Demo/DetailViewController.m @@ -34,12 +34,13 @@ if (self.imageURL) { __block UIActivityIndicatorView *activityIndicator; + __weak UIImageView *weakImageView = self.imageView; [self.imageView setImageWithURL:self.imageURL placeholderImage:nil options:SDWebImageProgressiveDownload progress:^(NSUInteger receivedSize, long long expectedSize) { if (!activityIndicator) { - [self.imageView addSubview:activityIndicator = [UIActivityIndicatorView.alloc initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]]; - activityIndicator.center = self.imageView.center; + [weakImageView addSubview:activityIndicator = [UIActivityIndicatorView.alloc initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]]; + activityIndicator.center = weakImageView.center; [activityIndicator startAnimating]; } }