From: caremoli Date: Mon, 14 Sep 2009 08:53:21 +0000 (+0000) Subject: CCAR: remove some memory leaks in non local SALOMEDS X-Git-Tag: V5_1_3rc1~56 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a19926ca8ece482821933490b3568291f4ffc85f;p=modules%2Fkernel.git CCAR: remove some memory leaks in non local SALOMEDS --- diff --git a/src/SALOMEDS/SALOMEDS_ChildIterator.cxx b/src/SALOMEDS/SALOMEDS_ChildIterator.cxx index 5cbf2edc0..1f11e67d6 100644 --- a/src/SALOMEDS/SALOMEDS_ChildIterator.cxx +++ b/src/SALOMEDS/SALOMEDS_ChildIterator.cxx @@ -95,6 +95,9 @@ _PTR(SObject) SALOMEDS_ChildIterator::Value() SALOMEDS::Locker lock; aSO = new SALOMEDS_SObject(_local_impl->Value()); } - else aSO = new SALOMEDS_SObject(_corba_impl->Value()); + else { + SALOMEDS::SObject_var so=_corba_impl->Value(); + aSO = new SALOMEDS_SObject(so); + } return _PTR(SObject)(aSO); } diff --git a/src/SALOMEDS/SALOMEDS_Driver_i.cxx b/src/SALOMEDS/SALOMEDS_Driver_i.cxx index 1efad2868..4d851194c 100644 --- a/src/SALOMEDS/SALOMEDS_Driver_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Driver_i.cxx @@ -160,6 +160,7 @@ bool SALOMEDS_Driver_i::CanCopy(const SALOMEDSImpl_SObject& theObject) SALOMEDS::unlock(); bool isOk = _driver->CanCopy(so.in()); + so->Destroy(); SALOMEDS::lock(); return isOk; diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx b/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx index 827ea4714..a5a64b49b 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx @@ -99,7 +99,7 @@ std::string SALOMEDS_GenericAttribute::Type() aType = _local_impl->Type(); } else { - aType = _corba_impl->Type(); + aType = (CORBA::String_var)_corba_impl->Type(); } return aType; } @@ -112,7 +112,7 @@ std::string SALOMEDS_GenericAttribute::GetClassType() aType = _local_impl->GetClassType(); } else { - aType = _corba_impl->GetClassType(); + aType = (CORBA::String_var)_corba_impl->GetClassType(); } return aType; } @@ -125,7 +125,7 @@ _PTR(SObject) SALOMEDS_GenericAttribute::GetSObject() aSO = new SALOMEDS_SObject(_local_impl->GetSObject()); } else { - aSO = new SALOMEDS_SObject(_corba_impl->GetSObject()); + aSO = new SALOMEDS_SObject((SALOMEDS::SObject_var)_corba_impl->GetSObject()); } return _PTR(SObject)(aSO); @@ -148,7 +148,8 @@ SALOMEDS_GenericAttribute* SALOMEDS_GenericAttribute::CreateAttribute(SALOMEDS:: { SALOMEDS_GenericAttribute* aGA = NULL; if(!CORBA::is_nil(theGA)) { - std::string aTypeOfAttribute = theGA->GetClassType(); + CORBA::String_var astr=theGA->GetClassType(); + std::string aTypeOfAttribute = astr.in(); __CreateGenericClientAttributeCORBA } return aGA; diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx index f8150e9e0..29767e091 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx @@ -87,7 +87,7 @@ char* SALOMEDS_GenericAttribute_i::Type() return CORBA::string_dup(type.c_str()); } - return (char*)""; + return CORBA::string_dup(""); } char* SALOMEDS_GenericAttribute_i::GetClassType() @@ -98,7 +98,7 @@ char* SALOMEDS_GenericAttribute_i::GetClassType() return CORBA::string_dup(class_type.c_str()); } - return (char*)""; + return CORBA::string_dup(""); } diff --git a/src/SALOMEDS/SALOMEDS_SComponent.cxx b/src/SALOMEDS/SALOMEDS_SComponent.cxx index fe7d379fc..30edcb280 100644 --- a/src/SALOMEDS/SALOMEDS_SComponent.cxx +++ b/src/SALOMEDS/SALOMEDS_SComponent.cxx @@ -50,7 +50,12 @@ std::string SALOMEDS_SComponent::ComponentDataType() SALOMEDS::Locker lock; aType = (dynamic_cast(GetLocalImpl()))->ComponentDataType(); } - else aType = (SALOMEDS::SComponent::_narrow(GetCORBAImpl()))->ComponentDataType(); + else + { + SALOMEDS::SComponent_var aCompo=SALOMEDS::SComponent::_narrow(GetCORBAImpl()); + CORBA::String_var aString = aCompo->ComponentDataType(); + aType=aString.in(); + } return aType; } @@ -74,13 +79,13 @@ bool SALOMEDS_SComponent::ComponentIOR(std::string& theID) SALOMEDS::SComponent_ptr SALOMEDS_SComponent::GetSComponent() { if(_isLocal) { - if(!CORBA::is_nil(_corba_impl)) return SALOMEDS::SComponent::_duplicate(SALOMEDS::SComponent::_narrow(GetCORBAImpl())); + if(!CORBA::is_nil(_corba_impl)) return SALOMEDS::SComponent::_narrow(GetCORBAImpl()); SALOMEDS::SComponent_var aSCO = SALOMEDS_SComponent_i::New(*(dynamic_cast(GetLocalImpl())), _orb); _corba_impl = SALOMEDS::SComponent::_duplicate(aSCO); return aSCO._retn(); } else { - return SALOMEDS::SComponent::_duplicate(SALOMEDS::SComponent::_narrow(GetCORBAImpl())); + return SALOMEDS::SComponent::_narrow(GetCORBAImpl()); } return SALOMEDS::SComponent::_nil(); } diff --git a/src/SALOMEDS/SALOMEDS_SComponentIterator.cxx b/src/SALOMEDS/SALOMEDS_SComponentIterator.cxx index 9ee6a8e7d..5aea876c1 100644 --- a/src/SALOMEDS/SALOMEDS_SComponentIterator.cxx +++ b/src/SALOMEDS/SALOMEDS_SComponentIterator.cxx @@ -84,6 +84,6 @@ _PTR(SComponent) SALOMEDS_SComponentIterator::Value() SALOMEDS::Locker lock; aSCO = new SALOMEDS_SComponent(_local_impl->Value()); } - else aSCO = new SALOMEDS_SComponent(_corba_impl->Value()); + else aSCO = new SALOMEDS_SComponent((SALOMEDS::SComponent_var)_corba_impl->Value()); return _PTR(SComponent)(aSCO); } diff --git a/src/SALOMEDS/SALOMEDS_SObject.cxx b/src/SALOMEDS/SALOMEDS_SObject.cxx index 1c6c05b4a..28df2a5c6 100644 --- a/src/SALOMEDS/SALOMEDS_SObject.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject.cxx @@ -112,7 +112,7 @@ std::string SALOMEDS_SObject::GetID() SALOMEDS::Locker lock; aValue = _local_impl->GetID(); } - else aValue = _corba_impl->GetID(); + else aValue = (CORBA::String_var)_corba_impl->GetID(); return aValue; } @@ -122,7 +122,7 @@ _PTR(SComponent) SALOMEDS_SObject::GetFatherComponent() SALOMEDS::Locker lock; return _PTR(SComponent)(new SALOMEDS_SComponent(_local_impl->GetFatherComponent())); } - return _PTR(SComponent)(new SALOMEDS_SComponent(_corba_impl->GetFatherComponent())); + return _PTR(SComponent)(new SALOMEDS_SComponent((SALOMEDS::SComponent_var)_corba_impl->GetFatherComponent())); } _PTR(SObject) SALOMEDS_SObject::GetFather() @@ -131,7 +131,7 @@ _PTR(SObject) SALOMEDS_SObject::GetFather() SALOMEDS::Locker lock; return _PTR(SObject)(new SALOMEDS_SObject(_local_impl->GetFather())); } - return _PTR(SObject)(new SALOMEDS_SObject(_corba_impl->GetFather())); + return _PTR(SObject)(new SALOMEDS_SObject((SALOMEDS::SObject_var)_corba_impl->GetFather())); } bool SALOMEDS_SObject::FindAttribute(_PTR(GenericAttribute)& anAttribute, @@ -199,7 +199,8 @@ _PTR(Study) SALOMEDS_SObject::GetStudy() SALOMEDS::Locker lock; return _PTR(Study)(new SALOMEDS_Study(_local_impl->GetStudy())); } - return _PTR(Study)(new SALOMEDS_Study(_corba_impl->GetStudy())); + SALOMEDS::Study_var study=_corba_impl->GetStudy(); + return _PTR(Study)(new SALOMEDS_Study(study)); } std::string SALOMEDS_SObject::Name() @@ -209,7 +210,7 @@ std::string SALOMEDS_SObject::Name() SALOMEDS::Locker lock; aName = _local_impl->Name(); } - else aName = _corba_impl->Name(); + else aName = (CORBA::String_var)_corba_impl->Name(); return aName; } @@ -257,7 +258,7 @@ std::string SALOMEDS_SObject::GetName() SALOMEDS::Locker lock; aName = _local_impl->GetName(); } - else aName = _corba_impl->GetName(); + else aName = (CORBA::String_var) _corba_impl->GetName(); return aName; } @@ -269,7 +270,7 @@ std::string SALOMEDS_SObject::GetComment() SALOMEDS::Locker lock; aComment = _local_impl->GetComment(); } - else aComment = _corba_impl->GetComment(); + else aComment = (CORBA::String_var) _corba_impl->GetComment(); return aComment; } @@ -281,7 +282,7 @@ std::string SALOMEDS_SObject::GetIOR() SALOMEDS::Locker lock; anIOR = _local_impl->GetIOR(); } - else anIOR = _corba_impl->GetIOR(); + else anIOR = (CORBA::String_var) _corba_impl->GetIOR(); return anIOR; } diff --git a/src/SALOMEDS/SALOMEDS_SObject.hxx b/src/SALOMEDS/SALOMEDS_SObject.hxx index b20ceaf78..f4aec2742 100644 --- a/src/SALOMEDS/SALOMEDS_SObject.hxx +++ b/src/SALOMEDS/SALOMEDS_SObject.hxx @@ -71,7 +71,7 @@ public: CORBA::Object_ptr GetObject(); SALOMEDS::SObject_ptr GetSObject(); - SALOMEDS::SObject_ptr GetCORBAImpl() { return SALOMEDS::SObject::_duplicate(_corba_impl); } + SALOMEDS::SObject_var GetCORBAImpl() { return _corba_impl; } SALOMEDSImpl_SObject* GetLocalImpl() { return _local_impl; } private: diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.cxx b/src/SALOMEDS/SALOMEDS_SObject_i.cxx index 6842edc3f..6398b8a6e 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.cxx @@ -153,7 +153,7 @@ CORBA::Boolean SALOMEDS_SObject_i::FindAttribute (SALOMEDS::GenericAttribute_out SALOMEDS::Locker lock; DF_Attribute* anAttr = NULL; if(_impl->FindAttribute(anAttr, (char*)aTypeOfAttribute)) { - anAttribute = SALOMEDS::GenericAttribute::_duplicate(SALOMEDS_GenericAttribute_i::CreateAttribute(anAttr, _orb)); + anAttribute = SALOMEDS_GenericAttribute_i::CreateAttribute(anAttr, _orb); return true; } @@ -179,7 +179,7 @@ SALOMEDS::ListOfAttributes* SALOMEDS_SObject_i::GetAllAttributes() for(int i = 0; i < length; i++) { SALOMEDSImpl_GenericAttribute* anAttr = dynamic_cast(aSeq[i]); SALOMEDS::GenericAttribute_var anAttribute; - anAttribute = SALOMEDS::GenericAttribute::_duplicate(SALOMEDS_GenericAttribute_i::CreateAttribute(anAttr, _orb)); + anAttribute = SALOMEDS_GenericAttribute_i::CreateAttribute(anAttr, _orb); if (!CORBA::is_nil(anAttribute)) { SeqOfAttr[i] = anAttribute; }