Skip to content

Commit

Permalink
fix dispatch_semaphore_wait not nil bug
Browse files Browse the repository at this point in the history
  • Loading branch information
xhzengAIB committed Dec 5, 2014
1 parent 80af37b commit 4330fe1
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,24 @@ - (void)configureMessagePhoto:(UIImage *)messagePhoto thumbnailUrl:(NSString *)t
if ([url.absoluteString isEqualToString:thumbnailUrl]) {

if (CGRectEqualToRect(weakSelf.bounds, CGRectZero)) {
weakSelf.semaphore = dispatch_semaphore_create(0);
dispatch_semaphore_wait(weakSelf.semaphore, DISPATCH_TIME_FOREVER);
weakSelf.semaphore = nil;
if (weakSelf) {
weakSelf.semaphore = dispatch_semaphore_create(0);
dispatch_semaphore_wait(weakSelf.semaphore, DISPATCH_TIME_FOREVER);
weakSelf.semaphore = nil;
}
}

image = [image thumbnailImage:CGRectGetWidth(weakSelf.bounds) * 2 transparentBorder:0 cornerRadius:0 interpolationQuality:1.0];
// if image not nil
if (image) {
// scale image
image = [image thumbnailImage:CGRectGetWidth(weakSelf.bounds) * 2 transparentBorder:0 cornerRadius:0 interpolationQuality:1.0];
dispatch_async(dispatch_get_main_queue(), ^{
weakSelf.messagePhoto = image;
[weakSelf.activityIndicatorView stopAnimating];
// if image not nil
if (image) {
// show image
weakSelf.messagePhoto = image;
[weakSelf.activityIndicatorView stopAnimating];
}
});
}
}
Expand Down

0 comments on commit 4330fe1

Please sign in to comment.