Skip to content

Commit

Permalink
don't attempt to render pages at size (0, 0)
Browse files Browse the repository at this point in the history
  • Loading branch information
brow committed Sep 17, 2013
1 parent 326930b commit b4f6f23
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Leaves/LeavesCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ - (void) dealloc


- (CGImageRef) imageForPageIndex:(NSUInteger)pageIndex {
if (CGSizeEqualToSize(pageSize, CGSizeZero))
return NULL;

CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL,
pageSize.width,
Expand Down Expand Up @@ -61,10 +64,12 @@ - (CGImageRef) cachedImageForPageIndex:(NSUInteger)pageIndex {
}
if (!pageImage) {
CGImageRef pageCGImage = [self imageForPageIndex:pageIndex];
pageImage = [UIImage imageWithCGImage:pageCGImage];
@synchronized (pageCache) {
[pageCache setObject:pageImage forKey:pageIndexNumber];
}
if (pageCGImage) {
pageImage = [UIImage imageWithCGImage:pageCGImage];
@synchronized (pageCache) {
[pageCache setObject:pageImage forKey:pageIndexNumber];
}
}
}
return pageImage.CGImage;
}
Expand Down

0 comments on commit b4f6f23

Please sign in to comment.