Skip to content

Conversation

@ugol-1
Copy link

@ugol-1 ugol-1 commented Nov 2, 2023

No description provided.


protected:
UASPtr uas; // uas back link
std::weak_ptr<UAS> uas_; // uas back link
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What for? Shared ptr good enough.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shared_ptr is not good here, because it creates cyclic references. The UAS node holds shared_ptrs to plugin nodes. In turn, each plugin node holds a shared_ptr to the UAS node. The result is that the UAS node and the plugin nodes never get destroyed.
You can check this by loading the mavros::uas::UAS component into a component container and then unloading it. The nodes will still be there. And then load it again, every node will get duplicated.

@ugol-1 ugol-1 force-pushed the fix_uas_component branch from 0d95358 to 98c538e Compare June 16, 2024 17:16
@ugol-1 ugol-1 force-pushed the fix_uas_component branch from 98c538e to fe0e21d Compare June 25, 2024 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants