From: eap Date: Tue, 24 Jan 2012 12:59:44 +0000 (+0000) Subject: 0021480: EDF 2084 SMESH: SIGSEGV when validating Netgen3D hypothesis X-Git-Tag: V6_5_0a1~181 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=fe663d61f64f1e7116438902e18e8779240967e3;p=modules%2Fsmesh.git 0021480: EDF 2084 SMESH: SIGSEGV when validating Netgen3D hypothesis In destructor, delete all data and delete mesh DS in a thread --- diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index aa36feb28..9416618c5 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -66,6 +66,9 @@ #include "Utils_ExceptHandlers.hxx" +#include +#include + using namespace std; // maximum stored group name length in MED file @@ -116,14 +119,29 @@ SMESH_Mesh::SMESH_Mesh(int theLocalId, //================================================================================ SMESH_Mesh::SMESH_Mesh(): - _groupId( 0 ), _nbSubShapes( 0 ) + _id(-1), + _studyId(-1), + _idDoc(-1), + _groupId( 0 ), + _nbSubShapes( 0 ), + _isShapeToMesh( false ), + _myDocument( 0 ), + _myMeshDS( 0 ), + _gen( 0 ), + _isAutoColor( false ), + _isModified( false ), + _shapeDiagonal( 0.0 ), + _rmGroupCallUp( 0 ) { - _myMeshDS = 0; - _isShapeToMesh = false; - _isAutoColor = false; - _isModified = false; - _shapeDiagonal = 0.0; - _rmGroupCallUp = 0; +} + +namespace +{ + void deleteMeshDS(SMESHDS_Mesh* meshDS) + { + //cout << "deleteMeshDS( " << meshDS << endl; + delete meshDS; + } } //============================================================================= @@ -149,8 +167,27 @@ SMESH_Mesh::~SMESH_Mesh() } _mapGroup.clear(); + // delete sub-meshes + map ::iterator sm = _mapSubMesh.begin(); + for ( ; sm != _mapSubMesh.end(); ++sm ) + delete sm->second; + _mapSubMesh.clear(); + if ( _rmGroupCallUp) delete _rmGroupCallUp; _rmGroupCallUp = 0; + + // remove self from studyContext + if ( _gen ) + { + StudyContextStruct * studyContext = _gen->GetStudyContext( _studyId ); + studyContext->mapMesh.erase( _id ); + } + if ( _myDocument ) + _myDocument->RemoveMesh( _id ); + + if ( _myMeshDS ) + // delete _myMeshDS, in a thread in order not to block closing a study with large meshes + boost::thread aThread(boost::bind( & deleteMeshDS, _myMeshDS )); } //=============================================================================