]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Removed unnecessary CORBA::release statements. Added _retn() to CORBA objects returne...
authorsrn <srn@opencascade.com>
Wed, 13 Apr 2005 12:07:47 +0000 (12:07 +0000)
committersrn <srn@opencascade.com>
Wed, 13 Apr 2005 12:07:47 +0000 (12:07 +0000)
src/SALOMEDS/SALOMEDS_GenericAttribute.cxx
src/SALOMEDS/SALOMEDS_SComponent.cxx
src/SALOMEDS/SALOMEDS_SObject.cxx
src/SALOMEDS/SALOMEDS_Study.cxx
src/SALOMEDS/SALOMEDS_StudyBuilder.cxx
src/SALOMEDS/SALOMEDS_StudyManager.cxx

index 0108f4ae58095e30eee51d59d7b235e47b3c4859..efea81cc08582dc4fa95102beccffaf08df3a26e 100644 (file)
@@ -49,7 +49,6 @@ SALOMEDS_GenericAttribute::SALOMEDS_GenericAttribute(SALOMEDS::GenericAttribute_
 
 SALOMEDS_GenericAttribute::~SALOMEDS_GenericAttribute() 
 {
-  //if(!_isLocal) CORBA::release(_corba_impl);
 }
 
 void SALOMEDS_GenericAttribute::CheckLocked() 
index 7501232508ca01aa879bda1e1fcd9f587ed228c4..334f9355cd23f00d0cf9034035fe542b69dec00c 100644 (file)
@@ -42,8 +42,7 @@ bool SALOMEDS_SComponent::ComponentIOR(std::string& theID)
   else {
     CORBA::String_var anIOR;
     ret = (SALOMEDS::SComponent::_narrow(GetCORBAImpl()))->ComponentIOR(anIOR.out());
-    theID = std::string(anIOR.in());
-               
+    theID = std::string(anIOR.in());                   
   }
 
   return ret;
@@ -53,7 +52,9 @@ SALOMEDS::SComponent_ptr SALOMEDS_SComponent::GetSComponent()
 {
   if(_isLocal) {
     if(!CORBA::is_nil(_corba_impl)) return SALOMEDS::SComponent::_narrow(GetCORBAImpl());
-    return SALOMEDS_SComponent_i::New(Handle(SALOMEDSImpl_SComponent)::DownCast(GetLocalImpl()), _orb);
+    SALOMEDS::SComponent_var aSCO = SALOMEDS_SComponent_i::New(Handle(SALOMEDSImpl_SComponent)::DownCast(GetLocalImpl()),
+                                                              _orb);
+    return aSCO._retn();
   }
   else {
     return SALOMEDS::SComponent::_narrow(GetCORBAImpl());
index 9958da4ce2b2340dafe226f8d71a6ead8e8697ae..1ba9a99482481ed5c16fb40a398a45c8a9f17c66 100644 (file)
@@ -60,7 +60,6 @@ SALOMEDS_SObject::SALOMEDS_SObject(const Handle(SALOMEDSImpl_SObject)& theSObjec
 
 SALOMEDS_SObject::~SALOMEDS_SObject()
 {
-  //if(!_isLocal) CORBA::release(_corba_impl);
 }
 
 std::string SALOMEDS_SObject::GetID()
@@ -224,11 +223,16 @@ int SALOMEDS_SObject::Depth()
 
 CORBA::Object_ptr SALOMEDS_SObject::GetObject()
 {
+  CORBA::Object_var obj;
   if(_isLocal) {
     std::string anIOR = GetIOR();
-    return _orb->string_to_object(anIOR.c_str());
+    obj = _orb->string_to_object(anIOR.c_str());
+    return obj._retn();
+  }
+  else {
+    obj = _corba_impl->GetObject();
+    return obj._retn();
   }
-  else return _corba_impl->GetObject();
 
   return CORBA::Object::_nil();
 }
@@ -237,7 +241,8 @@ SALOMEDS::SObject_ptr SALOMEDS_SObject::GetSObject()
 {
   if(_isLocal) {
     if(!CORBA::is_nil(_corba_impl)) return _corba_impl;
-    return SALOMEDS_SObject_i::New(_local_impl, _orb);
+    SALOMEDS::SObject_var aSO = SALOMEDS_SObject_i::New(_local_impl, _orb);
+    return aSO._retn();
   }
   else {
     return _corba_impl;
index 7f1fac0a3cb6b6940f66959ed53b29cf16acfbc3..7c7038684dce089113602c497eaaa11f812435d4 100644 (file)
@@ -538,15 +538,23 @@ void SALOMEDS_Study::init_orb()
 
 SALOMEDS::Study_ptr SALOMEDS_Study::GetStudy()
 {
-   if(_isLocal) {
-     if(!CORBA::is_nil(_corba_impl)) return _corba_impl;
-     SALOMEDS_Study_i *Study_servant = new SALOMEDS_Study_i(_local_impl, _orb);
-     SALOMEDS::Study_var Study = Study_servant->_this();
-     return Study;
-   }
-   else {
-     return _corba_impl;
-   }
+  if(_isLocal) {
+    if(!CORBA::is_nil(_corba_impl)) return _corba_impl;
+    std::string anIOR = _local_impl->GetTransientReference().ToCString();
+    SALOMEDS::Study_var aStudy;
+    if(!_local_impl->IsError() && anIOR != "") {
+      aStudy = SALOMEDS::Study::_narrow(_orb->string_to_object(anIOR.c_str()));
+    }
+    else {
+      SALOMEDS_Study_i *aStudy_servant = new SALOMEDS_Study_i(_local_impl, _orb);
+      aStudy = aStudy_servant->_this();
+      _local_impl->SetTransientReference(_orb->object_to_string(aStudy));
+    }
+    return aStudy._retn();
+  }
+  else {
+    return _corba_impl;
+  }
    
-   return SALOMEDS::Study::_nil();
+  return SALOMEDS::Study::_nil();
 }
index 8e76a248e53b1055a50cf3000818b5cb6b0850c8..ab69a2e326610785088614d54e2ea815a0cef2f5 100644 (file)
@@ -28,6 +28,7 @@ SALOMEDS_StudyBuilder::SALOMEDS_StudyBuilder(const Handle(SALOMEDSImpl_StudyBuil
   _isLocal = true;
   _local_impl = theBuilder;
   _corba_impl = SALOMEDS::StudyBuilder::_nil();
+
   init_orb();
 }
 
@@ -36,12 +37,12 @@ SALOMEDS_StudyBuilder::SALOMEDS_StudyBuilder(SALOMEDS::StudyBuilder_ptr theBuild
   _isLocal = false;
   _local_impl = NULL;
   _corba_impl = SALOMEDS::StudyBuilder::_duplicate(theBuilder);
+
   init_orb();
 }
 
 SALOMEDS_StudyBuilder::~SALOMEDS_StudyBuilder() 
 {
-  //if(!_isLocal) CORBA::release(_corba_impl);
 }
 
 SALOMEDSClient_SComponent* SALOMEDS_StudyBuilder::NewComponent(const std::string& ComponentDataType)
@@ -153,8 +154,9 @@ void SALOMEDS_StudyBuilder::LoadWith(SALOMEDSClient_SComponent* theSCO, const st
   SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(obj);
   
   if(_isLocal) {
-    SALOMEDS_Driver_i* drv = new SALOMEDS_Driver_i(aDriver, _orb);
-    bool isDone = _local_impl->LoadWith(Handle(SALOMEDSImpl_SComponent)::DownCast(aSCO->GetLocalImpl()), drv);
+    SALOMEDS_Driver_i* drv = new SALOMEDS_Driver_i(aDriver, _orb);    
+    Handle(SALOMEDSImpl_SComponent) aSCO_impl = Handle(SALOMEDSImpl_SComponent)::DownCast(aSCO->GetLocalImpl());
+    bool isDone = _local_impl->LoadWith(aSCO_impl, drv);
     delete drv;
     if(!isDone && _local_impl->IsError()) 
       THROW_SALOME_CORBA_EXCEPTION(_local_impl->GetErrorCode().ToCString(),SALOME::BAD_PARAM);
index 181fa4c93498a98c2503bf1023fe998a85573f4b..6a8e2f6492a3b256d7798dbff53bdc252038ca14 100644 (file)
@@ -52,7 +52,6 @@ SALOMEDS_StudyManager::SALOMEDS_StudyManager(SALOMEDS::StudyManager_ptr theManag
 
 SALOMEDS_StudyManager::~SALOMEDS_StudyManager()
 {
-  //if(!_isLocal) CORBA::release(_corba_impl);
 }
 
 SALOMEDSClient_Study* SALOMEDS_StudyManager::NewStudy(const std::string& study_name)