From 3686b7ed4ae47ea84e2b973610371a6062716826 Mon Sep 17 00:00:00 2001 From: ana Date: Fri, 27 Dec 2013 12:38:16 +0000 Subject: [PATCH] Win32/Win64: fix crash after closing study --- src/SMESH/SMESH_Mesh.cxx | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index 4c1383356..4a00711b7 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -69,9 +69,12 @@ #include "SMESH_TryCatch.hxx" // include after OCCT headers! #include "Utils_ExceptHandlers.hxx" - +#ifndef WIN32 #include #include +#else +#include +#endif using namespace std; @@ -139,11 +142,23 @@ SMESH_Mesh::SMESH_Mesh(): namespace { - void deleteMeshDS(SMESHDS_Mesh* meshDS) +#ifndef WIN32 + void deleteMeshDS(SMESHDS_Mesh* meshDS) { //cout << "deleteMeshDS( " << meshDS << endl; delete meshDS; } +#else + static void* deleteMeshDS(void* meshDS) + { + //cout << "deleteMeshDS( " << meshDS << endl; + SMESHDS_Mesh* m = (SMESHDS_Mesh*)meshDS; + if(m) { + delete m; + } + return 0; + } +#endif } //============================================================================= @@ -191,9 +206,15 @@ SMESH_Mesh::~SMESH_Mesh() _myDocument->RemoveMesh( _id ); _myDocument = 0; - if ( _myMeshDS ) - // delete _myMeshDS, in a thread in order not to block closing a study with large meshes + if ( _myMeshDS ) { + // delete _myMeshDS, in a thread in order not to block closing a study with large meshes +#ifndef WIN32 boost::thread aThread(boost::bind( & deleteMeshDS, _myMeshDS )); +#else + pthread_t thread; + int result=pthread_create(&thread, NULL, deleteMeshDS, (void*)_myMeshDS); +#endif + } } //================================================================================ -- 2.39.2