mirror of
https://github.com/status-im/react-native.git
synced 2025-02-22 14:18:23 +00:00
Fabric: Fixed a retain cycle between ParagraphShadowNode, LocalData and AttributedString
Summary: Consider this: * ParagraphShadowNode retains LocalData, * LocalData contains AttributedString, * AttributedString contains Fragments, * Fragment can contain a pointer to parent shadow node, so it can be the ParagraphShadowNode. In this case it's a retain cycle. We actually don't need to store pointers to not TextShadowNodes, so we don't now. Later, after we fully migrate to ShadowView, we can remove this condition because it will become harmless. Reviewed By: sahrens Differential Revision: D13196885 fbshipit-source-id: d386ce0a067df0a72e6619d62d56038aaf80eccb
This commit is contained in:
parent
215a0f0f21
commit
0ec1d21c2f
@ -29,7 +29,15 @@ AttributedString BaseTextShadowNode::getAttributedString(
|
||||
auto fragment = AttributedString::Fragment{};
|
||||
fragment.string = rawTextShadowNode->getProps()->text;
|
||||
fragment.textAttributes = textAttributes;
|
||||
fragment.parentShadowNode = parentNode;
|
||||
|
||||
// Storing a retaining pointer to `ParagraphShadowNode` inside
|
||||
// `attributedString` causes a retain cycle (besides that fact that we
|
||||
// don't need it at all). Storing a `ShadowView` instance instead of
|
||||
// `ShadowNode` should properly fix this problem.
|
||||
fragment.parentShadowNode =
|
||||
std::dynamic_pointer_cast<const TextShadowNode>(parentNode)
|
||||
? parentNode
|
||||
: nullptr;
|
||||
attributedString.appendFragment(fragment);
|
||||
continue;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user