Commit e5c793db authored by David C. Lonie's avatar David C. Lonie

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
......@@ -33,7 +33,7 @@ class MyArray : public vtkTypedDataArray<float>
vtkFloatArray *Data;
public:
vtkTypeMacro(MyArray, vtkTypedDataArray<float>)
static MyArray *New() { return new MyArray; }
static MyArray *New() { VTK_STANDARD_NEW_BODY(MyArray) }
void Init(vtkFloatArray *array)
{
this->Data = array;
......
......@@ -24,7 +24,12 @@
class vtkTestReferenceLoop: public vtkObject
{
public:
static vtkTestReferenceLoop* New() { return new vtkTestReferenceLoop; }
static vtkTestReferenceLoop* New()
{
vtkTestReferenceLoop *ret = new vtkTestReferenceLoop;
ret->InitializeObjectBase();
return ret;
}
vtkTypeMacro(vtkTestReferenceLoop, vtkObject);
void Register(vtkObjectBase* o) VTK_OVERRIDE { this->RegisterInternal(o, 1); }
......@@ -34,17 +39,12 @@ protected:
vtkTestReferenceLoop()
{
this->Other = new vtkTestReferenceLoop(this);
#ifdef VTK_DEBUG_LEAKS
vtkDebugLeaks::ConstructClass("vtkTestReferenceLoop");
#endif
this->Other->InitializeObjectBase();
}
vtkTestReferenceLoop(vtkTestReferenceLoop* other)
{
this->Other = other;
this->Other->Register(this);
#ifdef VTK_DEBUG_LEAKS
vtkDebugLeaks::ConstructClass("vtkTestReferenceLoop");
#endif
}
~vtkTestReferenceLoop() VTK_OVERRIDE
{
......
......@@ -33,7 +33,7 @@ public:
}
vtkTypeMacro(vtkTestPoints,vtkPoints);
static vtkTestPoints* New() { return new vtkTestPoints; }
static vtkTestPoints* New() { VTK_STANDARD_NEW_BODY(vtkTestPoints) }
vtkTestPoints() { }
private:
vtkTestPoints(const vtkTestPoints&);
......@@ -50,7 +50,7 @@ public:
// Methods from vtkObject
vtkTypeMacro(vtkTestPoints2,vtkPoints);
static vtkTestPoints2* New() { return new vtkTestPoints2; }
static vtkTestPoints2* New() { VTK_STANDARD_NEW_BODY(vtkTestPoints2) }
vtkTestPoints2() { }
private:
vtkTestPoints2(const vtkTestPoints2&);
......@@ -65,7 +65,12 @@ class VTK_EXPORT TestFactory : public vtkObjectFactory
{
public:
TestFactory();
static TestFactory* New() { return new TestFactory;}
static TestFactory* New()
{
TestFactory *f = new TestFactory;
f->InitializeObjectBase();
return f;
}
const char* GetVTKSourceVersion() VTK_OVERRIDE { return VTK_SOURCE_VERSION; }
const char* GetDescription() VTK_OVERRIDE { return "A fine Test Factory"; }
......@@ -74,11 +79,6 @@ protected:
void operator=(const TestFactory&);
};
TestFactory::TestFactory()
{
this->RegisterOverride("vtkPoints",
......@@ -97,7 +97,8 @@ void TestNewPoints(vtkPoints* v, const char* expectedClassName)
if(strcmp(v->GetClassName(), expectedClassName) != 0)
{
failed = 1;
cout << "Test Failed" << endl;
cout << "Test Failed:\nExpected classname: " << expectedClassName
<< "\nCreated classname: " << v->GetClassName() << endl;
}
}
......
......@@ -13,18 +13,38 @@
=========================================================================*/
/**
* @class vtkDebugLeaks
* @brief identify memory leaks at program termination
* @class vtkDebugLeaks
* @brief identify memory leaks at program termination
* vtkDebugLeaks is used to report memory leaks at the exit of the program. It
* uses vtkObjectBase::InitializeObjectBase() (called via vtkObjectFactory
* macros) to intercept the construction of all VTK objects. It uses the
* UnRegisterInternal method of vtkObjectBase to intercept the destruction of
* all objects.
*
* vtkDebugLeaks is used to report memory leaks at the exit of the program.
* It uses the vtkObjectFactory to intercept the construction of all VTK
* objects. It uses the UnRegister method of vtkObject to intercept the
* destruction of all objects. A table of object name to number of instances
* is kept. At the exit of the program if there are still VTK objects around
* it will print them out. To enable this class add the flag
* -DVTK_DEBUG_LEAKS to the compile line, and rebuild vtkObject and
* vtkObjectFactory.
*/
* If not using the vtkObjectFactory macros to implement New(), be sure to call
* vtkObjectBase::InitializeObjectBase() explicitly on the constructed
* instance. The rule of thumb is that wherever "new [some vtkObjectBase
* subclass]" is called, vtkObjectBase::InitializeObjectBase() must be called
* as well.
*
* There are exceptions to this:
*
* - vtkCommand subclasses traditionally do not fully participate in
* vtkDebugLeaks registration, likely because they typically do not use
* vtkTypeMacro to configure GetClassName. InitializeObjectBase should not be
* called on vtkCommand subclasses, and all such classes will be automatically
* registered with vtkDebugLeaks as "vtkCommand or subclass".
*
* - vtkInformationKey subclasses are not reference counted. They are allocated
* statically and registered automatically with a singleton "manager" instance.
* The manager ensures that all keys are cleaned up before exiting, and
* registration/deregistration with vtkDebugLeaks is bypassed.
*
* A table of object name to number of instances is kept. At the exit of the
* program if there are still VTK objects around it will print them out. To
* enable this class add the flag -DVTK_DEBUG_LEAKS to the compile line, and
* rebuild vtkObject and vtkObjectFactory.
*/
#ifndef vtkDebugLeaks_h
#define vtkDebugLeaks_h
......
......@@ -22,6 +22,8 @@
#ifndef vtkDenseArray_txx
#define vtkDenseArray_txx
#include "vtkObjectFactory.h"
///////////////////////////////////////////////////////////////////////////////
// vtkDenseArray::MemoryBlock
......@@ -72,12 +74,11 @@ T* vtkDenseArray<T>::StaticMemoryBlock::GetAddress()
template<typename T>
vtkDenseArray<T>* vtkDenseArray<T>::New()
{
vtkObject* ret = vtkObjectFactory::CreateInstance(typeid(ThisT).name());
if(ret)
{
return static_cast<ThisT*>(ret);
}
return new ThisT();
// Don't use object factory macros on templated classes. It'll confuse the
// object factory.
vtkDenseArray<T> *ret = new vtkDenseArray<T>;
ret->InitializeObjectBase();
return ret;
}
template<typename T>
......
......@@ -15,15 +15,13 @@
#include "vtkDynamicLoader.h"
#include "vtkDebugLeaks.h"
#include "vtkObjectFactory.h"
//-----------------------------------------------------------------------------
vtkDynamicLoader* vtkDynamicLoader::New()
{
#ifdef VTK_DEBUG_LEAKS
vtkDebugLeaks::ConstructClass("vtkDynamicLoader");
#endif
return new vtkDynamicLoader;
VTK_STANDARD_NEW_BODY(vtkDynamicLoader)
}
......
......@@ -18,14 +18,7 @@
//------------------------------------------------------------------------------
vtkIndent* vtkIndent::New()
{
// First try to create the object from the vtkObjectFactory
vtkObject* ret = vtkObjectFactory::CreateInstance("vtkIndent");
if(ret)
{
return reinterpret_cast<vtkIndent*>(ret);
}
// If the factory was unable to create the object, then create it here.
return new vtkIndent;
return new vtkIndent; // not a VTK object, don't use object factory macros
}
......
......@@ -64,7 +64,7 @@ void vtkInformationDoubleKey::Set(vtkInformation* info, double value)
{
// Allocate a new value.
vtkInformationDoubleValue* v = new vtkInformationDoubleValue;
this->ConstructClass("vtkInformationDoubleValue");
v->InitializeObjectBase();
v->Value = value;
this->SetAsObjectBase(info, v);
v->Delete();
......
......@@ -83,7 +83,7 @@ void vtkInformationDoubleVectorKey::Set(vtkInformation* info,
}
vtkInformationDoubleVectorValue* v =
new vtkInformationDoubleVectorValue;
this->ConstructClass("vtkInformationDoubleVectorValue");
v->InitializeObjectBase();
v->Value.insert(v->Value.begin(), value, value+length);
this->SetAsObjectBase(info, v);
v->Delete();
......
......@@ -64,7 +64,7 @@ void vtkInformationIdTypeKey::Set(vtkInformation* info, vtkIdType value)
{
// Allocate a new value.
vtkInformationIdTypeValue* v = new vtkInformationIdTypeValue;
this->ConstructClass("vtkInformationIdTypeValue");
v->InitializeObjectBase();
v->Value = value;
this->SetAsObjectBase(info, v);
v->Delete();
......
......@@ -64,7 +64,7 @@ void vtkInformationIntegerKey::Set(vtkInformation* info, int value)
{
// Allocate a new value.
vtkInformationIntegerValue* v = new vtkInformationIntegerValue;
this->ConstructClass("vtkInformationIntegerValue");
v->InitializeObjectBase();
v->Value = value;
this->SetAsObjectBase(info, v);
v->Delete();
......
......@@ -70,7 +70,7 @@ void vtkInformationIntegerPointerKey::Set(vtkInformation* info, int* value,
// Allocate a new value.
vtkInformationIntegerPointerValue* v =
new vtkInformationIntegerPointerValue;
this->ConstructClass("vtkInformationIntegerPointerValue");
v->InitializeObjectBase();
v->Value = value;
v->Length = length;
this->SetAsObjectBase(info, v);
......
......@@ -107,7 +107,7 @@ void vtkInformationIntegerVectorKey::Set(vtkInformation* info,
// Allocate a new value.
vtkInformationIntegerVectorValue* v =
new vtkInformationIntegerVectorValue;
this->ConstructClass("vtkInformationIntegerVectorValue");
v->InitializeObjectBase();
v->Value.insert(v->Value.begin(), value, value+length);
this->SetAsObjectBase(info, v);
v->Delete();
......
......@@ -156,13 +156,6 @@ void vtkInformationKey::ReportAsObjectBase(vtkInformation* info,
}
//----------------------------------------------------------------------------
#ifdef VTK_DEBUG_LEAKS
void vtkInformationKey::ConstructClass(const char* name)
{
vtkDebugLeaks::ConstructClass(name);
}
#else
void vtkInformationKey::ConstructClass(const char*)
{
}
#endif
......@@ -99,9 +99,8 @@ void vtkInformationKeyVectorKey::Set(vtkInformation* info,
{
if(value)
{
vtkInformationKeyVectorValue* v =
new vtkInformationKeyVectorValue;
this->ConstructClass("vtkInformationKeyVectorValue");
vtkInformationKeyVectorValue* v = new vtkInformationKeyVectorValue;
v->InitializeObjectBase();
v->Value.insert(v->Value.begin(), value, value+length);
this->SetAsObjectBase(info, v);
v->Delete();
......
......@@ -75,7 +75,7 @@ vtkInformationObjectBaseVectorValue *
if(base==NULL)
{
base=new vtkInformationObjectBaseVectorValue;
this->ConstructClass("vtkInformationObjectBaseVectorValue"); // For debug info
base->InitializeObjectBase();
this->SetAsObjectBase(info, base);
base->Delete();
}
......
......@@ -68,7 +68,7 @@ void vtkInformationStringKey::Set(vtkInformation* info, const char* value)
{
// Allocate a new value.
vtkInformationStringValue* v = new vtkInformationStringValue;
this->ConstructClass("vtkInformationStringValue");
v->InitializeObjectBase();
v->Value = value;
this->SetAsObjectBase(info, v);
v->Delete();
......
......@@ -92,7 +92,7 @@ void vtkInformationStringVectorKey::Set(vtkInformation* info, const char* value,
{
vtkInformationStringVectorValue* v =
new vtkInformationStringVectorValue;
this->ConstructClass("vtkInformationStringVectorValue");
v->InitializeObjectBase();
while(static_cast<int>(v->Value.size()) <= index)
{
v->Value.push_back("");
......
......@@ -65,7 +65,7 @@ void vtkInformationUnsignedLongKey::Set(vtkInformation* info,
{
// Allocate a new value.
vtkInformationUnsignedLongValue* v = new vtkInformationUnsignedLongValue;
this->ConstructClass("vtkInformationUnsignedLongValue");
v->InitializeObjectBase();
v->Value = value;
this->SetAsObjectBase(info, v);
v->Delete();
......
......@@ -68,7 +68,7 @@ void vtkInformationVariantKey::Set(vtkInformation* info, const vtkVariant& value
{
// Allocate a new value.
vtkInformationVariantValue* v = new vtkInformationVariantValue;
this->ConstructClass("vtkInformationVariantValue");
v->InitializeObjectBase();
v->Value = value;
this->SetAsObjectBase(info, v);
v->Delete();
......
......@@ -86,7 +86,7 @@ void vtkInformationVariantVectorKey::Set(vtkInformation* info, const vtkVariant*
}
vtkInformationVariantVectorValue* v =
new vtkInformationVariantVectorValue;
this->ConstructClass("vtkInformationVariantVectorValue");
v->InitializeObjectBase();
v->Value.insert(v->Value.begin(), value, value+length);
this->SetAsObjectBase(info, v);
v->Delete();
......
......@@ -45,10 +45,10 @@ public:
vtkBaseTypeMacro(vtkMathInternal, vtkObjectBase);
static vtkMathInternal* New()
{
#ifdef VTK_DEBUG_LEAKS
vtkDebugLeaks::ConstructClass("vtkMathInternal");
#endif
return new vtkMathInternal();
// Can't use object factory macros, since they cast to vtkObject*.
vtkMathInternal *ret = new vtkMathInternal;
ret->InitializeObjectBase();
return ret;
}
vtkMinimalStandardRandomSequence *Uniform;
......
......@@ -17,6 +17,7 @@
#include "vtkCommand.h"
#include "vtkDebugLeaks.h"
#include "vtkGarbageCollector.h"
#include "vtkObjectFactory.h"
#include "vtkTimeStamp.h"
#include "vtkWeakPointer.h"
......@@ -126,10 +127,9 @@ protected:
vtkObject *vtkObject::New()
{
#ifdef VTK_DEBUG_LEAKS
vtkDebugLeaks::ConstructClass("vtkObject");
#endif
return new vtkObject;
vtkObject *ret = new vtkObject;
ret->InitializeObjectBase();
return ret;
}
......
......@@ -94,6 +94,14 @@ vtkObjectBase::~vtkObjectBase()
}
}
//----------------------------------------------------------------------------
void vtkObjectBase::InitializeObjectBase()
{
#ifdef VTK_DEBUG_LEAKS
vtkDebugLeaks::ConstructClass(this->GetClassName());
#endif // VTK_DEBUG_LEAKS
}
//----------------------------------------------------------------------------
#ifdef VTK_WORKAROUND_WINDOWS_MANGLE
# undef GetClassName
......
......@@ -43,6 +43,11 @@
#ifndef vtkObjectBase_h
#define vtkObjectBase_h
// Semantics around vtkDebugLeaks usage has changed. Now just call
// vtkObjectBase::InitializeObjectBase() after creating an object with New().
// The object factory methods take care of this automatically.
#define VTK_HAS_INITIALIZE_OBJECT_BASE
#include "vtkCommonCoreModule.h" // For export macro
#include "vtkIndent.h"
#include "vtkSystemIncludes.h"
......@@ -120,7 +125,15 @@ public:
* to zero, and reference counting on.
*/
static vtkObjectBase *New()
{return new vtkObjectBase;}
{
vtkObjectBase *o = new vtkObjectBase;
o->InitializeObjectBase();
return o;
}
// Called by implementations of vtkObject::New(). Centralized location for
// vtkDebugLeaks registration:
void InitializeObjectBase();
#ifdef _WIN32
// avoid dll boundary problems
......
......@@ -47,7 +47,7 @@ static vtkCleanUpObjectFactory vtkCleanUpObjectFactoryGlobal;
// factories
vtkObject* vtkObjectFactory::CreateInstance(const char* vtkclassname,
bool isAbstract)
bool)
{
if(!vtkObjectFactory::RegisteredFactories)
{
......@@ -66,29 +66,15 @@ vtkObject* vtkObjectFactory::CreateInstance(const char* vtkclassname,
return newobject;
}
}
// if the factory does not create the object, then
// the object will be created with the name passed in,
// so register the construction
if (!isAbstract)
{
#ifdef VTK_DEBUG_LEAKS
vtkDebugLeaks::ConstructClass(vtkclassname);
#endif
}
return 0;
}
#ifdef VTK_DEBUG_LEAKS
void vtkObjectFactory::ConstructInstance(const char* vtkclassname)
{
vtkDebugLeaks::ConstructClass(vtkclassname);
}
#else
void vtkObjectFactory::ConstructInstance(const char*)
{
// no-op. Call vtkObjectBase::InitializeObjectBase() from the New()
// implementation instead.
}
#endif
// A one time initialization method.
void vtkObjectFactory::Init()
......
......@@ -55,17 +55,17 @@ public:
* Each loaded vtkObjectFactory will be asked in the order
* the factory was in the VTK_AUTOLOAD_PATH. After the
* first factory returns the object no other factories are asked.
* If the requested class is abstract, set isAbstract to true. Otherwise
* it is assumed that an instance of 'vtkclassname' will be instantiated
* by the caller when no override is found.
* isAbstract is no longer used. This method calls
* vtkObjectBase::InitializeObjectBase() on the instance when the
* return value is non-NULL.
*/
VTK_NEWINSTANCE
static vtkObject* CreateInstance(const char* vtkclassname,
bool isAbstract = false);
/**
* Call vtkDebugLeaks::ConstructClass if necessary. Does not attempt
* to use the object factory to create an instance.
* No longer used. Call vtkObjectBase::InitializeObjectBase() from the
* New() implementation instead.
*/
static void ConstructInstance(const char* vtkclassname);
......@@ -327,7 +327,9 @@ vtkObjectFactory* vtkLoad() \
{ \
return static_cast<thisClass*>(ret); \
} \
return new thisClass;
thisClass *result = new thisClass; \
result->InitializeObjectBase(); \
return result;
// Macro to implement the body of the abstract object factory form of the New()
// method, i.e. an abstract base class that can only be instantiated if the
......@@ -345,14 +347,11 @@ vtkObjectFactory* vtkLoad() \
#if defined(VTK_ALL_NEW_OBJECT_FACTORY)
# define VTK_STANDARD_NEW_BODY(thisClass) \
VTK_OBJECT_FACTORY_NEW_BODY(thisClass)
#elif defined(VTK_DEBUG_LEAKS)
#else
# define VTK_STANDARD_NEW_BODY(thisClass) \
thisClass *result = new thisClass; \
vtkObjectFactory::ConstructInstance(result->GetClassName()); \
result->InitializeObjectBase(); \
return result;
#else
# define VTK_STANDARD_NEW_BODY(thisClass) \
return new thisClass;
#endif
// Macro to implement the standard form of the New() method.
......
......@@ -15,13 +15,13 @@
#include "vtkObjectFactoryCollection.h"
#include "vtkDebugLeaks.h"
#include "vtkObjectFactory.h"
vtkObjectFactoryCollection* vtkObjectFactoryCollection::New()
{
#ifdef VTK_DEBUG_LEAKS
vtkDebugLeaks::ConstructClass("vtkObjectFactoryCollection");
#endif
return new vtkObjectFactoryCollection;
// Don't use the object factory macros. Creating an object factory here
// will cause an infinite loop.
vtkObjectFactoryCollection *ret = new vtkObjectFactoryCollection;
ret->InitializeObjectBase();
return ret;
}
......@@ -149,22 +149,14 @@ vtkOutputWindow* vtkOutputWindow::GetInstance()
// if the factory did not provide one, then create it here
if(!vtkOutputWindow::Instance)
{
// if the factory failed to create the object,
// then destroy it now, as vtkDebugLeaks::ConstructClass was called
// with "vtkOutputWindow", and not the real name of the class
#if defined( _WIN32 ) && !defined( VTK_USE_X )
#ifdef VTK_DEBUG_LEAKS
vtkDebugLeaks::DestructClass("vtkOutputWindow");
#endif
vtkOutputWindow::Instance = vtkWin32OutputWindow::New();
#else
#if defined( ANDROID )
#ifdef VTK_DEBUG_LEAKS
vtkDebugLeaks::DestructClass("vtkOutputWindow");
#endif
vtkOutputWindow::Instance = vtkAndroidOutputWindow::New();
#else
vtkOutputWindow::Instance = new vtkOutputWindow;
vtkOutputWindow::Instance->InitializeObjectBase();
#endif
#endif
}
......
......@@ -44,7 +44,9 @@ vtkPoints* vtkPoints::New(int dataType)
return static_cast<vtkPoints*>(ret);
}
// If the factory was unable to create the object, then create it here.
return new vtkPoints(dataType);
vtkPoints *result = new vtkPoints(dataType);
result->InitializeObjectBase();
return result;
}
vtkPoints* vtkPoints::New()
......
......@@ -44,7 +44,9 @@ vtkPoints2D* vtkPoints2D::New(int dataType)
return static_cast<vtkPoints2D*>(ret);
}
// If the factory was unable to create the object, then create it here.
return new vtkPoints2D(dataType);
vtkPoints2D *result = new vtkPoints2D(dataType);
result->InitializeObjectBase();
return result;
}
vtkPoints2D* vtkPoints2D::New()
......
......@@ -28,12 +28,11 @@
template<typename T>
vtkSparseArray<T>* vtkSparseArray<T>::New()
{
vtkObject* ret = vtkObjectFactory::CreateInstance(typeid(ThisT).name());
if(ret)
{
return static_cast<ThisT*>(ret);
}
return new ThisT();
// Don't use object factory macros on templates, it'll confuse the object
// factory.
vtkSparseArray<T> *ret = new vtkSparseArray<T>;
ret->InitializeObjectBase();
return ret;
}
template<typename T>
......
......@@ -129,17 +129,11 @@ public:
//---------------------------------------------------------------------------
static vtkCompactHyperOctreeCursor<D> *New()
{
vtkObject *ret=
vtkObjectFactory::CreateInstance("vtkCompactHyperOctreeCursor<D>");
if(ret!=0)
{
return static_cast<vtkCompactHyperOctreeCursor<D> *>(ret);
}
else
{
return new vtkCompactHyperOctreeCursor<D>;
}
// Don't use object factory macros with templates. It'll confuse the
// object factory.
vtkCompactHyperOctreeCursor<D> *ret = new vtkCompactHyperOctreeCursor<D>;
ret->InitializeObjectBase();
return ret;
}
vtkTypeMacro(vtkCompactHyperOctreeCursor<D>,vtkHyperOctreeCursor);
......@@ -655,17 +649,9 @@ public:
//---------------------------------------------------------------------------
static vtkCompactHyperOctree<D> *New()
{
vtkObject *ret=
vtkObjectFactory::CreateInstance("vtkCompactHyperOctree<D>");
if(ret!=0)
{
return static_cast<vtkCompactHyperOctree<D> *>(ret);
}
else
{
return new vtkCompactHyperOctree<D>;
}
vtkCompactHyperOctree<D> *result = new vtkCompactHyperOctree<D>;
result->InitializeObjectBase();
return result;
}
vtkTypeMacro(vtkCompactHyperOctree<D>,vtkHyperOctreeInternal);
......
......@@ -37,10 +37,9 @@ public:
static vtkCompactHyperTreeCursor<N>* New()
{
vtkObject* o =
vtkObjectFactory::CreateInstance( "vtkCompactHyperTreeCursor<N>" );
return o ? static_cast<vtkCompactHyperTreeCursor<N> *>( o ) :
new vtkCompactHyperTreeCursor<N>();
vtkCompactHyperTreeCursor<N> *ret = new vtkCompactHyperTreeCursor<N>;
ret->InitializeObjectBase();
return ret;
}
//---------------------------------------------------------------------------
......@@ -595,9 +594,9 @@ public:
//---------------------------------------------------------------------------
static vtkCompactHyperTree<N>* New()
{
vtkObject* o = vtkObjectFactory::CreateInstance( "vtkCompactHyperTree<N>" );
return o ?
static_cast<vtkCompactHyperTree<N> *>(o) : new vtkCompactHyperTree<N>;
vtkCompactHyperTree<N> *ret = new vtkCompactHyperTree<N>;
ret->InitializeObjectBase();
return ret;
}
//---------------------------------------------------------------------------
......
......@@ -72,7 +72,7 @@ vtkInformationQuadratureSchemeDefinitionVectorValue *
if(base == NULL)
{
base=new vtkInformationQuadratureSchemeDefinitionVectorValue;
this->ConstructClass("vtkInformationQuadratureSchemeDefinitionVectorValue"); // For debug info
base->InitializeObjectBase();
this->SetAsObjectBase(info, base);
base->Delete();
}
......
......@@ -16,6 +16,7 @@
// This test checks the SplitExtent method of vtkThreadedImageAlgorithm.
#include "vtkNew.h"
#include "vtkObjectFactory.h"
#include "vtkThreadedImageAlgorithm.h"
#define TEST_SUCCESS 0
......@@ -32,10 +33,7 @@ public:
bool TestSplitExtent(int extent[6], vtkIdType pieces);
};
ThreadedImageAlgorithmTester *ThreadedImageAlgorithmTester::New()
{
return new ThreadedImageAlgorithmTester;
}
vtkStandardNewMacro(ThreadedImageAlgorithmTester)
// The SplitPath is protected, so add a method to set it.