From: Viktor Uzlov Date: Fri, 15 Jul 2022 08:05:01 +0000 (+0300) Subject: bos #30450 [CEA][Windows][Forum] SHAPER activation after GMSHPLUGIN call X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fvuzlov%2F30450;p=plugins%2Fgmshplugin.git bos #30450 [CEA][Windows][Forum] SHAPER activation after GMSHPLUGIN call --- diff --git a/src/GMSHPlugin/GMSHPlugin_Mesher.cxx b/src/GMSHPlugin/GMSHPlugin_Mesher.cxx index 7fb7e56..f55b232 100644 --- a/src/GMSHPlugin/GMSHPlugin_Mesher.cxx +++ b/src/GMSHPlugin/GMSHPlugin_Mesher.cxx @@ -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; }