Skip to content

Commit

Permalink
Ensure context is non-null
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettmoon committed Jan 28, 2016
1 parent 4815066 commit 7b002c4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions AsyncDisplayKit/ASImageNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ - (UIImage *)displayWithParameters:(_ASImageNodeDrawParameters *)parameters isCa
}

CGContextRef context = UIGraphicsGetCurrentContext();
if (preContextBlock) {
if (context && preContextBlock) {
preContextBlock(context);
}

Expand All @@ -258,7 +258,7 @@ - (UIImage *)displayWithParameters:(_ASImageNodeDrawParameters *)parameters isCa
[image drawInRect:imageDrawRect];
}

if (postContextBlock) {
if (context && postContextBlock) {
postContextBlock(context);
}

Expand Down
4 changes: 2 additions & 2 deletions AsyncDisplayKit/Private/ASDisplayNode+AsyncDisplay.mm
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ - (asyncdisplaykit_async_transaction_operation_block_t)_displayBlockWithAsynchro
}

CGContextRef currentContext = UIGraphicsGetCurrentContext();
if (_willDisplayNodeContentWithRenderingContext) {
if (currentContext && _willDisplayNodeContentWithRenderingContext) {
_willDisplayNodeContentWithRenderingContext(currentContext);
}

Expand All @@ -284,7 +284,7 @@ - (asyncdisplaykit_async_transaction_operation_block_t)_displayBlockWithAsynchro
[[self class] drawRect:bounds withParameters:drawParameters isCancelled:isCancelledBlock isRasterizing:rasterizing];
}

if (_didDisplayNodeContentWithRenderingContext) {
if (currentContext && _didDisplayNodeContentWithRenderingContext) {
_didDisplayNodeContentWithRenderingContext(currentContext);
}

Expand Down

0 comments on commit 7b002c4

Please sign in to comment.