Salome HOME
[bos #37406][CEA] Fixed segfault in YACS_YacsRuntimeTest on UB22,FD36 and FD37 by...
[modules/yacs.git] / src / runtime / CppContainer.cxx
index 0f2b8fceb9995056fa8aa85b0d0f6186490a2510..b88046f103fb842b121c2833170f336862ac624e 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006-2016  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -85,7 +85,7 @@ bool CppContainer::isAlreadyStarted(const Task *askingNode) const
   return NULL != _trueCont;
 }
 
-void CppContainer::start(const Task *askingNode) throw (YACS::Exception)
+void CppContainer::start(const Task *askingNode)
 {
   _trueCont = LocalContainer::get();
 }
@@ -111,7 +111,7 @@ Container *CppContainer::cloneAlways() const
   return new CppContainer(*this);
 }
 
-bool CppContainer::loadComponentLibrary(const std::string & componentName) throw (YACS::Exception)
+bool CppContainer::loadComponentLibrary(const std::string & componentName)
     {
   if (_trueCont)
     {
@@ -168,7 +168,7 @@ std::string CppContainer::getFullPlacementId(const Task *askingNode) const
   return "/";
 }
 
-void CppContainer::checkCapabilityToDealWith(const ComponentInstance *inst) const throw(YACS::Exception)
+void CppContainer::checkCapabilityToDealWith(const ComponentInstance *inst) const
 {
   if(inst->getKind()!=CppComponent::KIND)
     throw Exception("CppContainer::checkCapabilityToDealWith : CppContainer is not able to deal with this type of ComponentInstance.");
@@ -339,7 +339,15 @@ LocalLibrary  LocalContainer::loadComponentLibrary(const std::string & aCompName
     
 #if defined( WIN32 )
   HMODULE handle;
-  handle = dlopen( impl_name.c_str() ) ;
+#if defined(UNICODE)
+  size_t length = strlen(impl_name.c_str()) + sizeof(char);
+  wchar_t* aPath = new wchar_t[length + 1];
+  memset(aPath, '\0', length);
+  mbstowcs(aPath, impl_name.c_str(), length);
+#else
+  const char* aPath = fullLibName.c_str();
+#endif
+  handle = dlopen( aPath ) ;
 #else
   void* handle;
   handle = dlopen( impl_name.c_str() , RTLD_LAZY ) ;