Fabric: Making UIManager::getNewestCloneOfShadowNode even more safer

Summary:
We cannot use a raw pointer here because the tree might progress right after we call to `shadowTree.tryCommit` and we will get a dangling pointer as a result.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D21464832

fbshipit-source-id: 3998b39d29db672da54d4adcb6be55cd3d44d862
This commit is contained in:
Valentin Shergin authored and Facebook GitHub Bot committed 2020-05-10 13:28:46 -07:00
1 parent 604402678b
commit 0d2fcb1ed7
1 file changed
+2 -2
+2 -2
View File
@@ -136,12 +136,12 @@ ShadowNode::Shared UIManager::getNewestCloneOfShadowNode(
return nullptr;
};
ShadowNode const *ancestorShadowNode;
auto ancestorShadowNode = ShadowNode::Shared{};
shadowTreeRegistry_.visit(
shadowNode.getSurfaceId(), [&](ShadowTree const &shadowTree) {
shadowTree.tryCommit(
[&](RootShadowNode::Shared const &oldRootShadowNode) {
ancestorShadowNode = oldRootShadowNode.get();
ancestorShadowNode = oldRootShadowNode;
return nullptr;
},
true);