From ee35ac825cacbaae2581b1712bdc9494302de8f4 Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 14 Dec 2012 13:16:39 +0000 Subject: [PATCH] 21948: EDF SMESH : Memory is not freed when deleting a mesh - int NewMesh(bool theIsEmbeddedMode); + SMESHDS_Mesh * NewMesh(bool theIsEmbeddedMode, int MeshID); --- src/SMESHDS/SMESHDS_Document.cxx | 16 +++++++++------- src/SMESHDS/SMESHDS_Document.hxx | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/SMESHDS/SMESHDS_Document.cxx b/src/SMESHDS/SMESHDS_Document.cxx index 315275e33..ff16aa2b0 100644 --- a/src/SMESHDS/SMESHDS_Document.cxx +++ b/src/SMESHDS/SMESHDS_Document.cxx @@ -55,13 +55,15 @@ SMESHDS_Document::~SMESHDS_Document() //function : NewMesh //purpose : //======================================================================= -int SMESHDS_Document::NewMesh(bool theIsEmbeddedMode) -{ - static int aNewMeshID = 0; - aNewMeshID++; - SMESHDS_Mesh *aNewMesh = new SMESHDS_Mesh(aNewMeshID,theIsEmbeddedMode); - myMeshes[aNewMeshID] = aNewMesh; - return aNewMeshID; +SMESHDS_Mesh * SMESHDS_Document::NewMesh(bool theIsEmbeddedMode, int MeshID) +{ + std::map::iterator i_m = + myMeshes.insert( make_pair( MeshID, (SMESHDS_Mesh*)0 )).first; + if ( i_m->second ) + throw SALOME_Exception("SMESHDS_Document::NewMesh(): ID of existing mesh given"); + SMESHDS_Mesh *aNewMesh = new SMESHDS_Mesh(MeshID,theIsEmbeddedMode); + i_m->second = aNewMesh; + return aNewMesh; } //======================================================================= diff --git a/src/SMESHDS/SMESHDS_Document.hxx b/src/SMESHDS/SMESHDS_Document.hxx index 4b7f1fcd1..172b723e2 100644 --- a/src/SMESHDS/SMESHDS_Document.hxx +++ b/src/SMESHDS/SMESHDS_Document.hxx @@ -38,8 +38,8 @@ class SMESHDS_EXPORT SMESHDS_Document { public: SMESHDS_Document(int UserID); - ~SMESHDS_Document(); - int NewMesh(bool theIsEmbeddedMode); + ~SMESHDS_Document(); + SMESHDS_Mesh * NewMesh(bool theIsEmbeddedMode, int MeshID); void RemoveMesh(int MeshID); SMESHDS_Mesh * GetMesh(int MeshID); void AddHypothesis(SMESHDS_Hypothesis * H); -- 2.39.2