Merge pull request #2687 from maicki/MSBetterErrorMessageForDeallocatedDisplayNodeInLayout

Better error message if a display node is created in layoutSpecThatFits: and deallocated before it was added to a subnode
This commit is contained in:
Adlai Holler 2016-12-01 17:39:56 -08:00 committed by GitHub
commit 8e90a31cc1

View File

@ -233,7 +233,7 @@ static inline std::vector<NSUInteger> findNodesInLayoutAtIndexesWithFilteredNode
if (idx > lastIndex) { break; } if (idx > lastIndex) { break; }
if (idx >= firstIndex && [indexes containsIndex:idx]) { if (idx >= firstIndex && [indexes containsIndex:idx]) {
ASDisplayNode *node = (ASDisplayNode *)sublayout.layoutElement; ASDisplayNode *node = (ASDisplayNode *)sublayout.layoutElement;
ASDisplayNodeCAssert(node, @"A flattened layout must consist exclusively of node sublayouts"); ASDisplayNodeCAssert(node, @"ASDisplayNode was deallocated before it was added to a subnode. It's likely the case that you use automatically manages subnodes and allocate a ASDisplayNode in layoutSpecThatFits: and don't have any strong reference to it.");
// Ignore the odd case in which a non-node sublayout is accessed and the type cast fails // Ignore the odd case in which a non-node sublayout is accessed and the type cast fails
if (node != nil) { if (node != nil) {
BOOL notFiltered = (filteredNodes == nil || [filteredNodes indexOfObjectIdenticalTo:node] == NSNotFound); BOOL notFiltered = (filteredNodes == nil || [filteredNodes indexOfObjectIdenticalTo:node] == NSNotFound);