Skip to content

Commit c3968b3

Browse files
committed
Merge branch 'develop'
* develop: Potential strong cycle fixed. 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. Fixed typo.
2 parents c50be70 + c776527 commit c3968b3

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

Examples/SDWebImage Demo/DetailViewController.m

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ - (void)configureView
3434
if (self.imageURL)
3535
{
3636
__block UIActivityIndicatorView *activityIndicator;
37+
__weak UIImageView *weakImageView = self.imageView;
3738
[self.imageView setImageWithURL:self.imageURL placeholderImage:nil options:SDWebImageProgressiveDownload progress:^(NSUInteger receivedSize, long long expectedSize)
3839
{
3940
if (!activityIndicator)
4041
{
41-
[self.imageView addSubview:activityIndicator = [UIActivityIndicatorView.alloc initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]];
42-
activityIndicator.center = self.imageView.center;
42+
[weakImageView addSubview:activityIndicator = [UIActivityIndicatorView.alloc initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]];
43+
activityIndicator.center = weakImageView.center;
4344
[activityIndicator startAnimating];
4445
}
4546
}

Examples/SDWebImage Demo/MasterViewController.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
333333
nil];
334334
}
335335
[SDWebImageManager.sharedManager.imageDownloader setValue:@"SDWebImage Demo" forHTTPHeaderField:@"AppName"];
336-
SDWebImageManager.sharedManager.imageDownloader.queueMode = SDWebImageDownloaderLIFOQueueMode;
336+
SDWebImageManager.sharedManager.imageDownloader.executionOrder = SDWebImageDownloaderLIFOExecutionOrder;
337337
return self;
338338
}
339339

SDWebImage/SDImageCache.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ enum SDImageCacheType
2020
*/
2121
SDImageCacheTypeDisk,
2222
/**
23-
* The image was obtained from the disk cache.
23+
* The image was obtained from the memory cache.
2424
*/
2525
SDImageCacheTypeMemory
2626
};

SDWebImage/SDWebImageDownloader.h

+11-5
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,15 @@ typedef enum
2828

2929
typedef enum
3030
{
31-
SDWebImageDownloaderFILOQueueMode,
32-
SDWebImageDownloaderLIFOQueueMode
33-
} SDWebImageDownloaderQueueMode;
31+
SDWebImageDownloaderFIFOExecutionOrder,
32+
/**
33+
* Default value. All download operations will execute in queue style (first-in-first-out).
34+
*/
35+
SDWebImageDownloaderLIFOExecutionOrder
36+
/**
37+
* All download operations will execute in stack style (last-in-first-out).
38+
*/
39+
} SDWebImageDownloaderExecutionOrder;
3440

3541
extern NSString *const SDWebImageDownloadStartNotification;
3642
extern NSString *const SDWebImageDownloadStopNotification;
@@ -46,9 +52,9 @@ typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data,
4652
@property (assign, nonatomic) NSInteger maxConcurrentDownloads;
4753

4854
/**
49-
* Changes download operations unqueue mode. Default value is `SDWebImageDownloaderFILOQueueMode`.
55+
* Changes download operations execution order. Default value is `SDWebImageDownloaderFIFOExecutionOrder`.
5056
*/
51-
@property (assign, nonatomic) SDWebImageDownloaderQueueMode queueMode;
57+
@property (assign, nonatomic) SDWebImageDownloaderExecutionOrder executionOrder;
5258

5359
+ (SDWebImageDownloader *)sharedDownloader;
5460

SDWebImage/SDWebImageDownloader.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ - (id)init
6767
{
6868
if ((self = [super init]))
6969
{
70-
_queueMode = SDWebImageDownloaderFILOQueueMode;
70+
_executionOrder = SDWebImageDownloaderFIFOExecutionOrder;
7171
_downloadQueue = NSOperationQueue.new;
7272
_downloadQueue.maxConcurrentOperationCount = 2;
7373
_URLCallbacks = NSMutableDictionary.new;
@@ -158,9 +158,9 @@ - (NSInteger)maxConcurrentDownloads
158158
[sself removeCallbacksForURL:url];
159159
}];
160160
[wself.downloadQueue addOperation:operation];
161-
if (wself.queueMode == SDWebImageDownloaderLIFOQueueMode)
161+
if (wself.executionOrder == SDWebImageDownloaderLIFOExecutionOrder)
162162
{
163-
// Emulate LIFO queue mode by systematically adding new operations as last operation's dependency
163+
// Emulate LIFO execution order by systematically adding new operations as last operation's dependency
164164
[wself.lastAddedOperation addDependency:operation];
165165
wself.lastAddedOperation = operation;
166166
}

0 commit comments

Comments
 (0)