【YogaKit】Fix two crashes. YogaKitSample upgrade to swift 5 #1144

Closed
Henrs wants to merge 3 commits from main into main
3 changed files with 36 additions and 32 deletions
Showing only changes of commit 9d6eaa473d - Show all commits

View File

@@ -430,7 +430,13 @@ static void YGAttachNodesFromViewHierachy(UIView* const view) {
if (!YGNodeHasExactSameChildren(node, subviewsToInclude)) { if (!YGNodeHasExactSameChildren(node, subviewsToInclude)) {
YGRemoveAllChildren(node); YGRemoveAllChildren(node);
for (int i = 0; i < subviewsToInclude.count; i++) { for (int i = 0; i < subviewsToInclude.count; i++) {
YGNodeInsertChild(node, subviewsToInclude[i].yoga.node, i); // should remove from owner if node has one owner
const YGNodeRef child = subviewsToInclude[i].yoga.node;
YGNodeRef owner = YGNodeGetOwner(child);
if (owner) {
YGNodeRemoveChild(owner, child);
}
YGNodeInsertChild(node, child, i);
} }
} }