Salome HOME
Merge branch 'V9_9_BR'
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_HypothesesUtils.cxx
index f3176684a6b783438aac029f9b101dac07cf57d6..b8e0277ccd316c7d6c08e4d9ebc99909c2a6f11c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -34,7 +34,8 @@
 #include "SMESHGUI_VTKUtils.h"
 #include "SMESHGUI_XmlHandler.h"
 
-#include "SMESH_Actor.h"
+#include <SMESH_Actor.h>
+#include <SMESH_TryCatch.hxx>
 
 // SALOME GUI includes
 #include <SUIT_Desktop.h>
@@ -67,6 +68,7 @@
  #define LoadLib( name ) LoadLibrary( name )
  #define GetProc GetProcAddress
  #define UnLoadLib( handle ) FreeLibrary( handle );
+ #define env_sep ";"
 #else // WIN32
  #define LibHandle void*
  #ifdef DYNLOAD_LOCAL
@@ -76,6 +78,7 @@
  #endif // DYNLOAD_LOCAL
  #define GetProc dlsym
  #define UnLoadLib( handle ) dlclose( handle );
+ #define env_sep ":"
 #endif // WIN32
 
 #ifdef _DEBUG_
@@ -197,7 +200,7 @@ namespace SMESH
       if (cenv)
         HypsXml.sprintf("%s", cenv);
 
-      QStringList HypsXmlList = HypsXml.split(":", QString::SkipEmptyParts);
+      QStringList HypsXmlList = HypsXml.split(env_sep, QString::SkipEmptyParts);
       if (HypsXmlList.count() == 0) {
         SUIT_MessageBox::critical(SMESHGUI::desktop(),
                                   QObject::tr("SMESH_WRN_WARNING"),
@@ -329,8 +332,7 @@ namespace SMESH
         hypoSet != myListOfHypothesesSets.end();
         ++hypoSet ) {
       HypothesesSet* aSet = *hypoSet;
-      if ( aSet && ( aSet->count( true ) || aSet->count( false )) &&
-          aSet->maxDim() <= maxDim)
+      if ( aSet && 0 <= aSet->maxDim() && aSet->maxDim() <= maxDim )
       {
         aSetNameList.append( mangledHypoSetName( aSet ));
       }
@@ -521,7 +523,22 @@ namespace SMESH
       try {
         // load plugin library
         if(MYDEBUG) MESSAGE("Loading client meshers plugin library ...");
-        LibHandle libHandle = LoadLib( aClientLibName.toUtf8().data() );
+#ifdef WIN32
+#ifdef UNICODE
+        LPTSTR path = new TCHAR[aClientLibName.length() + 1];
+        path[aClientLibName.toWCharArray(path)] = '\0';
+#else
+        QByteArray baPath = aClientLibName.toUtf8();
+        const char* path = baPath.data();
+#endif
+#else
+        QByteArray baPath = aClientLibName.toUtf8();
+        char* path = baPath.data();
+#endif
+        LibHandle libHandle = LoadLib( path );
+#if defined(WIN32) && defined(UNICODE)
+      delete path;
+#endif
         if (!libHandle) {
           // report any error, if occurred
           {
@@ -576,7 +593,7 @@ namespace SMESH
 
   SMESH::SMESH_Hypothesis_ptr CreateHypothesis(const QString& aHypType,
                                                const QString& aHypName,
-                                               const bool isAlgo)
+                                               const bool /*isAlgo*/)
   {
     if(MYDEBUG) MESSAGE("Create " << aHypType.toLatin1().data() <<
                         " with name " << aHypName.toLatin1().data());
@@ -612,10 +629,13 @@ namespace SMESH
 
     HypothesisData* aHypData = GetHypothesisData(aHypType);
     QString aServLib = aHypData->ServerLibName;
+    SMESH_TRY;
     return SMESHGUI::GetSMESHGen()->IsApplicable( aHypType.toLatin1().data(),
                                                   aServLib.toUtf8().data(),
                                                   theGeomObject,
                                                   toCheckAll);
+    SMESH_CATCH( SMESH::printErrorInDebugMode );
+    return false;
   }
 
 
@@ -653,7 +673,7 @@ namespace SMESH
     int res = SMESH::HYP_UNKNOWN_FATAL;
     SUIT_OverrideCursor wc;
 
-    if (!aSubMesh->_is_nil() && ! aHyp->_is_nil()) {
+    if ( !aSubMesh->_is_nil() && !aHyp->_is_nil() ) {
       try {
         SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
         _PTR(SObject) SsubM = SMESH::FindSObject(aSubMesh);