Salome HOME
Merge from V6_main 11/02/2013
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_Driver_i.cxx
index ae2db2077fcfb73511880303cbb5026d424f4459..e30cecd845715ca4314d93af65b6750a04663125 100644 (file)
@@ -62,9 +62,9 @@ std::string SALOMEDS_Driver_i::GetIOR()
 }
 
 SALOMEDSImpl_TMPFile* SALOMEDS_Driver_i::Save(const SALOMEDSImpl_SComponent& theComponent,
-                                             const std::string& theURL,
-                                             long& theStreamLength,
-                                             bool isMultiFile)
+                                              const std::string& theURL,
+                                              long& theStreamLength,
+                                              bool isMultiFile)
 {  
   SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb);
   CORBA::String_var url = CORBA::string_dup(theURL.c_str());
@@ -77,6 +77,8 @@ SALOMEDSImpl_TMPFile* SALOMEDS_Driver_i::Save(const SALOMEDSImpl_SComponent& the
 
   SALOMEDSImpl_TMPFile* aTMPFile = new SALOMEDS_TMPFile_i(aStream._retn());
   theStreamLength = aTMPFile->Size();
+
+  sco->UnRegister();
   SALOMEDS::lock();
 
   return aTMPFile;
@@ -98,6 +100,8 @@ SALOMEDSImpl_TMPFile* SALOMEDS_Driver_i::SaveASCII(const SALOMEDSImpl_SComponent
 
   SALOMEDSImpl_TMPFile* aTMPFile = new SALOMEDS_TMPFile_i(aStream._retn());
   theStreamLength = aTMPFile->Size();
+
+  sco->UnRegister();
   SALOMEDS::lock();
 
   return aTMPFile;
@@ -125,6 +129,7 @@ bool SALOMEDS_Driver_i::Load(const SALOMEDSImpl_SComponent& theComponent,
   if ( !CORBA::is_nil(_driver) )
     isOk = _driver->Load(sco.in(), aStream.in(), url, isMultiFile);
 
+  sco->UnRegister();
   SALOMEDS::lock();
   return isOk;
 }
@@ -151,6 +156,7 @@ bool SALOMEDS_Driver_i::LoadASCII(const SALOMEDSImpl_SComponent& theComponent,
   if ( !CORBA::is_nil(_driver) )
     isOk = _driver->LoadASCII(sco.in(), aStream.in(), url, isMultiFile);
 
+  sco->UnRegister();
   SALOMEDS::lock();
   return isOk;
 }
@@ -162,6 +168,7 @@ void SALOMEDS_Driver_i::Close(const SALOMEDSImpl_SComponent& theComponent)
   SALOMEDS::unlock();
   if ( !CORBA::is_nil(_driver) )
     _driver->Close(sco.in());
+  sco->UnRegister();
   SALOMEDS::lock();
 }
 
@@ -181,22 +188,22 @@ std::string SALOMEDS_Driver_i::Version()
 }
 
 std::string SALOMEDS_Driver_i::IORToLocalPersistentID(const SALOMEDSImpl_SObject& theSObject,
-                                                     const std::string& IORString,
-                                                     bool isMultiFile,
-                                                     bool isASCII)
+                                                      const std::string& IORString,
+                                                      bool isMultiFile,
+                                                      bool isASCII)
 {
   SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theSObject, _orb);
-  CORBA::String_var ior = CORBA::string_dup(IORString.c_str());
-
   SALOMEDS::unlock();
 
   std::string pstr = "";
 
   if ( !CORBA::is_nil(_driver) ) {
-    CORBA::String_var pers_string =_driver->IORToLocalPersistentID(so.in(), ior.in(), isMultiFile, isASCII);
+    CORBA::String_var pers_string =_driver->IORToLocalPersistentID(so.in(), IORString.c_str(),
+                                                                   isMultiFile, isASCII);
     pstr = pers_string;
   }
 
+  so->UnRegister();
   SALOMEDS::lock();
 
   return pstr;
@@ -204,9 +211,9 @@ std::string SALOMEDS_Driver_i::IORToLocalPersistentID(const SALOMEDSImpl_SObject
 
 
 std::string SALOMEDS_Driver_i::LocalPersistentIDToIOR(const SALOMEDSImpl_SObject& theObject,
-                                                     const std::string& aLocalPersistentID,
-                                                     bool isMultiFile,
-                                                     bool isASCII)
+                                                      const std::string& aLocalPersistentID,
+                                                      bool isMultiFile,
+                                                      bool isASCII)
 {
   SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theObject, _orb);
   CORBA::String_var pers_string = CORBA::string_dup(aLocalPersistentID.c_str());
@@ -218,7 +225,7 @@ std::string SALOMEDS_Driver_i::LocalPersistentIDToIOR(const SALOMEDSImpl_SObject
     CORBA::String_var IOR = _driver->LocalPersistentIDToIOR(so.in(), pers_string.in(), isMultiFile, isASCII);
     ior = IOR;
   }
-
+  so->UnRegister();
   SALOMEDS::lock();
   return ior;
 }
@@ -256,6 +263,8 @@ SALOMEDSImpl_TMPFile* SALOMEDS_Driver_i::CopyFrom(const SALOMEDSImpl_SObject& th
   SALOMEDSImpl_TMPFile* aTMPFile = new SALOMEDS_TMPFile_i(aStream._retn());
   theStreamLength = aTMPFile->Size();
   theObjectID = anObjectID;
+
+  so->UnRegister();
   SALOMEDS::lock();
 
   return aTMPFile;
@@ -274,9 +283,9 @@ bool SALOMEDS_Driver_i::CanPaste(const std::string& theComponentName, int theObj
 }
 
 std::string SALOMEDS_Driver_i::PasteInto(const unsigned char* theStream,
-                                        const long theStreamLength,
-                                        int theObjectID,
-                                        const SALOMEDSImpl_SObject& theObject)
+                                         const long theStreamLength,
+                                         int theObjectID,
+                                         const SALOMEDSImpl_SObject& theObject)
 {
   SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theObject, _orb);
   CORBA::Octet* anOctetBuf =  (CORBA::Octet*)theStream;
@@ -296,6 +305,7 @@ std::string SALOMEDS_Driver_i::PasteInto(const unsigned char* theStream,
     entry = ret_so->GetID();
   }
 
+  so->UnRegister();
   SALOMEDS::lock();
 
   return entry;