Merge pull request #2093 from dreampiggy/fix_completion_block_memory_called_next_runloop
Fix that completion block and set image block are called asynchronously for UIView+WebCache
This commit is contained in:
commit
821c2f3b8a
|
@ -99,11 +99,15 @@ typedef void(^SDWebImageNoParamsBlock)(void);
|
|||
|
||||
FOUNDATION_EXPORT NSString *const SDWebImageErrorDomain;
|
||||
|
||||
#ifndef dispatch_main_async_safe
|
||||
#define dispatch_main_async_safe(block)\
|
||||
if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(dispatch_get_main_queue())) == 0) {\
|
||||
#ifndef dispatch_queue_async_safe
|
||||
#define dispatch_queue_async_safe(queue, block)\
|
||||
if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(queue)) == 0) {\
|
||||
block();\
|
||||
} else {\
|
||||
dispatch_async(dispatch_get_main_queue(), block);\
|
||||
dispatch_async(queue, block);\
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef dispatch_main_async_safe
|
||||
#define dispatch_main_async_safe(block) dispatch_queue_async_safe(dispatch_get_main_queue(), block)
|
||||
#endif
|
||||
|
|
|
@ -106,7 +106,7 @@ static char TAG_ACTIVITY_SHOW;
|
|||
}
|
||||
dispatch_queue_t targetQueue = shouldUseGlobalQueue ? dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0) : dispatch_get_main_queue();
|
||||
|
||||
dispatch_async(targetQueue, ^{
|
||||
dispatch_queue_async_safe(targetQueue, ^{
|
||||
[sself sd_setImage:targetImage imageData:targetData basedOnClassOrViaCustomSetImageBlock:setImageBlock];
|
||||
dispatch_main_async_safe(callCompletedBlockClojure);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue