Skip to content

Commit 3e9083b

Browse files
zeyapmeta-codesync[bot]
authored andcommitted
nullcheck result of getAnimatedNode in NativeAnimatedNodesManager::updateNodes (#54830)
Summary: Pull Request resolved: #54830 ## Changelog: [General] [Fixed] - nullcheck result of getAnimatedNode in NativeAnimatedNodesManager::updateNodes Reviewed By: javache Differential Revision: D88760450 fbshipit-source-id: f37c1bec5ad558b8f9d654e6646f82a73491b11f
1 parent 814a2cd commit 3e9083b

1 file changed

Lines changed: 33 additions & 29 deletions

File tree

packages/react-native/ReactCommon/react/renderer/animated/NativeAnimatedNodesManager.cpp

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -653,20 +653,22 @@ void NativeAnimatedNodesManager::updateNodes(
653653
// in Animated, value nodes like RGBA are parents and Color node is child
654654
// (the opposite of tree structure)
655655
for (const auto childTag : nextNode.node->getChildren()) {
656-
auto child = getAnimatedNode<AnimatedNode>(childTag);
657-
child->activeIncomingNodes++;
658-
if (child->bfsColor != animatedGraphBFSColor_) {
659-
child->bfsColor = animatedGraphBFSColor_;
656+
if (auto child = getAnimatedNode<AnimatedNode>(childTag)) {
657+
child->activeIncomingNodes++;
658+
if (child->bfsColor != animatedGraphBFSColor_) {
659+
child->bfsColor = animatedGraphBFSColor_;
660660
#ifdef REACT_NATIVE_DEBUG
661-
activeNodesCount++;
661+
activeNodesCount++;
662662
#endif
663-
const auto connectedToFinishedAnimation =
664-
is_node_connected_to_finished_animation(
665-
child, childTag, nextNode.connectedToFinishedAnimation);
666-
nodesQueue.emplace_back(
667-
NodesQueueItem{
668-
.node = child,
669-
.connectedToFinishedAnimation = connectedToFinishedAnimation});
663+
const auto connectedToFinishedAnimation =
664+
is_node_connected_to_finished_animation(
665+
child, childTag, nextNode.connectedToFinishedAnimation);
666+
nodesQueue.emplace_back(
667+
NodesQueueItem{
668+
.node = child,
669+
.connectedToFinishedAnimation =
670+
connectedToFinishedAnimation});
671+
}
670672
}
671673
}
672674
}
@@ -721,27 +723,29 @@ void NativeAnimatedNodesManager::updateNodes(
721723
}
722724

723725
for (auto childTag : nextNode.node->getChildren()) {
724-
auto child = getAnimatedNode<AnimatedNode>(childTag);
725-
child->activeIncomingNodes--;
726-
if (child->activeIncomingNodes == 0 &&
727-
child->bfsColor != animatedGraphBFSColor_) {
728-
child->bfsColor = animatedGraphBFSColor_;
726+
if (auto child = getAnimatedNode<AnimatedNode>(childTag)) {
727+
child->activeIncomingNodes--;
728+
if (child->activeIncomingNodes == 0 &&
729+
child->bfsColor != animatedGraphBFSColor_) {
730+
child->bfsColor = animatedGraphBFSColor_;
729731
#ifdef REACT_NATIVE_DEBUG
730-
updatedNodesCount++;
732+
updatedNodesCount++;
731733
#endif
732-
const auto connectedToFinishedAnimation =
733-
is_node_connected_to_finished_animation(
734-
child, childTag, nextNode.connectedToFinishedAnimation);
735-
nodesQueue.emplace_back(
736-
NodesQueueItem{
737-
.node = child,
738-
.connectedToFinishedAnimation = connectedToFinishedAnimation});
739-
}
734+
const auto connectedToFinishedAnimation =
735+
is_node_connected_to_finished_animation(
736+
child, childTag, nextNode.connectedToFinishedAnimation);
737+
nodesQueue.emplace_back(
738+
NodesQueueItem{
739+
.node = child,
740+
.connectedToFinishedAnimation =
741+
connectedToFinishedAnimation});
742+
}
740743
#ifdef REACT_NATIVE_DEBUG
741-
else if (child->bfsColor == animatedGraphBFSColor_) {
742-
cyclesDetected++;
743-
}
744+
else if (child->bfsColor == animatedGraphBFSColor_) {
745+
cyclesDetected++;
746+
}
744747
#endif
748+
}
745749
}
746750
}
747751

0 commit comments

Comments
 (0)