From 14e44c7736a6764aa2bad627bf77f79fde95a540 Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 9 Feb 2012 13:10:52 +0000 Subject: [PATCH] 0021375: EDF 1671 SMESH: Dump study of current state + bool MeshExists( int meshId ) const; used to avoid crash at deletion of SMESH_subMesh::myOwnListeners at mesh removal --- src/SMESH/SMESH_Mesh.cxx | 15 +++++++++++++++ src/SMESH/SMESH_Mesh.hxx | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index 9416618c5..45d541b7a 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -170,7 +170,10 @@ SMESH_Mesh::~SMESH_Mesh() // delete sub-meshes map ::iterator sm = _mapSubMesh.begin(); for ( ; sm != _mapSubMesh.end(); ++sm ) + { delete sm->second; + sm->second = 0; + } _mapSubMesh.clear(); if ( _rmGroupCallUp) delete _rmGroupCallUp; @@ -184,12 +187,24 @@ SMESH_Mesh::~SMESH_Mesh() } if ( _myDocument ) _myDocument->RemoveMesh( _id ); + _myDocument = 0; 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 )); } +//================================================================================ +/*! + * \brief Return true if a mesh with given id exists + */ +//================================================================================ + +bool SMESH_Mesh::MeshExists( int meshId ) const +{ + return _myDocument ? _myDocument->GetMesh( meshId ) : false; +} + //============================================================================= /*! * \brief Set geometry to be meshed diff --git a/src/SMESH/SMESH_Mesh.hxx b/src/SMESH/SMESH_Mesh.hxx index fc607868f..2546d7fbf 100644 --- a/src/SMESH/SMESH_Mesh.hxx +++ b/src/SMESH/SMESH_Mesh.hxx @@ -147,6 +147,8 @@ public: int GetId() const { return _id; } + bool MeshExists( int meshId ) const; + SMESHDS_Mesh * GetMeshDS() { return _myMeshDS; } const SMESHDS_Mesh * GetMeshDS() const { return _myMeshDS; }