From 3bec9e87eb9d1379b63394bdd88fbf0b8bbb9b6a Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 14 Dec 2012 14:05:32 +0000 Subject: [PATCH] 21948: EDF SMESH : Memory is not freed when deleting a mesh + typedef SALOME::GenericObj_wrap< GEOM_Object > GEOM_Object_wrap; + // + // wrappers of operations + typedef SALOME::GenericObj_wrap< GEOM_IBasicOperations > GEOM_IBasicOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_ITransformOperations> GEOM_ITransformOperations_wrap; + ... --- src/GEOMBase/GEOM_GenericObjPtr.h | 33 ++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/GEOMBase/GEOM_GenericObjPtr.h b/src/GEOMBase/GEOM_GenericObjPtr.h index b4ece1236..f764af96c 100644 --- a/src/GEOMBase/GEOM_GenericObjPtr.h +++ b/src/GEOMBase/GEOM_GenericObjPtr.h @@ -30,6 +30,8 @@ #include "SALOMEconfig.h" #include CORBA_SERVER_HEADER(GEOM_Gen) +#include + namespace GEOM { /*! @@ -87,15 +89,15 @@ namespace GEOM void Register() { if ( !CORBA::is_nil( this->myObject ) ) - this->myObject->Register(); + this->myObject->Register(); } //! Decrement counter for the object. void UnRegister() { if ( !CORBA::is_nil( this->myObject ) ) { - this->myObject->UnRegister(); - this->myObject = TInterface::_nil(); + this->myObject->UnRegister(); + this->myObject = TInterface::_nil(); } } @@ -231,6 +233,31 @@ namespace GEOM typedef GenericObjPtr AdvancedOpPtr; template<> bool GEOMBASE_EXPORT GenericObjPtr::isSame( GEOM::GEOM_Object_ptr theLeft, GEOM::GEOM_Object_ptr theRight ); + + + // Declare a type to replace GEOM::GEOM_Object_var by GEOM::GEOM_Object_wrap, + // to be used in the case if a new GEOM_Object is received, in which case + // obj->UnRegister() must be called to avoid a memory leak. + // The GEOM::GEOM_Object_wrap object calls UnRegister() at destruction. + // A simple rule: use GEOM::GEOM_Object_wrap if an object is returned by a + // GEOM operation (GEOM::GEOM_IBasicOperations etc). + // + typedef SALOME::GenericObj_wrap< GEOM_Object > GEOM_Object_wrap; + // + // wrappers of operations + typedef SALOME::GenericObj_wrap< GEOM_IBasicOperations > GEOM_IBasicOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_ITransformOperations> GEOM_ITransformOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_I3DPrimOperations > GEOM_I3DPrimOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_IShapesOperations > GEOM_IShapesOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_IBlocksOperations > GEOM_IBlocksOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_IBooleanOperations > GEOM_IBooleanOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_ICurvesOperations > GEOM_ICurvesOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_ILocalOperations > GEOM_ILocalOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_IHealingOperations > GEOM_IHealingOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_IInsertOperations > GEOM_IInsertOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_IMeasureOperations > GEOM_IMeasureOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_IGroupOperations > GEOM_IGroupOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_IAdvancedOperations > GEOM_IAdvancedOperations_wrap; } #endif // GEOM_GenericObjPtr_H -- 2.39.2