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

PCLVisualizer shape handling is bad #1244

Closed
VictorLamoine opened this issue May 21, 2015 · 4 comments · Fixed by #1245
Closed

PCLVisualizer shape handling is bad #1244

VictorLamoine opened this issue May 21, 2015 · 4 comments · Fixed by #1245

Comments

@VictorLamoine
Copy link
Contributor

This simple example will crash the PCLVisualizer:

#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>

int
main (int argc,
      char *argv[])
{
  pcl::visualization::PCLVisualizer viewer ("Viewer");
  viewer.addText("coucou", 50, 50, "text");
  pcl::PointXYZ p1 (0, 0, 0), p2 (1, 1, 1);
  viewer.addLine(p1, p2, "line");
  viewer.updateText("make the visualizer crash", 50, 50, "line");
  viewer.spin();
  return 0;
}

Both text and line are added in the shape_actor_map_, so when you try to update the ID line as if it was a text, the ID is found and the SafeDownCast crashes because a vtkLODActor (line) cannot be casted into a vtkTextActor:

vtkTextActor* actor = vtkTextActor::SafeDownCast (am_it->second);
@taketwo
Copy link
Member

taketwo commented May 21, 2015

I wonder why it is called safe? Perhaps it throws an exception? Then we can catch it and warn the user.

@VictorLamoine
Copy link
Contributor Author

I can't find any documentation about this; I would have expected a NULL pointer but it throws a segfault.

@taketwo
Copy link
Member

taketwo commented May 21, 2015

Are you sure that segfault occurs in down cast, not on the next line, when the pointer is used without NULL check?

@VictorLamoine
Copy link
Contributor Author

Yup (VTK 5.8)
Uhh NO, the pointer is indeed NULL, we need to add some checks.

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 a pull request may close this issue.

2 participants