Fix clone issue in YogaNodeJNIBase
Summary: Changelog: Fix the cloneWithChildren implementation that was not copying the list of children on the java object. We were missing on copying the list of children when cloning. This is pretty bad as it means that the clone operation was mutating the old node as well as the new. When multiple threads were involved this could cause crashes. Reviewed By: SidharthGuglani Differential Revision: D24565307 fbshipit-source-id: 4e2e111db389e25c315ce7603b4018ac695bb0f1
This commit is contained in:
committed by
Facebook GitHub Bot
parent
64e2459427
commit
07eac0c6e2
@@ -116,6 +116,9 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
public YogaNodeJNIBase cloneWithChildren() {
|
||||
try {
|
||||
YogaNodeJNIBase clonedYogaNode = (YogaNodeJNIBase) super.clone();
|
||||
if (clonedYogaNode.mChildren != null) {
|
||||
clonedYogaNode.mChildren = new ArrayList<>(clonedYogaNode.mChildren);
|
||||
}
|
||||
long clonedNativePointer = YogaNative.jni_YGNodeCloneJNI(mNativePointer);
|
||||
clonedYogaNode.mOwner = null;
|
||||
clonedYogaNode.mNativePointer = clonedNativePointer;
|
||||
|
Reference in New Issue
Block a user