ros-perception / image_common

Common code for working with images in ROS
http://www.ros.org/wiki/image_common
124 stars 219 forks source link

Creating an ImageTransport object inside a ROS node can lead to a circular dependency #311

Open KmakD opened 3 months ago

KmakD commented 3 months ago

Creating publishers, subscribers, etc., inside a ROS node implementation is a common practice. I did the same with an ImageTransport object, but this resulted in a circular dependency. When you pass a node (using shared_from_this()) to ImageTransport, it holds a reference to the ROS node, and this node holds a reference to the image transport object, thereby creating a circular dependency.

A common solution to avoid circular dependencies is to use weak pointers. What's your opinion on this?