[vtkusers] clarification on smart pointer usage

Rick Frank rickfrank at me.com
Fri Dec 28 20:35:24 EST 2012


Hi,


Tracing through the code seems to indicate that assigning one smart point to another does not free the left hand side pointer.

For instance,

vtkSmartPointer<vtkVolumeRayCastCompositionFunction> one = vtkVolumeRayCastCompositionFunction::New();


vtkSmartPointer<vtkVolumeRayCastCompositionFunction> two = vtkVolumeRayCastCompositionFunction::New();


one = two;

// The pointer in one seems to be left undeleted?

Is there a standard best-pattern for  deleting the left hand side of the assignment?


The docs say the reference to the pointer is removed, but that's a bit unclear to me.

In the above, I put a break point on the dtor of vtkVolumeRayCastCompositionFunction and it wasn't hit.

Thanks

Rick



More information about the vtkusers mailing list