Skip to content
Snippets Groups Projects
Commit e5c793db authored by David C. Lonie's avatar David C. Lonie
Browse files

Refactor vtkDebugLeaks construction.

vtkDebugLeaks registers instance by class name, which worked well for
many years. However, now that we have more templated code, this is
becoming difficult. For instance, "template <typename T> vtkBuffer<T>"
would be identified as "vtkBuffer<T>" when registering with
vtkDebugLeaks, but deregistered with the compiler dependent
typeid(vtkBuffer<T>).name() string returned from GetClassName().

This patch moves vtkDebugLeaks registrations to the method
vtkObjectBase::InitializeObjectBase(), which must be called after the
vtkObjectBase is instantiated. This ensures that objects are
registered using the same string as when they are destroyed. In
general, a call to "new vtkSomeClass" must be followed by a call to
InitializeObjectBase on the new instance. The common ::New()
implementation macros in vtkObjectFactory will ensure that
registration happens correctly.

Two notable exceptions are vtkCommand and vtkInformationKey
subclasses. These do not require any specific handling for
vtkDebugLeaks registration.

See discussion at:

http://vtk.1045678.n5.nabble.com/Proposal-Simplify-vtkDebugLeaks-registration-td5740222.html
parent e0b081e7
No related branches found
No related tags found
No related merge requests found
Showing
with 72 additions and 67 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment