[vtk-developers] vtkNew in examples (or auto?)

Marcus D. Hanwell marcus.hanwell at kitware.com
Mon Jun 26 15:47:27 EDT 2017


On Mon, Jun 26, 2017 at 3:30 PM, David Cole <DLRdave at aol.com> wrote:
> I hereby retract my "disastrous" comment from the other email thread
> on this topic...
>
That was quite a thread, it was hidden by a terrible subject that gave
me no idea what it was about. I think I was with you, but as vtkObject
derived classes are all reference counted, and vtkSmartPointer/vtkNew
are effectively the same as far as risk of going out of
scope/returning a dangling pointer we should be consistent.

I am not a fan of either implicitly converting, but if one does it
they both should. I was just being cautious at the time, but I think
it was the wrong call, and would prefer consistency. I routinely use
vtkSmartPointer and vtkNew in class design to take care of objects,
and when switching between the two it is a pain because of the
inconsistency.

I had been planning to propose this patch for a while, and am glad
someone else did. It is a simple change, but it makes using the two
far more interchangeable, and will hopefully encourage more people to
use our pointer classes to aid with memory management, and banish the
smart pointer creation macros littering tests.


More information about the vtk-developers mailing list