]> SALOME platform Git repositories - modules/smesh.git/blobdiff - src/SMESH/SMESH_Mesh.cxx
Salome HOME
Win32/Win64: fix crash after closing study
[modules/smesh.git] / src / SMESH / SMESH_Mesh.cxx
index 6f1edc645e019e56b35d079c44307312da9b803d..4a00711b7a6f76286586fd9afc2cf8cc7fed0186 100644 (file)
 #include "SMESH_TryCatch.hxx" // include after OCCT headers!
 
 #include "Utils_ExceptHandlers.hxx"
-
+#ifndef WIN32
 #include <boost/thread/thread.hpp>
 #include <boost/bind.hpp>
+#else 
+#include <pthread.h> 
+#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
+  }
 }
 
 //================================================================================
@@ -876,7 +897,7 @@ SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const int anHypId) const
 {
   StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
   if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
-    return false;
+    return NULL;
 
   SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
   return anHyp;