diff --git a/AsyncDisplayKit/ASControlNode.mm b/AsyncDisplayKit/ASControlNode.mm index 34333ea0dd..29b0b57da2 100644 --- a/AsyncDisplayKit/ASControlNode.mm +++ b/AsyncDisplayKit/ASControlNode.mm @@ -286,7 +286,9 @@ void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, v { // Create the dispatch table for this event. eventDispatchTable = [NSMapTable weakToStrongObjectsMapTable]; - _controlEventDispatchTable[eventKey] = eventDispatchTable; + if (eventKey) { + [_controlEventDispatchTable setObject:eventDispatchTable forKey:eventKey]; + } } // Have we seen this target before for this event? @@ -442,9 +444,11 @@ id _ASControlNodeEventKeyForControlEvent(ASControlNodeEvent controlEv void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, void (^block)(ASControlNodeEvent anEvent)) { + if (block == nil) { + return; + } // Start with our first event (touch down) and work our way up to the last event (touch cancel) - for (ASControlNodeEvent thisEvent = ASControlNodeEventTouchDown; thisEvent <= ASControlNodeEventTouchCancel; thisEvent <<= 1) - { + for (ASControlNodeEvent thisEvent = ASControlNodeEventTouchDown; thisEvent <= ASControlNodeEventTouchCancel; thisEvent <<= 1){ // If it's included in the mask, invoke the block. if ((mask & thisEvent) == thisEvent) block(thisEvent); diff --git a/AsyncDisplayKit/ASRunLoopQueue.mm b/AsyncDisplayKit/ASRunLoopQueue.mm index 693f01dc75..44621b667d 100644 --- a/AsyncDisplayKit/ASRunLoopQueue.mm +++ b/AsyncDisplayKit/ASRunLoopQueue.mm @@ -59,13 +59,15 @@ static void runLoopSourceCallback(void *info) { // It is not guaranteed that the runloop will turn if it has no scheduled work, and this causes processing of // the queue to stop. Attaching a custom loop source to the run loop and signal it if new work needs to be done CFRunLoopSourceContext *runLoopSourceContext = (CFRunLoopSourceContext *)calloc(1, sizeof(CFRunLoopSourceContext)); - runLoopSourceContext->perform = runLoopSourceCallback; + if (runLoopSourceContext) { + runLoopSourceContext->perform = runLoopSourceCallback; #if ASRunLoopQueueLoggingEnabled - runLoopSourceContext->info = (__bridge void *)self; + runLoopSourceContext->info = (__bridge void *)self; #endif - _runLoopSource = CFRunLoopSourceCreate(NULL, 0, runLoopSourceContext); - CFRunLoopAddSource(runloop, _runLoopSource, kCFRunLoopCommonModes); - free(runLoopSourceContext); + _runLoopSource = CFRunLoopSourceCreate(NULL, 0, runLoopSourceContext); + CFRunLoopAddSource(runloop, _runLoopSource, kCFRunLoopCommonModes); + free(runLoopSourceContext); + } #if ASRunLoopQueueLoggingEnabled _runloopQueueLoggingTimer = [NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(checkRunLoop) userInfo:nil repeats:YES]; diff --git a/AsyncDisplayKit/ASTableView.mm b/AsyncDisplayKit/ASTableView.mm index 80bf807308..8fdb55eb44 100644 --- a/AsyncDisplayKit/ASTableView.mm +++ b/AsyncDisplayKit/ASTableView.mm @@ -606,16 +606,18 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell"; cell.delegate = self; ASCellNode *node = [_dataController nodeAtIndexPath:indexPath]; - [_rangeController configureContentView:cell.contentView forCellNode:node]; + if (node) { + [_rangeController configureContentView:cell.contentView forCellNode:node]; - cell.node = node; - cell.backgroundColor = node.backgroundColor; - cell.selectionStyle = node.selectionStyle; + cell.node = node; + cell.backgroundColor = node.backgroundColor; + cell.selectionStyle = node.selectionStyle; - // the following ensures that we clip the entire cell to it's bounds if node.clipsToBounds is set (the default) - // This is actually a workaround for a bug we are seeing in some rare cases (selected background view - // overlaps other cells if size of ASCellNode has changed.) - cell.clipsToBounds = node.clipsToBounds; + // the following ensures that we clip the entire cell to it's bounds if node.clipsToBounds is set (the default) + // This is actually a workaround for a bug we are seeing in some rare cases (selected background view + // overlaps other cells if size of ASCellNode has changed.) + cell.clipsToBounds = node.clipsToBounds; + } return cell; } diff --git a/AsyncDisplayKit/ASVideoPlayerNode.mm b/AsyncDisplayKit/ASVideoPlayerNode.mm index 7d1dc889d9..0099dd34fe 100644 --- a/AsyncDisplayKit/ASVideoPlayerNode.mm +++ b/AsyncDisplayKit/ASVideoPlayerNode.mm @@ -379,19 +379,19 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext; slider.maximumValue = 1.0; if (_delegateFlags.delegateScrubberMinimumTrackTintColor) { - slider.minimumTrackTintColor = [_delegate videoPlayerNodeScrubberMinimumTrackTint:strongSelf]; + slider.minimumTrackTintColor = [strongSelf.delegate videoPlayerNodeScrubberMinimumTrackTint:strongSelf]; } if (_delegateFlags.delegateScrubberMaximumTrackTintColor) { - slider.maximumTrackTintColor = [_delegate videoPlayerNodeScrubberMaximumTrackTint:strongSelf]; + slider.maximumTrackTintColor = [strongSelf.delegate videoPlayerNodeScrubberMaximumTrackTint:strongSelf]; } if (_delegateFlags.delegateScrubberThumbTintColor) { - slider.thumbTintColor = [_delegate videoPlayerNodeScrubberThumbTint:strongSelf]; + slider.thumbTintColor = [strongSelf.delegate videoPlayerNodeScrubberThumbTint:strongSelf]; } if (_delegateFlags.delegateScrubberThumbImage) { - UIImage *thumbImage = [_delegate videoPlayerNodeScrubberThumbImage:strongSelf]; + UIImage *thumbImage = [strongSelf.delegate videoPlayerNodeScrubberThumbImage:strongSelf]; [slider setThumbImage:thumbImage forState:UIControlStateNormal]; } diff --git a/AsyncDisplayKit/Details/ASDataController.mm b/AsyncDisplayKit/Details/ASDataController.mm index 76c8b723de..40c4af1abf 100644 --- a/AsyncDisplayKit/Details/ASDataController.mm +++ b/AsyncDisplayKit/Details/ASDataController.mm @@ -560,6 +560,10 @@ NSString * const ASDataControllerRowNodeKind = @"_ASDataControllerRowNodeKind"; return; } + if (block == nil) { + return; + } + // If we have never performed a reload, there is no value in executing edit operations as the initial // reload will directly re-query the latest state of the datasource - so completely skip the block in this case. if (_batchUpdateCounter == 0) { diff --git a/AsyncDisplayKit/Details/NSIndexSet+ASHelpers.m b/AsyncDisplayKit/Details/NSIndexSet+ASHelpers.m index f05acafa5f..15a4e9ec39 100644 --- a/AsyncDisplayKit/Details/NSIndexSet+ASHelpers.m +++ b/AsyncDisplayKit/Details/NSIndexSet+ASHelpers.m @@ -68,9 +68,9 @@ NSMutableString *result = [NSMutableString stringWithString:@"{ "]; [self enumerateRangesUsingBlock:^(NSRange range, BOOL * _Nonnull stop) { if (range.length == 1) { - [result appendFormat:@"%zu ", range.location]; + [result appendFormat:@"%zu ", (unsigned long)range.location]; } else { - [result appendFormat:@"%zu-%zu ", range.location, NSMaxRange(range) - 1]; + [result appendFormat:@"%zu-%lu ", (unsigned long)range.location, NSMaxRange(range) - 1]; } }]; [result appendString:@"}"]; diff --git a/AsyncDisplayKit/Private/ASInternalHelpers.mm b/AsyncDisplayKit/Private/ASInternalHelpers.mm index 94042053d7..dbe7f16795 100644 --- a/AsyncDisplayKit/Private/ASInternalHelpers.mm +++ b/AsyncDisplayKit/Private/ASInternalHelpers.mm @@ -34,6 +34,9 @@ BOOL ASSubclassOverridesClassSelector(Class superclass, Class subclass, SEL sele void ASPerformBlockOnMainThread(void (^block)()) { + if (block == nil){ + return; + } if (ASDisplayNodeThreadIsMain()) { block(); } else { @@ -43,6 +46,9 @@ void ASPerformBlockOnMainThread(void (^block)()) void ASPerformBlockOnBackgroundThread(void (^block)()) { + if (block == nil){ + return; + } if (ASDisplayNodeThreadIsMain()) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block); } else { diff --git a/AsyncDisplayKit/Private/ASMultidimensionalArrayUtils.mm b/AsyncDisplayKit/Private/ASMultidimensionalArrayUtils.mm index a251ed7fc6..e8b3671977 100644 --- a/AsyncDisplayKit/Private/ASMultidimensionalArrayUtils.mm +++ b/AsyncDisplayKit/Private/ASMultidimensionalArrayUtils.mm @@ -43,7 +43,9 @@ static void ASRecursivelyUpdateMultidimensionalArrayAtIndexPaths(NSMutableArray curIdx++; } - updateBlock(mutableArray, indexSet, curIdx); + if (updateBlock){ + updateBlock(mutableArray, indexSet, curIdx); + } } } diff --git a/AsyncDisplayKit/TextKit/ASTextKitContext.mm b/AsyncDisplayKit/TextKit/ASTextKitContext.mm index 7410ed9f45..e1f65a0122 100755 --- a/AsyncDisplayKit/TextKit/ASTextKitContext.mm +++ b/AsyncDisplayKit/TextKit/ASTextKitContext.mm @@ -75,7 +75,9 @@ NSTextContainer *))block { std::lock_guard l(_textKitMutex); - block(_layoutManager, _textStorage, _textContainer); + if (block) { + block(_layoutManager, _textStorage, _textContainer); + } } @end diff --git a/inferScript.sh b/inferScript.sh new file mode 100755 index 0000000000..81919c1e81 --- /dev/null +++ b/inferScript.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +if ! [ -x "$(command -v infer)" ]; then + echo "infer not found" + echo "Install infer with homebrew: brew install infer" +else + infer --continue --reactive -- xcodebuild build -workspace AsyncDisplayKit.xcworkspace -scheme "AsyncDisplayKit-iOS" -configuration Debug -sdk iphonesimulator9.3 +fi