[vtkusers] Deleting unknown object: vtkObject - vector of pointers?
Bill Lorensen
bill.lorensen at gmail.com
Fri Nov 6 10:27:55 EST 2009
Does SetRay increment the reference count of the Ray? Using
this->Ray->Register(this)
I tried your example with two vtk objects and it worked as expected.
Bill
On Fri, Nov 6, 2009 at 8:52 AM, David Doria <daviddoria+vtk at gmail.com> wrote:
> 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
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
More information about the vtkusers
mailing list