]> SALOME platform Git repositories - plugins/gmshplugin.git/commitdiff
Salome HOME
bos #30450 [CEA][Windows][Forum] SHAPER activation after GMSHPLUGIN call vuzlov/30450
authorViktor Uzlov <viktor.uzlov@opencascade.com>
Fri, 15 Jul 2022 08:05:01 +0000 (11:05 +0300)
committerViktor Uzlov <viktor.uzlov@opencascade.com>
Fri, 15 Jul 2022 08:05:01 +0000 (11:05 +0300)
src/GMSHPlugin/GMSHPlugin_Mesher.cxx

index 7fb7e56ff1e7dc9b89ce943eb03e9a76baf434f4..f55b232a8099d7a9a24a9de2a790c798ffc31bae 100644 (file)
@@ -1093,6 +1093,21 @@ bool GMSHPlugin_Mesher::Compute()
 {
   MESSAGE("GMSHPlugin_Mesher::Compute");
 
+  // vuzlov: Environment variables PATH and PYTHONPATH copy and restore
+  //         in the end of function because this variables change in gmsh
+  //         library and delete paths to libraries of SALOME modules.
+  //         See 'gmsh/Common/GmshMessage.cpp::Msg::Initialize' and
+  //         'addGmshPathToEnvironmentVar'
+#ifdef WIN32
+#ifdef UNICODE
+  wchar_t* ws_path = _wgetenv( L"PATH" );
+  wchar_t* wsp_path = _wgetenv( L"PYTHONPATH" );
+#else
+  const char* s_path = getenv("PATH");
+  const char* sp_path = getenv("PYTHONPATH");
+#endif
+#endif
+
   int err = 0;
 
 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
@@ -1160,6 +1175,25 @@ bool GMSHPlugin_Mesher::Compute()
   delete _gModel;
   GmshFinalize();
   MESSAGE("GMSHPlugin_Mesher::Compute:End");
+
+#ifdef WIN32
+#ifdef UNICODE
+  std::wstring s (L"PATH=");
+  s+=ws_path;
+  _wputenv((wchar_t *)s.c_str());
+  s = L"PYTHONPATH=";
+  s+=wsp_path;
+  _wputenv((wchar_t *)s.c_str());
+#else
+  std::string s("PATH=");
+  s+=s_path;
+  putenv((char *)s.c_str());
+  s = "PYTHONPATH=";
+  s+=sp_path;
+  putenv((char *)s.c_str());
+#endif
+#endif
+
   return !err;
 }