Fix crash when a non-leaf node becomes a leaf node
Summary: When a non-leaf node becomes a leaf node, `YGAttachNodesFromViewHierachy` calls `YGNodeSetMeasureFunc` before `YGRemoveAllChildren`, which causes a crash because that node has children. Fixed by swapping the order of the calls and have a unit-test to make sure it works. Closes https://github.com/facebook/yoga/pull/320 Differential Revision: D4383905 Pulled By: dshahidehpour fbshipit-source-id: 4872b1e819f178adaaa66b1f1c233390d3ec3be9
This commit is contained in:
committed by
Facebook Github Bot
parent
bf6602ebff
commit
1877a97898
@@ -316,8 +316,8 @@ static void YGAttachNodesFromViewHierachy(UIView *const view)
|
||||
|
||||
// Only leaf nodes should have a measure function
|
||||
if (view.yg_isLeaf) {
|
||||
YGNodeSetMeasureFunc(node, YGMeasureView);
|
||||
YGRemoveAllChildren(node);
|
||||
YGNodeSetMeasureFunc(node, YGMeasureView);
|
||||
} else {
|
||||
YGNodeSetMeasureFunc(node, NULL);
|
||||
|
||||
|
Reference in New Issue
Block a user