From: Yoann Audouin Date: Fri, 4 Nov 2022 14:20:53 +0000 (+0100) Subject: Moving creation/deletion of temporary folder as __del__ is not called (Unregister... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e749ba3f4ebeb7c676f9f945b7f6dcc074a627f6;p=modules%2Fsmesh.git Moving creation/deletion of temporary folder as __del__ is not called (Unregister removed from smeshBuilder) --- diff --git a/src/SMESH/SMESH_Gen.cxx b/src/SMESH/SMESH_Gen.cxx index 61d4fc010..fdacc7418 100644 --- a/src/SMESH/SMESH_Gen.cxx +++ b/src/SMESH/SMESH_Gen.cxx @@ -289,6 +289,7 @@ bool SMESH_Gen::parallelComputeSubMeshes( // Pool of thread for computation // TODO: move when parallelMesh created aMesh.InitPoolThreads(); + aMesh.CreateTmpFolder(); TopAbs_ShapeEnum previousShapeType = TopAbs_VERTEX; int nbThreads = aMesh.GetNbThreads(); @@ -365,6 +366,7 @@ bool SMESH_Gen::parallelComputeSubMeshes( aMesh.wait(); aMesh.GetMeshDS()->Modified(); + aMesh.DeleteTmpFolder(); return ret; }; diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index fb373c593..6c55d1e7b 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -124,9 +124,6 @@ SMESH_Mesh::SMESH_Mesh(int theLocalId, _callUp = NULL; _meshDS->ShapeToMesh( PseudoShape() ); _subMeshHolder = new SubMeshHolder; - // Temporary folder that will be used by parallel computation - tmp_folder = fs::temp_directory_path()/fs::unique_path(fs::path("SMESH_%%%%-%%%%")); - fs::create_directories(tmp_folder); // assure unique persistent ID if ( _document->NbMeshes() > 1 ) @@ -243,9 +240,6 @@ SMESH_Mesh::~SMESH_Mesh() if(_pool) DeletePoolThreads(); #endif -#ifndef _DEBUG_ - fs::remove_all(tmp_folder); -#endif } //================================================================================ @@ -2575,3 +2569,28 @@ void SMESH_Mesh::getAncestorsSubMeshes (const TopoDS_Shape& theSubSha // sort submeshes according to stored mesh order SortByMeshOrder( theSubMeshes ); } + + +//============================================================================= +/*! + * \brief Build folder for parallel computation + */ +//============================================================================= +void SMESH_Mesh::CreateTmpFolder() +{ + // Temporary folder that will be used by parallel computation + tmp_folder = fs::temp_directory_path()/fs::unique_path(fs::path("SMESH_%%%%-%%%%")); + fs::create_directories(tmp_folder); +} +// +//============================================================================= +/*! + * \brief Delete temporary folder used for parallel computation + */ +//============================================================================= +void SMESH_Mesh::DeleteTmpFolder() +{ +#ifndef _DEBUG_ + fs::remove_all(tmp_folder); +#endif +} diff --git a/src/SMESH/SMESH_Mesh.hxx b/src/SMESH/SMESH_Mesh.hxx index a59f7228a..ffce71417 100644 --- a/src/SMESH/SMESH_Mesh.hxx +++ b/src/SMESH/SMESH_Mesh.hxx @@ -418,6 +418,9 @@ class SMESH_EXPORT SMESH_Mesh bool IsParallel(){return _NbThreads > 0;} #endif + void CreateTmpFolder(); + void DeleteTmpFolder(); + // Temporary folder used during parallel Computation boost::filesystem::path tmp_folder; #ifndef WIN32