From 35acab1199ad17313b677ec234f1d34d6724182d Mon Sep 17 00:00:00 2001 From: jfa Date: Thu, 5 Jul 2007 11:05:54 +0000 Subject: [PATCH] Inherit MULTIPR_Obj from GenericObj to provide correct removal of it on study closure. --- idl/MULTIPR.idl | 2 +- src/MULTIPR/MULTIPR_i.cxx | 35 +++++++++++------------------------ src/MULTIPR/MULTIPR_i.hxx | 8 ++++++-- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/idl/MULTIPR.idl b/idl/MULTIPR.idl index d571fd8..c4d9511 100644 --- a/idl/MULTIPR.idl +++ b/idl/MULTIPR.idl @@ -35,7 +35,7 @@ typedef sequence string_array; // Interface of the %MULTIPR component used to manage partition/decimation //************************************************************************* -interface MULTIPR_Obj +interface MULTIPR_Obj : SALOME::GenericObj { //--------------------------------------------------------------------- diff --git a/src/MULTIPR/MULTIPR_i.cxx b/src/MULTIPR/MULTIPR_i.cxx index ce51c25..ada3ff3 100644 --- a/src/MULTIPR/MULTIPR_i.cxx +++ b/src/MULTIPR/MULTIPR_i.cxx @@ -308,7 +308,7 @@ void MULTIPR_Gen_i::decimePartition( MULTIPR_ORB::MULTIPR_Obj_ptr MULTIPR_Gen_i::getObject (const char* medFilename) throw (SALOME::SALOME_Exception) { - MULTIPR_Obj_i* obj = new MULTIPR_Obj_i(medFilename); + MULTIPR_Obj_i* obj = new MULTIPR_Obj_i(_poa, medFilename); obj->setEngine(this); // Dump Python @@ -318,9 +318,13 @@ MULTIPR_ORB::MULTIPR_Obj_ptr MULTIPR_Gen_i::getObject (const char* medFilename) } -MULTIPR_Obj_i::MULTIPR_Obj_i (const char* medFilename, bool isPersistence, bool isMultifile) +MULTIPR_Obj_i::MULTIPR_Obj_i (PortableServer::POA_ptr thePOA, + const char* medFilename, + bool isPersistence, + bool isMultifile) throw (SALOME::SALOME_Exception) - : mBoxing(100), + : SALOME::GenericObj_i(thePOA), + mBoxing(100), _engine(NULL), mIsTmp(isPersistence && !isMultifile) { @@ -363,7 +367,7 @@ MULTIPR_Obj_i::~MULTIPR_Obj_i() system(cmd_rm.c_str()); } - cout << "MULTIPR: Destructor: remove mObj" << endl; + if(MYDEBUG) MESSAGE("MULTIPR_Obj_i: Destructor: remove mObj"); delete mObj; mObj = NULL; } @@ -838,25 +842,7 @@ char* MULTIPR_Gen_i::ComponentDataType() */ void MULTIPR_Gen_i::Close (SALOMEDS::SComponent_ptr theComponent) { - if(MYDEBUG) MESSAGE( "MULTIPR_Gen_i::Close" ); - - // Clear study contexts data - //_impl->Close(theComponent->GetStudy()->StudyId()); - - // Destroy all objects - SALOMEDS::Study_ptr aStudy = theComponent->GetStudy(); - SALOMEDS::ChildIterator_ptr obj_it (aStudy->NewChildIterator(theComponent)); - for (; obj_it->More(); obj_it->Next()) - { - SALOMEDS::SObject_ptr aSObj = obj_it->Value(); - CORBA::Object_var anObj = aSObj->GetObject(); - MULTIPR_ORB::MULTIPR_Obj_ptr obj = MULTIPR_ORB::MULTIPR_Obj::_narrow(anObj); - if (!CORBA::is_nil(obj)) - { - //obj->Destroy(); - CORBA::Object_Helper::release(obj); - } - } + if(MYDEBUG) MESSAGE("MULTIPR_Gen_i::Close"); } /*! Save MULTIPR module's data @@ -1228,7 +1214,8 @@ char* MULTIPR_Gen_i::LocalPersistentIDToIOR (SALOMEDS::SObject_ptr /*theSObject* // create MULTIPR_Obj from file //MULTIPR_ORB::MULTIPR_Obj_ptr obj = getObject(medFilename.c_str()); - MULTIPR_Obj_i* obj_i = new MULTIPR_Obj_i (medFilename.c_str(), + MULTIPR_Obj_i* obj_i = new MULTIPR_Obj_i (_poa, + medFilename.c_str(), /*isPersistence = */true, isMultiFile); obj_i->setEngine(this); diff --git a/src/MULTIPR/MULTIPR_i.hxx b/src/MULTIPR/MULTIPR_i.hxx index cb47bef..fc3ff82 100644 --- a/src/MULTIPR/MULTIPR_i.hxx +++ b/src/MULTIPR/MULTIPR_i.hxx @@ -24,6 +24,8 @@ #include "SALOME_Component_i.hxx" #include "Utils_CorbaException.hxx" +#include "SALOME_GenericObj_i.hh" + #include "MULTIPR_Obj.hxx" #include @@ -39,7 +41,8 @@ class MULTIPR_Gen_i; //***************************************************************************** class MULTIPR_Obj_i : - public POA_MULTIPR_ORB::MULTIPR_Obj + public POA_MULTIPR_ORB::MULTIPR_Obj, + public virtual SALOME::GenericObj_i { public: @@ -49,7 +52,8 @@ public: * Associate a MED file (sequential or distributed) with this object. * \param pMEDFilename MED file to be associated with this object. */ - MULTIPR_Obj_i (const char* pMEDFilename, + MULTIPR_Obj_i (PortableServer::POA_ptr thePOA, + const char* pMEDFilename, bool isPersistence = false, bool isMultifile = false) throw (SALOME::SALOME_Exception); -- 2.39.2