From 7b002c408df15f1e2c5ccab79fe5003c01e44402 Mon Sep 17 00:00:00 2001 From: Garrett Moon Date: Thu, 28 Jan 2016 08:38:40 -0800 Subject: [PATCH] Ensure context is non-null --- AsyncDisplayKit/ASImageNode.mm | 4 ++-- AsyncDisplayKit/Private/ASDisplayNode+AsyncDisplay.mm | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AsyncDisplayKit/ASImageNode.mm b/AsyncDisplayKit/ASImageNode.mm index d87dea3591..3864ca5ad6 100644 --- a/AsyncDisplayKit/ASImageNode.mm +++ b/AsyncDisplayKit/ASImageNode.mm @@ -238,7 +238,7 @@ - (UIImage *)displayWithParameters:(_ASImageNodeDrawParameters *)parameters isCa } CGContextRef context = UIGraphicsGetCurrentContext(); - if (preContextBlock) { + if (context && preContextBlock) { preContextBlock(context); } @@ -258,7 +258,7 @@ - (UIImage *)displayWithParameters:(_ASImageNodeDrawParameters *)parameters isCa [image drawInRect:imageDrawRect]; } - if (postContextBlock) { + if (context && postContextBlock) { postContextBlock(context); } diff --git a/AsyncDisplayKit/Private/ASDisplayNode+AsyncDisplay.mm b/AsyncDisplayKit/Private/ASDisplayNode+AsyncDisplay.mm index f3e09b61bc..24100027a9 100644 --- a/AsyncDisplayKit/Private/ASDisplayNode+AsyncDisplay.mm +++ b/AsyncDisplayKit/Private/ASDisplayNode+AsyncDisplay.mm @@ -274,7 +274,7 @@ - (asyncdisplaykit_async_transaction_operation_block_t)_displayBlockWithAsynchro } CGContextRef currentContext = UIGraphicsGetCurrentContext(); - if (_willDisplayNodeContentWithRenderingContext) { + if (currentContext && _willDisplayNodeContentWithRenderingContext) { _willDisplayNodeContentWithRenderingContext(currentContext); } @@ -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); }