From: caremoli Date: Wed, 26 Aug 2009 07:26:06 +0000 (+0000) Subject: CCAR: remove some memory leaks in SALOMEDS CORBA interface X-Git-Tag: V5_1_3rc1~81 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4a76ece6017b9d8c11e8fea446cca49f4d123272;p=modules%2Fkernel.git CCAR: remove some memory leaks in SALOMEDS CORBA interface --- diff --git a/src/DF/DF_Document.cxx b/src/DF/DF_Document.cxx index 5840bc330..6037f4ef3 100644 --- a/src/DF/DF_Document.cxx +++ b/src/DF/DF_Document.cxx @@ -103,6 +103,7 @@ void DF_Document::Clear() delete vn[i]; _root._node->Reset(); + delete _root._node; } //Returns true if this document is empty diff --git a/src/NamingService/SALOME_NamingServicePy.py b/src/NamingService/SALOME_NamingServicePy.py index 3797ae961..92ad1360a 100644 --- a/src/NamingService/SALOME_NamingServicePy.py +++ b/src/NamingService/SALOME_NamingServicePy.py @@ -52,13 +52,15 @@ class SALOME_NamingServicePy_i(object): #------------------------------------------------------------------------- - def __init__(self, orb): + def __init__(self, orb=None): """ Standard Constructor, with ORB reference. Initializes the naming service root context """ #MESSAGE ( "SALOME_NamingServicePy_i::__init__" ) + if orb is None: + orb=CORBA.ORB_init([''], CORBA.ORB_ID) self._orb = orb # initialize root context and current context ok = 0 diff --git a/src/SALOMEDS/SALOMEDS_ChildIterator_i.hxx b/src/SALOMEDS/SALOMEDS_ChildIterator_i.hxx index 057312b44..09ac451e5 100644 --- a/src/SALOMEDS/SALOMEDS_ChildIterator_i.hxx +++ b/src/SALOMEDS/SALOMEDS_ChildIterator_i.hxx @@ -43,7 +43,7 @@ class SALOMEDS_ChildIterator_i: public virtual POA_SALOMEDS::ChildIterator, public virtual SALOME::GenericObj_i { private: - CORBA::ORB_ptr _orb; + CORBA::ORB_var _orb; SALOMEDSImpl_ChildIterator* _it; public: diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx index c68177b5c..f8150e9e0 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx @@ -50,6 +50,10 @@ SALOMEDS_GenericAttribute_i::SALOMEDS_GenericAttribute_i(DF_Attribute* theImpl, _impl = theImpl; } +SALOMEDS_GenericAttribute_i::~SALOMEDS_GenericAttribute_i() +{ +} + void SALOMEDS_GenericAttribute_i::CheckLocked() throw (SALOMEDS::GenericAttribute::LockProtection) { SALOMEDS::Locker lock; diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx index 8b2893947..69fc111fb 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx @@ -41,11 +41,11 @@ class Standard_EXPORT SALOMEDS_GenericAttribute_i: public virtual POA_SALOMEDS:: protected: DF_Attribute* _impl; - CORBA::ORB_ptr _orb; + CORBA::ORB_var _orb; public: SALOMEDS_GenericAttribute_i(DF_Attribute* theImpl, CORBA::ORB_ptr theOrb); - virtual ~SALOMEDS_GenericAttribute_i() {}; + virtual ~SALOMEDS_GenericAttribute_i(); void CheckLocked() throw (SALOMEDS::GenericAttribute::LockProtection); diff --git a/src/SALOMEDS/SALOMEDS_SComponentIterator_i.hxx b/src/SALOMEDS/SALOMEDS_SComponentIterator_i.hxx index ff2e8f16d..1b9e1680c 100644 --- a/src/SALOMEDS/SALOMEDS_SComponentIterator_i.hxx +++ b/src/SALOMEDS/SALOMEDS_SComponentIterator_i.hxx @@ -45,7 +45,7 @@ class SALOMEDS_SComponentIterator_i:public virtual POA_SALOMEDS::SComponentItera private: - CORBA::ORB_ptr _orb; + CORBA::ORB_var _orb; SALOMEDSImpl_SComponentIterator* _impl; public: diff --git a/src/SALOMEDS/SALOMEDS_SComponent_i.cxx b/src/SALOMEDS/SALOMEDS_SComponent_i.cxx index cbe8ed337..48d71ed7d 100644 --- a/src/SALOMEDS/SALOMEDS_SComponent_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SComponent_i.cxx @@ -33,9 +33,8 @@ using namespace std; SALOMEDS::SComponent_ptr SALOMEDS_SComponent_i::New(const SALOMEDSImpl_SComponent& theImpl, CORBA::ORB_ptr theORB) { SALOMEDS_SComponent_i* sco_servant = new SALOMEDS_SComponent_i(theImpl, theORB); - SALOMEDS::SComponent_var sco = SALOMEDS::SComponent::_narrow(sco_servant->SComponent::_this()); - return sco._retn(); + return sco_servant->_this(); } //============================================================================ diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.cxx b/src/SALOMEDS/SALOMEDS_SObject_i.cxx index 985423a52..6842edc3f 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.cxx @@ -49,9 +49,8 @@ using namespace std; SALOMEDS::SObject_ptr SALOMEDS_SObject_i::New(const SALOMEDSImpl_SObject& theImpl, CORBA::ORB_ptr theORB) { SALOMEDS_SObject_i* so_servant = new SALOMEDS_SObject_i(theImpl, theORB); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); - return so._retn(); + return so_servant->_this(); } diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.hxx b/src/SALOMEDS/SALOMEDS_SObject_i.hxx index abf5fd3b3..7190778f3 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.hxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.hxx @@ -42,7 +42,7 @@ class Standard_EXPORT SALOMEDS_SObject_i: public virtual POA_SALOMEDS::SObject, public virtual SALOME::GenericObj_i { protected: - CORBA::ORB_ptr _orb; + CORBA::ORB_var _orb; SALOMEDSImpl_SObject* _impl; public: diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx index 4f6cb0596..e33d710f1 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx @@ -112,7 +112,8 @@ void SALOMEDS_StudyBuilder_i::RemoveComponent(SALOMEDS::SComponent_ptr aComponen SALOMEDS::Locker lock; CheckLocked(); ASSERT(!CORBA::is_nil(aComponent)); - SALOMEDSImpl_SComponent aSCO = _impl->GetOwner()->GetSComponent(aComponent->GetID()); + CORBA::String_var cid=aComponent->GetID(); + SALOMEDSImpl_SComponent aSCO = _impl->GetOwner()->GetSComponent(cid.in()); _impl->RemoveComponent(aSCO); } diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx index 99d0a3af4..caa92dea9 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx @@ -39,7 +39,7 @@ class SALOMEDS_StudyBuilder_i: public POA_SALOMEDS::StudyBuilder { private: - CORBA::ORB_ptr _orb; + CORBA::ORB_var _orb; SALOMEDSImpl_StudyBuilder* _impl; public: diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index c579fa47f..f2759d888 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -123,7 +123,7 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* study_name) MESSAGE("NewStudy : Creating the CORBA servant holding it... "); SALOMEDS_Study_i *Study_servant = new SALOMEDS_Study_i(aStudyImpl, _orb); - SALOMEDS::Study_var Study = SALOMEDS::Study::_narrow(Study_servant->_this()); + SALOMEDS::Study_var Study = Study_servant->_this(); // Register study in the naming service // Path to acces the study @@ -139,7 +139,7 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* study_name) _mapOfPOA[Study->StudyId()] = _poa; - return Study; + return Study._retn(); } //============================================================================ diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 3ec35db2b..fb0e28abd 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -426,9 +426,8 @@ SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject //Create iterator SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb); - SALOMEDS::ChildIterator_var it = SALOMEDS::ChildIterator::_narrow(it_servant->_this()); - return it; + return it_servant->_this(); } @@ -661,12 +660,13 @@ void SALOMEDS_Study_i::Close() SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator(); for (; itcomponent->More(); itcomponent->Next()) { SALOMEDS::SComponent_var sco = itcomponent->Value(); - MESSAGE ( "Look for an engine for data type :"<< sco->ComponentDataType()); + CORBA::String_var compodatatype=sco->ComponentDataType(); + MESSAGE ( "Look for an engine for data type :"<< compodatatype); // if there is an associated Engine call its method for closing CORBA::String_var IOREngine; if (sco->ComponentIOR(IOREngine)) { // we have found the associated engine to write the data - MESSAGE ( "We have found an engine for data type :"<< sco->ComponentDataType()); + MESSAGE ( "We have found an engine for data type :"<< compodatatype); //_narrow can throw a corba exception try { diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index 307f09fb2..52ada453c 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -48,7 +48,7 @@ class Standard_EXPORT SALOMEDS_Study_i: public POA_SALOMEDS::Study { private: - CORBA::ORB_ptr _orb; + CORBA::ORB_var _orb; SALOMEDSImpl_Study* _impl; SALOMEDS_StudyBuilder_i* _builder; diff --git a/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.hxx b/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.hxx index 864646a0a..af1e5bbed 100644 --- a/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.hxx +++ b/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.hxx @@ -46,7 +46,7 @@ class SALOMEDS_UseCaseBuilder_i: public virtual POA_SALOMEDS::UseCaseBuilder, { private: - CORBA::ORB_ptr _orb; + CORBA::ORB_var _orb; SALOMEDSImpl_UseCaseBuilder* _impl; public: diff --git a/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.hxx b/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.hxx index d40276d79..0c935f9ea 100644 --- a/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.hxx +++ b/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.hxx @@ -41,7 +41,7 @@ class SALOMEDS_UseCaseIterator_i: public virtual POA_SALOMEDS::UseCaseIterator, public virtual SALOME::GenericObj_i { private: - CORBA::ORB_ptr _orb; + CORBA::ORB_var _orb; SALOMEDSImpl_UseCaseIterator* _impl; public: diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index 7514c85bc..7d40c15db 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -79,7 +79,11 @@ SALOMEDSImpl_Study::SALOMEDSImpl_Study(const DF_Document* doc, */ //============================================================================ SALOMEDSImpl_Study::~SALOMEDSImpl_Study() -{} +{ + delete _builder; + delete _cb; + delete _useCaseBuilder; +} //============================================================================ /*! Function : GetPersistentReference diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx index 69376ec3b..001e2d3fd 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx @@ -80,6 +80,7 @@ SALOMEDSImpl_StudyManager::SALOMEDSImpl_StudyManager() //============================================================================ SALOMEDSImpl_StudyManager::~SALOMEDSImpl_StudyManager() { + _appli->Close(_clipboard); // Destroy application delete _appli; }