Salome HOME
0021375: EDF 1671 SMESH: Dump study of current state
authoreap <eap@opencascade.com>
Thu, 9 Feb 2012 13:10:52 +0000 (13:10 +0000)
committereap <eap@opencascade.com>
Thu, 9 Feb 2012 13:10:52 +0000 (13:10 +0000)
+  bool MeshExists( int meshId ) const;
     used to avoid crash at deletion of SMESH_subMesh::myOwnListeners
     at mesh removal

src/SMESH/SMESH_Mesh.cxx
src/SMESH/SMESH_Mesh.hxx

index 9416618c5c433325ec980dc4d6b39a5bdc6bd2df..45d541b7a1a123b18a16a0612ba752660fd7ea98 100644 (file)
@@ -170,7 +170,10 @@ SMESH_Mesh::~SMESH_Mesh()
   // delete sub-meshes
   map <int, SMESH_subMesh*>::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
index fc607868f604a4b6d0476da9419fbc48c65aeeac..2546d7fbff1730c79673c506febb6e57b24f53fc 100644 (file)
@@ -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; }