]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
CCAR: remove some memory leaks in SALOMEDS CORBA interface
authorcaremoli <caremoli>
Wed, 26 Aug 2009 07:26:06 +0000 (07:26 +0000)
committercaremoli <caremoli>
Wed, 26 Aug 2009 07:26:06 +0000 (07:26 +0000)
18 files changed:
src/DF/DF_Document.cxx
src/NamingService/SALOME_NamingServicePy.py
src/SALOMEDS/SALOMEDS_ChildIterator_i.hxx
src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx
src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx
src/SALOMEDS/SALOMEDS_SComponentIterator_i.hxx
src/SALOMEDS/SALOMEDS_SComponent_i.cxx
src/SALOMEDS/SALOMEDS_SObject_i.cxx
src/SALOMEDS/SALOMEDS_SObject_i.hxx
src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx
src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx
src/SALOMEDS/SALOMEDS_StudyManager_i.cxx
src/SALOMEDS/SALOMEDS_Study_i.cxx
src/SALOMEDS/SALOMEDS_Study_i.hxx
src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.hxx
src/SALOMEDS/SALOMEDS_UseCaseIterator_i.hxx
src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx
src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx

index 5840bc330439a657f2336a906f7fa590b6c2d7dd..6037f4ef30d0153174bb90496e57354d79e1f5ae 100644 (file)
@@ -103,6 +103,7 @@ void DF_Document::Clear()
     delete vn[i];
 
   _root._node->Reset();
+  delete _root._node;
 }
 
 //Returns true if this document is empty
index 3797ae9616e7e29bc9112f2511cf829acce3c845..92ad1360a1c47e01ddebf60777c3d180a94d118f 100644 (file)
@@ -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
index 057312b44128c960df5a472419fd0dda21479810..09ac451e5c347eecfe9f6cc09b8e8080d6808748 100644 (file)
@@ -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:
 
index c68177b5c1d5e2ef03b21696a7026e4148e79143..f8150e9e0716b8af9df91ce33181120d2c2507ef 100644 (file)
@@ -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;
index 8b2893947135dedcaebd68ffb1a78452ced6c623..69fc111fb77a7c78de2430be146e3edfa5ae8be4 100644 (file)
@@ -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);
   
index ff2e8f16d7a06301109ada53e18c477c8b9a4888..1b9e1680c8312b9e8bfc11f143610d1f424dd4ff 100644 (file)
@@ -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:
index cbe8ed3370d3b0723d94c340b5c7fd7a6a622fab..48d71ed7de4595134869d612fa37ef157e580ace 100644 (file)
@@ -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();
 }    
 
 //============================================================================
index 985423a5202a42ca7fa1401d891e56dd759a1ee4..6842edc3f84eb057cfdf7c911fdc198c810f40be 100644 (file)
@@ -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();
 }
 
 
index abf5fd3b3bb0ebf8bd9d11953d07380667b91c2e..7190778f3f1ed040df9aa67ef4d2b13703421b0e 100644 (file)
@@ -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:
index 4f6cb05965e632971df67f308fd1d4bfe254dd71..e33d710f108c90fbec55e1e9b3a5966fa1dedb41 100644 (file)
@@ -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);
 }
 
index 99d0a3af4ebe311649da3f63202a7c277753ea3f..caa92dea992e4e416ef1cd1404c19ffededec3ad 100644 (file)
@@ -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:
     
index c579fa47fa0f371998e9e80836beb31846dc0cce..f2759d888e6812c961703694a50d241f583d38c8 100644 (file)
@@ -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();
 }
 
 //============================================================================
index 3ec35db2baa21a109202a585ec622b539ed92820..fb0e28abdf407df09442b4e09ede8351b8ca64f5 100644 (file)
@@ -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
         {
index 307f09fb2cf745227bd40cedadaf765c532a743e..52ada453c2b36b400a83fdb510c08abcde100572 100644 (file)
@@ -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;    
 
index 864646a0a8fe310dcdf7ff3f0bae46f13416bc36..af1e5bbed25e4d820b25cbb5c756d31288c7d369 100644 (file)
@@ -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:
index d40276d793d7dfb6881e33387956e0eb1ef639d9..0c935f9ea418a297f922cfa6145806cb5596b5ea 100644 (file)
@@ -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:
index 7514c85bc6f8fdeae542533e645d0d320118579a..7d40c15dbb10c51dfd3391b5fdaec2e6bbb858b7 100644 (file)
@@ -79,7 +79,11 @@ SALOMEDSImpl_Study::SALOMEDSImpl_Study(const DF_Document* doc,
  */
 //============================================================================
 SALOMEDSImpl_Study::~SALOMEDSImpl_Study()
-{}
+{
+  delete _builder;
+  delete _cb;
+  delete _useCaseBuilder;
+}
 
 //============================================================================
 /*! Function : GetPersistentReference
index 69376ec3bca8bc55ead3139389dc2f25789cfe51..001e2d3fdef2b5a03f084be0a25d791659536cca 100644 (file)
@@ -80,6 +80,7 @@ SALOMEDSImpl_StudyManager::SALOMEDSImpl_StudyManager()
 //============================================================================
 SALOMEDSImpl_StudyManager::~SALOMEDSImpl_StudyManager()
 {
+  _appli->Close(_clipboard);
   // Destroy application
   delete _appli;    
 }