From bb0ec5c2cb4a40e5fd5a77a8dbfb63428492870c Mon Sep 17 00:00:00 2001 From: sbh Date: Mon, 2 Mar 2015 13:05:16 +0300 Subject: [PATCH] Error messages processing on librarry loading under windows platform --- env_Salome.bat | 2 +- src/Config/Config_ModuleReader.cpp | 20 ++++++++++++++++---- src/XGUI/XGUI_Workshop.cpp | 6 ++---- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/env_Salome.bat b/env_Salome.bat index ca536a797..e7e3551a5 100644 --- a/env_Salome.bat +++ b/env_Salome.bat @@ -89,7 +89,7 @@ IF "%ARCH%" == "Win64" ( ) @SET NEW_GEOM_CONFIG_FILE=%ROOT_DIR%\install\plugins -@SET PATH=%ROOT_DIR%\install\plugins;%ROOT_DIR%\install\bin;%PATH% +@SET PATH=%ROOT_DIR%\install\swig;%ROOT_DIR%\install\plugins;%ROOT_DIR%\install\bin;%PATH% @SET PYTHONPATH=%ROOT_DIR%\install\swig;%ROOT_DIR%\install\plugins;%PYTHONPATH% @SET LightAppConfig=%ROOT_DIR%\install\share\salome\resources\newgeom;%GUI_ROOT_DIR%\share\salome\resources\gui diff --git a/src/Config/Config_ModuleReader.cpp b/src/Config/Config_ModuleReader.cpp index 6acffa268..2dfd4c135 100644 --- a/src/Config/Config_ModuleReader.cpp +++ b/src/Config/Config_ModuleReader.cpp @@ -184,16 +184,28 @@ void Config_ModuleReader::loadLibrary(const std::string& theLibName) if (aFileName.empty()) return; -#ifdef WIN32 + #ifdef WIN32 HINSTANCE aModLib = ::LoadLibrary(aFileName.c_str()); -#else + #else void* aModLib = dlopen( aFileName.c_str(), RTLD_LAZY | RTLD_GLOBAL ); -#endif + #endif if(!aModLib && theLibName != "DFBrowser") { // don't show error for internal debugging tool std::string anErrorMsg = "Failed to load " + aFileName; - #ifndef WIN32 + #ifdef WIN32 + DWORD dwLastError = ::GetLastError(); + LPSTR messageBuffer = NULL; + size_t size = ::FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + dwLastError, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPSTR)&messageBuffer, 0, NULL); + anErrorMsg += ": " + std::string(messageBuffer, size); + #else anErrorMsg += ": " + std::string(dlerror()); #endif + std::cerr << anErrorMsg << std::endl; Events_Error::send(anErrorMsg); } } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 52472194c..99311b558 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -446,15 +446,13 @@ void XGUI_Workshop::processEvent(const std::shared_ptr& theMessa aMsg->parameters()); } } - } - - - else { + } else { //Show error dialog if error message received. std::shared_ptr anAppError = std::dynamic_pointer_cast(theMessage); if (anAppError) { emit errorOccurred(QString::fromLatin1(anAppError->description())); } + return; } if (!isSalomeMode()) { SessionPtr aMgr = ModelAPI_Session::get(); -- 2.39.2