From 9546c84f9461dbe6b3fb58a3d55ae9b2ebe28b8f Mon Sep 17 00:00:00 2001 From: Matej Bukovinski Date: Mon, 19 Nov 2012 13:43:25 +0100 Subject: [PATCH] Making sure cache queries always callback in the main thread. - queryDiskCacheForKey:done: now always invokes the callback in the main thread - removed the now redundant main thread dispatch in the image manager class --- SDWebImage/SDImageCache.m | 6 ++++-- SDWebImage/SDWebImageManager.m | 7 ++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/SDWebImage/SDImageCache.m b/SDWebImage/SDImageCache.m index 47612df9..95a11a82 100644 --- a/SDWebImage/SDImageCache.m +++ b/SDWebImage/SDImageCache.m @@ -189,8 +189,10 @@ static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week [self.memCache setObject:diskImage forKey:key cost:image.size.height * image.size.width * image.scale]; } - doneBlock(diskImage, SDImageCacheTypeDisk); - + dispatch_async(dispatch_get_main_queue(), ^ + { + doneBlock(diskImage, SDImageCacheTypeDisk); + }); }); } diff --git a/SDWebImage/SDWebImageManager.m b/SDWebImage/SDWebImageManager.m index 29c6f00e..cb38493b 100644 --- a/SDWebImage/SDWebImageManager.m +++ b/SDWebImage/SDWebImageManager.m @@ -86,11 +86,8 @@ if (image) { - dispatch_async(dispatch_get_main_queue(), ^ - { - completedBlock(image, nil, cacheType, YES); - [self.runningOperations removeObject:operation]; - }); + completedBlock(image, nil, cacheType, YES); + [self.runningOperations removeObject:operation]; } else {