Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added virtual dtor for PointCloud #3472

Closed
wants to merge 1 commit into from
Closed

Added virtual dtor for PointCloud #3472

wants to merge 1 commit into from

Conversation

erdustiggen
Copy link

As requested in #3470, a virtual destructor was readded to the PointCloud class.

Copy link
Member

@SergioRAgostinho SergioRAgostinho left a comment

Choose a reason for hiding this comment

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

Thank you, however pcl::RangeImage is the one that needs a virtual destructor, not pcl::PointCloud.

@taketwo
Copy link
Member

taketwo commented Nov 17, 2019

To resolve this warning indeed only pcl::RangeImage needs a virtual destructor.

However, as we have now found out, pcl::PointCloud serves as a base class. It's a good practice to mark destructors of every base class as virutal (ref).

Copy link
Member

@SergioRAgostinho SergioRAgostinho left a comment

Choose a reason for hiding this comment

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

Since PointCloud has no virtual methods, I'm struggling to find good practice cases where storing a base pointer to PointCloud objects, while wanting to address child methods from RangeImage, would make sense. That being said, if the criteria for adding a virtual dtor is a class having children, then I messed up my review during the destructor removal. I only focused on checking if the class had virtual methods and if any base class to it already defined a virtual dtor.

@taketwo
Copy link
Member

taketwo commented Nov 19, 2019

I agree with your first point. Perhaps we should even evaluate a possibility of "un-deriving" RangeImage from PointCloud.

@SergioRAgostinho
Copy link
Member

SergioRAgostinho commented Nov 19, 2019

I just had a look at the public interface of RangeImage and it looks messy. I wish we could write it from scratch.

  • The base container as a Eigen::Matrix/Eigen::Array
  • Most public methods actually feel like they should be free functions or static factory methods.
  • Not derived from PointCloud.

@taketwo
Copy link
Member

taketwo commented Nov 19, 2019

So maybe we pretend that RangeImage is not derived from PointCloud -> nothing is derived from PointCloud -> PointCloud is not supposed to be a base class -> PointCloud does not need a virtual destructor. And RangeImage gets a virtual destructor since we pretend it's at the root of a class hierarchy?

Copy link
Member

@SergioRAgostinho SergioRAgostinho left a comment

Choose a reason for hiding this comment

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

Sounds good to me. I'll just switch my review to make sure no one merges this as is.

@kunaltyagi
Copy link
Member

PointCloud is not supposed to be a base class

Maybe add final specifier to PointCloud in that case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants