From e749ba3f4ebeb7c676f9f945b7f6dcc074a627f6 Mon Sep 17 00:00:00 2001 From: Yoann Audouin Date: Fri, 4 Nov 2022 15:20:53 +0100 Subject: [PATCH] Moving creation/deletion of temporary folder as __del__ is not called (Unregister removed from smeshBuilder) --- src/SMESH/SMESH_Gen.cxx | 2 ++ src/SMESH/SMESH_Mesh.cxx | 31 +++++++++++++++++++++++++------ src/SMESH/SMESH_Mesh.hxx | 3 +++ 3 files changed, 30 insertions(+), 6 deletions(-) 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 -- 2.39.2