From: srn Date: Wed, 13 Apr 2005 12:07:47 +0000 (+0000) Subject: Removed unnecessary CORBA::release statements. Added _retn() to CORBA objects returne... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1980d0ed4edacb8f069204022641a1dfed44f97b;p=modules%2Fkernel.git Removed unnecessary CORBA::release statements. Added _retn() to CORBA objects returned from GetStudy. GetSObject and GetSComponent methods. --- diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx b/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx index 0108f4ae5..efea81cc0 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx @@ -49,7 +49,6 @@ SALOMEDS_GenericAttribute::SALOMEDS_GenericAttribute(SALOMEDS::GenericAttribute_ SALOMEDS_GenericAttribute::~SALOMEDS_GenericAttribute() { - //if(!_isLocal) CORBA::release(_corba_impl); } void SALOMEDS_GenericAttribute::CheckLocked() diff --git a/src/SALOMEDS/SALOMEDS_SComponent.cxx b/src/SALOMEDS/SALOMEDS_SComponent.cxx index 750123250..334f9355c 100644 --- a/src/SALOMEDS/SALOMEDS_SComponent.cxx +++ b/src/SALOMEDS/SALOMEDS_SComponent.cxx @@ -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()); diff --git a/src/SALOMEDS/SALOMEDS_SObject.cxx b/src/SALOMEDS/SALOMEDS_SObject.cxx index 9958da4ce..1ba9a9948 100644 --- a/src/SALOMEDS/SALOMEDS_SObject.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject.cxx @@ -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; diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index 7f1fac0a3..7c7038684 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -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(); } diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx index 8e76a248e..ab69a2e32 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx @@ -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); diff --git a/src/SALOMEDS/SALOMEDS_StudyManager.cxx b/src/SALOMEDS/SALOMEDS_StudyManager.cxx index 181fa4c93..6a8e2f649 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager.cxx @@ -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)