Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Cory Quammen
VTK
Commits
75ca1bd2
Commit
75ca1bd2
authored
Oct 08, 2010
by
Pat Marion
Browse files
Add new api to vtkDebugLeaks to track vtk object lifetime
Change-Id: I5c45fbc337fc7c1fccdbef4c831624862f7cbfb9
parent
c345717a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Common/vtkDebugLeaks.cxx
View file @
75ca1bd2
...
...
@@ -305,6 +305,36 @@ void vtkDebugLeaks::DestructClass(const char*)
}
#endif
//----------------------------------------------------------------------------
void
vtkDebugLeaks
::
SetDebugLeaksObserver
(
vtkDebugLeaksObserver
*
observer
)
{
vtkDebugLeaks
::
Observer
=
observer
;
}
//----------------------------------------------------------------------------
vtkDebugLeaksObserver
*
vtkDebugLeaks
::
GetDebugLeaksObserver
()
{
return
vtkDebugLeaks
::
Observer
;
}
//----------------------------------------------------------------------------
void
vtkDebugLeaks
::
ConstructingObject
(
vtkObjectBase
*
object
)
{
if
(
vtkDebugLeaks
::
Observer
)
{
vtkDebugLeaks
::
Observer
->
ConstructingObject
(
object
);
}
}
//----------------------------------------------------------------------------
void
vtkDebugLeaks
::
DestructingObject
(
vtkObjectBase
*
object
)
{
if
(
vtkDebugLeaks
::
Observer
)
{
vtkDebugLeaks
::
Observer
->
DestructingObject
(
object
);
}
}
//----------------------------------------------------------------------------
int
vtkDebugLeaks
::
PrintCurrentLeaks
()
{
...
...
@@ -413,10 +443,12 @@ void vtkDebugLeaks::ClassInitialize()
// Default to error when leaks occur while running tests.
vtkDebugLeaks
::
ExitError
=
1
;
vtkDebugLeaks
::
Observer
=
0
;
#else
vtkDebugLeaks
::
MemoryTable
=
0
;
vtkDebugLeaks
::
CriticalSection
=
0
;
vtkDebugLeaks
::
ExitError
=
0
;
vtkDebugLeaks
::
Observer
=
0
;
#endif
}
...
...
@@ -458,3 +490,5 @@ vtkSimpleCriticalSection* vtkDebugLeaks::CriticalSection;
// Purposely not initialized. ClassInitialize will handle it.
int
vtkDebugLeaks
::
ExitError
;
vtkDebugLeaksObserver
*
vtkDebugLeaks
::
Observer
;
Common/vtkDebugLeaks.h
View file @
75ca1bd2
...
...
@@ -33,6 +33,7 @@
class
vtkDebugLeaksHashTable
;
class
vtkSimpleCriticalSection
;
class
vtkDebugLeaksObserver
;
class
VTK_COMMON_EXPORT
vtkDebugLeaks
:
public
vtkObject
{
...
...
@@ -64,6 +65,10 @@ public:
// Default is on when VTK_DEBUG_LEAKS is on and off otherwise.
static
int
GetExitError
();
static
void
SetExitError
(
int
);
//BTX
static
void
SetDebugLeaksObserver
(
vtkDebugLeaksObserver
*
observer
);
static
vtkDebugLeaksObserver
*
GetDebugLeaksObserver
();
//ETX
protected:
vtkDebugLeaks
(){};
...
...
@@ -74,17 +79,34 @@ protected:
static
void
ClassInitialize
();
static
void
ClassFinalize
();
static
void
ConstructingObject
(
vtkObjectBase
*
object
);
static
void
DestructingObject
(
vtkObjectBase
*
object
);
//BTX
friend
class
vtkDebugLeaksManager
;
friend
class
vtkObjectBase
;
//ETX
private:
static
vtkDebugLeaksHashTable
*
MemoryTable
;
static
vtkSimpleCriticalSection
*
CriticalSection
;
static
vtkDebugLeaksObserver
*
Observer
;
static
int
ExitError
;
vtkDebugLeaks
(
const
vtkDebugLeaks
&
);
// Not implemented.
void
operator
=
(
const
vtkDebugLeaks
&
);
// Not implemented.
};
//BTX
// This class defines callbacks for debugging tools. The callbacks are not for general use.
// The objects passed as arguments to the callbacks are in partially constructed or destructed
// state and accessing them may cause undefined behavior.
class
VTK_COMMON_EXPORT
vtkDebugLeaksObserver
{
public:
virtual
~
vtkDebugLeaksObserver
()
{};
virtual
void
ConstructingObject
(
vtkObjectBase
*
)
=
0
;
virtual
void
DestructingObject
(
vtkObjectBase
*
)
=
0
;
};
//ETX
#endif // __vtkDebugLeaks_h
Common/vtkObjectBase.cxx
View file @
75ca1bd2
...
...
@@ -75,10 +75,17 @@ vtkObjectBase::vtkObjectBase()
{
this
->
ReferenceCount
=
1
;
this
->
WeakPointers
=
0
;
#ifdef VTK_DEBUG_LEAKS
vtkDebugLeaks
::
ConstructingObject
(
this
);
#endif
}
vtkObjectBase
::~
vtkObjectBase
()
{
#ifdef VTK_DEBUG_LEAKS
vtkDebugLeaks
::
DestructingObject
(
this
);
#endif
// warn user if reference counting is on and the object is being referenced
// by another object
if
(
this
->
ReferenceCount
>
0
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment