Fix that completion block and set image block are called asynchronously in UIView+WebCache. Add a more common macro to do current queue check
This commit is contained in:
parent
b2e5317666
commit
0eff98e4e7
|
@ -99,11 +99,15 @@ typedef void(^SDWebImageNoParamsBlock)(void);
|
||||||
|
|
||||||
FOUNDATION_EXPORT NSString *const SDWebImageErrorDomain;
|
FOUNDATION_EXPORT NSString *const SDWebImageErrorDomain;
|
||||||
|
|
||||||
#ifndef dispatch_main_async_safe
|
#ifndef dispatch_queue_async_safe
|
||||||
#define dispatch_main_async_safe(block)\
|
#define dispatch_queue_async_safe(queue, block)\
|
||||||
if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(dispatch_get_main_queue())) == 0) {\
|
if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(queue)) == 0) {\
|
||||||
block();\
|
block();\
|
||||||
} else {\
|
} else {\
|
||||||
dispatch_async(dispatch_get_main_queue(), block);\
|
dispatch_async(queue, block);\
|
||||||
}
|
}
|
||||||
#endif
|
#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_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];
|
[sself sd_setImage:targetImage imageData:targetData basedOnClassOrViaCustomSetImageBlock:setImageBlock];
|
||||||
dispatch_main_async_safe(callCompletedBlockClojure);
|
dispatch_main_async_safe(callCompletedBlockClojure);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue