[vtkusers] Deleting unknown object: vtkObject - vector of pointers?

David Doria daviddoria+vtk at gmail.com
Fri Nov 6 08:52:36 EST 2009


On Fri, Nov 6, 2009 at 8:27 AM, Bill Lorensen <bill.lorensen at gmail.com>wrote:

> David,
>
>
> Try printing the reference count of each LidarPoint before and after
> std::cout << "Ref Before: " << LidarPoint->GetReferenceCount() <<
> std::endl;
> Column[phiCounter] = LidarPoint;
> std::cout << "Ref After: " << LidarPoint->GetReferenceCount() << std::endl;
>
> And outside the end of the inner loop:
> std::cout << "Ref outside loop: " <<
> OutputGrid[0]-.GetReferenceCount() << std::endl;
>
>
Both before and after Column[phiCounter] = LidarPoint;, the reference count
is 1.

I changed
vtkstd::vector<vtkLidarPoint*> Column;
to
vtkstd::vector<vtkSmartPointer<vtkLidarPoint> > Column;
so that the reference count increases to 2 after Column[phiCounter] =
LidarPoint;

I also changed
vtkstd::vector<vtkstd::vector<vtkLidarPoint*> > OutputGrid;
to
vtkstd::vector<vtkstd::vector<vtkSmartPointer<vtkLidarPoint> > > OutputGrid;
based on the same logic.

I now get many less errors, but I still get a single
Deleting unknown object: vtkObject
every time the inner loop is entered.

I'm assuming it is because the vtkRay is going out of scope at the end of
the loop and I haven't made LidarPoint::SetRay accept a smart pointer?

Is all of this the correct way to approach storing these objects?

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091106/d3e987ec/attachment.htm>


More information about the vtkusers mailing list