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

pcd_grabber fix destruction #1127

Merged
merged 1 commit into from
Feb 8, 2015

Conversation

soyersoyer
Copy link
Contributor

PCDGrabberImpl::trigger () use the PCDGrabber's publish () virtual function, so the ~PCDGrabber should stop the PCDGrabberBase

@@ -387,7 +387,6 @@ pcl::PCDGrabberBase::PCDGrabberBase (const std::vector<std::string>& pcd_files,
///////////////////////////////////////////////////////////////////////////////////////////
pcl::PCDGrabberBase::~PCDGrabberBase () throw ()
{
stop ();
delete impl_;
Copy link
Member

Choose a reason for hiding this comment

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

We might need to be more careful here because the copy constructor and assignment operator of PCDGrabberBase both copy this raw pointer. Would wrapping it into a shared pointer be a good idea?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately it is not a good idea. The trigger function calls the outside class' (PCDGrabberBase) publish function. https://github.com/soyersoyer/pcl/blob/pcdgrabber_fix/io/src/pcd_grabber.cpp#L291
After a copy it will call the copied PCDGrabberBase's publish function, not the new.

I think the PCDGrabberBase is not a good "value class" candidate (it is polymorphic), so the copy constructor and assignment should be private/deleted. If the copy is necessary, it is achievable with a virtual clone function.

Copy link
Member

Choose a reason for hiding this comment

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

Okay. It's not clear why they were made public in the first place. Anyways, that's a separate issue. Could you put the opening brace in dtor on a separate line so I can merge?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I've forgotten it. Fixed :-)

Copy link
Member

Choose a reason for hiding this comment

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

Thx

PCDGrabberImpl::trigger () use the PCDGrabber<PointT>'s publish ()
virtual function, so the ~PCDGrabber<PointT> should stop the
PCDGrabberBase
taketwo added a commit that referenced this pull request Feb 8, 2015
@taketwo taketwo merged commit 5dc3b81 into PointCloudLibrary:master Feb 8, 2015
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