Commit e85d0cd9 authored by Ken Martin's avatar Ken Martin
Browse files

fix memory leak

parent 04c85e54
......@@ -16,6 +16,7 @@
#include "vtkCellData.h"
#include "vtkFloatArray.h"
#include "vtkGarbageCollector.h"
#include "vtkImageData.h"
#include "vtkImplicitFunction.h"
#include "vtkMergePoints.h"
......@@ -30,7 +31,7 @@
#include "vtkIdTypeArray.h"
#include "vtkUnsignedCharArray.h"
vtkCxxRevisionMacro(vtkClipVolume, "1.67");
vtkCxxRevisionMacro(vtkClipVolume, "1.68");
vtkStandardNewMacro(vtkClipVolume);
vtkCxxSetObjectMacro(vtkClipVolume,ClipFunction,vtkImplicitFunction);
......@@ -699,3 +700,27 @@ void vtkClipVolume::PrintSelf(ostream& os, vtkIndent indent)
os << indent << "Mixed 3D Cell Type: "
<< (this->Mixed3DCellGeneration ? "On\n" : "Off\n");
}
//----------------------------------------------------------------------------
void vtkClipVolume::ReportReferences(vtkGarbageCollector* collector)
{
this->Superclass::ReportReferences(collector);
#ifdef VTK_USE_EXECUTIVES
// These filters share our input and are therefore involved in a
// reference loop.
collector->ReportReference(this->ClipFunction, "ClipFunction");
#endif
}
//----------------------------------------------------------------------------
void vtkClipVolume::RemoveReferences()
{
#ifdef VTK_USE_EXECUTIVES
if(this->ClipFunction)
{
this->ClipFunction->Delete();
this->ClipFunction = 0;
}
#endif
this->Superclass::RemoveReferences();
}
......@@ -166,6 +166,9 @@ protected:
vtkClipVolume(vtkImplicitFunction *cf=NULL);
~vtkClipVolume();
virtual void ReportReferences(vtkGarbageCollector*);
virtual void RemoveReferences();
void Execute();
void ClipTets(double value, vtkTetra *clipTetra, vtkDataArray *clipScalars,
vtkDataArray *cellScalars, vtkIdList *tetraIds,
......
......@@ -19,6 +19,7 @@
#include "vtkCellData.h"
#include "vtkContourGrid.h"
#include "vtkContourValues.h"
#include "vtkGarbageCollector.h"
#include "vtkGenericCell.h"
#include "vtkMergePoints.h"
#include "vtkObjectFactory.h"
......@@ -30,7 +31,7 @@
#include <math.h>
vtkCxxRevisionMacro(vtkContourFilter, "1.100");
vtkCxxRevisionMacro(vtkContourFilter, "1.101");
vtkStandardNewMacro(vtkContourFilter);
vtkCxxSetObjectMacro(vtkContourFilter,ScalarTree,vtkScalarTree);
......@@ -62,6 +63,7 @@ vtkContourFilter::~vtkContourFilter()
if ( this->ScalarTree )
{
this->ScalarTree->Delete();
this->ScalarTree = 0;
}
this->SetInputScalarsSelection(NULL);
}
......@@ -126,6 +128,7 @@ void vtkContourFilter::Execute()
cgrid->SelectInputScalars(this->InputScalarsSelection);
cgrid->Update();
output->ShallowCopy(cgrid->GetOutput());
cgrid->SetInput(0);
cgrid->Delete();
} //if type VTK_UNSTRUCTURED_GRID
else
......@@ -337,3 +340,26 @@ void vtkContourFilter::PrintSelf(ostream& os, vtkIndent indent)
}
}
//----------------------------------------------------------------------------
void vtkContourFilter::ReportReferences(vtkGarbageCollector* collector)
{
this->Superclass::ReportReferences(collector);
#ifdef VTK_USE_EXECUTIVES
// These filters share our input and are therefore involved in a
// reference loop.
collector->ReportReference(this->ScalarTree, "ScalarTree");
#endif
}
//----------------------------------------------------------------------------
void vtkContourFilter::RemoveReferences()
{
#ifdef VTK_USE_EXECUTIVES
if(this->ScalarTree)
{
this->ScalarTree->Delete();
this->ScalarTree = 0;
}
#endif
this->Superclass::RemoveReferences();
}
......@@ -141,6 +141,9 @@ protected:
vtkContourFilter();
~vtkContourFilter();
virtual void ReportReferences(vtkGarbageCollector*);
virtual void RemoveReferences();
void Execute();
vtkContourValues *ContourValues;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment