Avoid cleaning up Owner of YGNode during clonning
Summary: This diff refactors the cloning mechanism for YogaNode used from Fabric UI renderer and RN iOS graphs. Previously, we were cleaning the owner of the child's cloned node inside the C++ implementation of YogaNode. This was a mistake because this modified the last commited YogaTree, causing side effect in RN iOS graphs. Reviewed By: shergin Differential Revision: D8672627 fbshipit-source-id: c9902d00690e0361fd58aed84b506c42258bd995
This commit is contained in:
committed by
Facebook Github Bot
parent
77ea79490f
commit
f4d29e6f11
@@ -175,6 +175,8 @@ public class YogaNode implements Cloneable {
|
||||
jni_YGNodeInsertSharedChild(mNativePointer, child.mNativePointer, i);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeSetOwner(long nativePointer, long newOwnerNativePointer);
|
||||
|
||||
private native long jni_YGNodeClone(long nativePointer, Object newNode);
|
||||
|
||||
@Override
|
||||
@@ -182,6 +184,14 @@ public class YogaNode implements Cloneable {
|
||||
try {
|
||||
YogaNode clonedYogaNode = (YogaNode) super.clone();
|
||||
long clonedNativePointer = jni_YGNodeClone(mNativePointer, clonedYogaNode);
|
||||
|
||||
if (mChildren != null) {
|
||||
for (YogaNode child : mChildren) {
|
||||
child.jni_YGNodeSetOwner(child.mNativePointer, 0);
|
||||
child.mOwner = null;
|
||||
}
|
||||
}
|
||||
|
||||
clonedYogaNode.mNativePointer = clonedNativePointer;
|
||||
clonedYogaNode.mOwner = null;
|
||||
clonedYogaNode.mChildren =
|
||||
|
Reference in New Issue
Block a user