From bddaa5e7bc675eb50e6bc85f773900db4be63537 Mon Sep 17 00:00:00 2001 From: Viktor Uzlov Date: Fri, 15 Jul 2022 11:05:01 +0300 Subject: [PATCH] bos #30450 [CEA][Windows][Forum] SHAPER activation after GMSHPLUGIN call --- src/GMSHPlugin/GMSHPlugin_Mesher.cxx | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) 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; } -- 2.39.2