WeakReference for parent

Summary: - Use WeakReference for parent to avoid circular reference although GC will treat it

Reviewed By: emilsjolander

Differential Revision: D3982520

fbshipit-source-id: b0f6764aa4df3da53be51f6cb4fe2994d989afdf
This commit is contained in:
Kazuki Sakamoto
2016-10-07 11:07:51 -07:00
committed by Facebook Github Bot
parent c233bafeb2
commit 90844d62c5
2 changed files with 44 additions and 5 deletions

View File

@@ -19,7 +19,7 @@ namespace Facebook.CSSLayout
private bool _isDisposed;
private IntPtr _cssNode;
private CSSNode _parent;
private WeakReference _parent;
private List<CSSNode> _children;
private MeasureFunction _measureFunction;
private CSSMeasureFunc _measureFunc;
@@ -155,7 +155,7 @@ namespace Facebook.CSSLayout
get
{
AssertNativeInstance();
return _parent;
return _parent != null ? _parent.Target as CSSNode : null;
}
}
@@ -632,7 +632,7 @@ namespace Facebook.CSSLayout
{
AssertNativeInstance();
_children.Insert(index, node);
node._parent = this;
node._parent = new WeakReference(this);
Native.CSSNodeInsertChild(_cssNode, node._cssNode, (uint)index);
}