Salome HOME
Fix pb with persistence of "light" modules: SaveAs operation leads to loss of non...
authorvsr <vsr@opencascade.com>
Wed, 2 Apr 2014 08:02:23 +0000 (12:02 +0400)
committervsr <vsr@opencascade.com>
Wed, 2 Apr 2014 08:02:23 +0000 (12:02 +0400)
src/SALOMEDS/SALOMEDS_Driver_i.cxx

index 5e4ba437715b44d29e7ac0ad71fc7ca291307455..a179db962e43e38410eb00eb55680b25d6cb7857 100644 (file)
@@ -29,6 +29,8 @@
 #include "SALOMEDS.hxx"
 #include <stdlib.h>
 
+#include CORBA_CLIENT_HEADER(SALOME_Session)
+
 SALOMEDS_Driver_i::SALOMEDS_Driver_i(Engines::EngineComponent_ptr theEngine, CORBA::ORB_ptr theORB)
 {
   // engine should not be null - component is supposed to be inherited from Engines::EngineComponent
@@ -355,26 +357,28 @@ SALOMEDS_DriverFactory_i::~SALOMEDS_DriverFactory_i()
 
 SALOMEDSImpl_Driver* SALOMEDS_DriverFactory_i::GetDriverByType(const std::string& theComponentType)
 {
-  CORBA::Object_var obj;
-
-  std::string aFactoryType;
-  if (theComponentType == "SUPERV") aFactoryType = "SuperVisionContainer";
-  else aFactoryType = "FactoryServer";
-
-  SALOMEDS::unlock();
-  obj = SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component(aFactoryType.c_str(), theComponentType.c_str());
-  SALOMEDS::lock();
+  SALOMEDSImpl_Driver* driver = 0;
 
-  if (CORBA::is_nil(obj)) {
-    obj = SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component("FactoryServer", theComponentType.c_str());
-  }
+  CORBA::Object_var obj = SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component("FactoryServer", theComponentType.c_str());
 
   if (!CORBA::is_nil(obj)) {
     Engines::EngineComponent_var anEngine = Engines::EngineComponent::_narrow(obj);
-    return new SALOMEDS_Driver_i(anEngine, _orb);
+    driver = new SALOMEDS_Driver_i(anEngine, _orb);
+  }
+  else {
+    // It can be "light" module
+    obj = _name_service->Resolve("/Kernel/Session");
+    if (!CORBA::is_nil(obj)) {
+      SALOME::Session_var session = SALOME::Session::_narrow(obj);
+      if (!CORBA::is_nil(session)) {
+       Engines::EngineComponent_var anEngine = session->GetComponent(theComponentType.c_str());
+       if (!CORBA::is_nil(anEngine))
+         driver = new SALOMEDS_Driver_i(anEngine, _orb);
+      }
+    }
   }
 
-  return NULL;
+  return driver;
 }
 
 SALOMEDSImpl_Driver* SALOMEDS_DriverFactory_i::GetDriverByIOR(const std::string& theIOR)