Skip to content

Commit

Permalink
fix use out-of-scope memory warning (facebook#41441)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#41441

changelog: [internal]

Reviewed By: cipolleschi

Differential Revision: D51233760

fbshipit-source-id: 5fc7ab22220e3d80729243e715e22e85e3ba7afa
  • Loading branch information
sammy-SC authored and Saadnajmi committed May 21, 2024
1 parent 0204338 commit 88d042b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
ShadowNodeFamily::Shared createFamily(
const ShadowNodeFamilyFragment& fragment) const override {
return std::make_shared<ShadowNodeFamily>(
ShadowNodeFamilyFragment{
fragment.tag, fragment.surfaceId, fragment.instanceHandle},
eventDispatcher_,
*this);
fragment, eventDispatcher_, *this);
}

SharedEventEmitter createEventEmitter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,11 @@ class State;
* about a `ShadowNodeFamily`. Pelase define specific purpose containers in
* those cases.
*
* Note: All of the fields are `const &` references (essentially just raw
* pointers) which means that the Fragment does not copy/store them nor
* retain ownership of them.
*/
struct ShadowNodeFamilyFragment {
const Tag tag;
const SurfaceId surfaceId;
const InstanceHandle::Shared& instanceHandle;
const std::shared_ptr<const InstanceHandle> instanceHandle;
};

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ ShadowTree::ShadowTree(
layoutConstraints,
layoutContext);

const auto fragment = ShadowNodeFamilyFragment{surfaceId, surfaceId, nullptr};
auto family = globalRootComponentDescriptor->createFamily(fragment);
auto family = globalRootComponentDescriptor->createFamily(
{surfaceId, surfaceId, nullptr});

auto rootShadowNode = std::static_pointer_cast<const RootShadowNode>(
globalRootComponentDescriptor->createShadowNode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ ShadowNode::Shared UIManager::createNode(

PropsParserContext propsParserContext{surfaceId, *contextContainer_.get()};

const auto fragment =
ShadowNodeFamilyFragment{tag, surfaceId, instanceHandle};
auto family = componentDescriptor.createFamily(fragment);
auto family =
componentDescriptor.createFamily({tag, surfaceId, instanceHandle});
const auto props =
componentDescriptor.cloneProps(propsParserContext, nullptr, rawProps);
const auto state = componentDescriptor.createInitialState(props, family);
Expand Down

0 comments on commit 88d042b

Please sign in to comment.