PR: debug memory leak (EDF 2662)

non virtual destructors and missing delete...
This commit is contained in:
prascle 2013-06-20 12:22:27 +00:00
parent 8eee7182cb
commit 2dcc1590a3
4 changed files with 31 additions and 24 deletions

View File

@ -6360,7 +6360,7 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint()
void getElementsInSphere ( const gp_XYZ& center, void getElementsInSphere ( const gp_XYZ& center,
const double radius, TIDSortedElemSet& foundElems); const double radius, TIDSortedElemSet& foundElems);
size_t getSize() { return std::max( _size, _elements.size() ); } size_t getSize() { return std::max( _size, _elements.size() ); }
~ElementBndBoxTree(); virtual ~ElementBndBoxTree();
protected: protected:
ElementBndBoxTree():_size(0) {} ElementBndBoxTree():_size(0) {}
@ -6559,6 +6559,9 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint()
* of classification of point in 2D mesh * of classification of point in 2D mesh
*/ */
//======================================================================= //=======================================================================
SMESH_ElementSearcher::~SMESH_ElementSearcher()
{
}
struct SMESH_ElementSearcherImpl: public SMESH_ElementSearcher struct SMESH_ElementSearcherImpl: public SMESH_ElementSearcher
{ {
@ -6572,8 +6575,8 @@ struct SMESH_ElementSearcherImpl: public SMESH_ElementSearcher
set<const SMDS_MeshElement*> _outerFaces; // empty means "no internal faces at all" set<const SMDS_MeshElement*> _outerFaces; // empty means "no internal faces at all"
SMESH_ElementSearcherImpl( SMESHDS_Mesh& mesh, SMDS_ElemIteratorPtr elemIt=SMDS_ElemIteratorPtr()) SMESH_ElementSearcherImpl( SMESHDS_Mesh& mesh, SMDS_ElemIteratorPtr elemIt=SMDS_ElemIteratorPtr())
: _mesh(&mesh),_meshPartIt(elemIt),_ebbTree(0),_nodeSearcher(0),_tolerance(-1),_outerFacesFound(false) {} : _mesh(&mesh),_meshPartIt(elemIt),_ebbTree(0),_nodeSearcher(0),_tolerance(-1),_outerFacesFound(false) {MESSAGE("-----------> SMESH_ElementSearcherImpl constructor");}
~SMESH_ElementSearcherImpl() virtual ~SMESH_ElementSearcherImpl()
{ {
if ( _ebbTree ) delete _ebbTree; _ebbTree = 0; if ( _ebbTree ) delete _ebbTree; _ebbTree = 0;
if ( _nodeSearcher ) delete _nodeSearcher; _nodeSearcher = 0; if ( _nodeSearcher ) delete _nodeSearcher; _nodeSearcher = 0;

View File

@ -96,6 +96,7 @@ struct SMESH_ElementSearcher
* \brief Find out if the given point is out of closed 2D mesh. * \brief Find out if the given point is out of closed 2D mesh.
*/ */
virtual TopAbs_State GetPointState(const gp_Pnt& point) = 0; virtual TopAbs_State GetPointState(const gp_Pnt& point) = 0;
virtual ~SMESH_ElementSearcher();
}; };

View File

@ -49,6 +49,7 @@ public:
// Constructor. limit must be provided at tree root construction. // Constructor. limit must be provided at tree root construction.
// limit will be deleted by SMESH_Octree // limit will be deleted by SMESH_Octree
SMESH_Octree (SMESH_TreeLimit* limit=0); SMESH_Octree (SMESH_TreeLimit* limit=0);
virtual ~SMESH_Octree() {};
// Compute the bigger dimension of my box // Compute the bigger dimension of my box
double maxSize() const; double maxSize() const;

View File

@ -218,6 +218,8 @@ void SMESH_Tree<BND_BOX,NB_CHILDREN>::buildChildren()
myChildren[i] = newChild(); myChildren[i] = newChild();
// and we assign to him its box. // and we assign to him its box.
myChildren[i]->myFather = this; myChildren[i]->myFather = this;
if (myChildren[i]->myLimit)
delete myChildren[i]->myLimit;
myChildren[i]->myLimit = myLimit; myChildren[i]->myLimit = myLimit;
myChildren[i]->myLevel = myLevel + 1; myChildren[i]->myLevel = myLevel + 1;
myChildren[i]->myBox = newChildBox( i ); myChildren[i]->myBox = newChildBox( i );