From d4a97eee6e1615d9c49322458fc62c3a98f8330c Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 7 Dec 2006 08:29:52 +0000 Subject: [PATCH] PAL13473 (Build repetitive mesh): an arg added to constructor of SMESH_subMeshEventListener --- src/SMESH/SMESH_subMesh.cxx | 10 +++++----- src/SMESH/SMESH_subMeshEventListener.hxx | 19 ++++++++++++------- src/StdMeshers/StdMeshers_Projection_1D.cxx | 2 +- src/StdMeshers/StdMeshers_Projection_2D.cxx | 2 +- src/StdMeshers/StdMeshers_Projection_3D.cxx | 2 +- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/SMESH/SMESH_subMesh.cxx b/src/SMESH/SMESH_subMesh.cxx index d47ab027c..1701da600 100644 --- a/src/SMESH/SMESH_subMesh.cxx +++ b/src/SMESH/SMESH_subMesh.cxx @@ -1491,12 +1491,12 @@ bool SMESH_subMesh::ComputeStateEngine(int event) break; } - if ( _algoState != oldAlgoState ) + if ( _algoState != oldAlgoState || event == MODIF_HYP ) { - if (_algoState == HYP_OK && algo ) - algo->SetEventListener( this ); if ( oldAlgoState == HYP_OK ) DeleteOwnListeners(); + if (_algoState == HYP_OK && algo ) + algo->SetEventListener( this ); } NotifyListenersOnEvent( event, COMPUTE_EVENT ); @@ -1883,8 +1883,8 @@ void SMESH_subMesh::DeleteEventListener(EventListener* listener) map< EventListener*, EventListenerData* >::iterator l_d = myEventListeners.find( listener ); if ( l_d != myEventListeners.end() ) { - delete l_d->first; - delete l_d->second; + if ( l_d->first->IsDeletable() ) delete l_d->first; + if ( l_d->second->IsDeletable() ) delete l_d->second; myEventListeners.erase( l_d ); } } diff --git a/src/SMESH/SMESH_subMeshEventListener.hxx b/src/SMESH/SMESH_subMeshEventListener.hxx index 66543cf7d..f8a5fc4be 100644 --- a/src/SMESH/SMESH_subMeshEventListener.hxx +++ b/src/SMESH/SMESH_subMeshEventListener.hxx @@ -42,7 +42,10 @@ struct SMESH_subMeshEventListenerData; // ------------------------------------------------------------------ class SMESH_subMeshEventListener { + bool myIsDeletable; //!< if true, it will be deleted by SMESH_subMesh public: + SMESH_subMeshEventListener(bool isDeletable):myIsDeletable(isDeletable) {} + bool IsDeletable() const { return myIsDeletable; } /*! * \brief Do something on a certain event * \param event - algo_event or compute_event itself (of SMESH_subMesh) @@ -69,11 +72,13 @@ public: struct SMESH_subMeshEventListenerData { - //!< to recognize data type - int myType; - //!< generally: submeshes depending on the one storing this data - std::list mySubMeshes; - //!< subMesh where data + bool myIsDeletable; //!< if true, it will be deleted by SMESH_subMesh + int myType; //!< to recognize data type + std::list mySubMeshes; //!< generally: submeshes depending + // on the one storing this data +public: + SMESH_subMeshEventListenerData(bool isDeletable):myIsDeletable(isDeletable) {} + bool IsDeletable() const { return myIsDeletable; } /*! * \brief Create a default listener data. @@ -82,12 +87,12 @@ struct SMESH_subMeshEventListenerData * \retval SMESH_subMeshEventListenerData* - a new listener data * * See SMESH_subMeshEventListener::ProcessEvent() to know how the default - * listener uses it + * listener uses it (implementation is in SMESH_subMesh.cxx) */ static SMESH_subMeshEventListenerData* MakeData(SMESH_subMesh* dependentSM, const int type = 0) { - SMESH_subMeshEventListenerData* data = new SMESH_subMeshEventListenerData; + SMESH_subMeshEventListenerData* data = new SMESH_subMeshEventListenerData(true); data->mySubMeshes.push_back( dependentSM ); data->myType = type; return data; diff --git a/src/StdMeshers/StdMeshers_Projection_1D.cxx b/src/StdMeshers/StdMeshers_Projection_1D.cxx index acf89664b..bde70d395 100644 --- a/src/StdMeshers/StdMeshers_Projection_1D.cxx +++ b/src/StdMeshers/StdMeshers_Projection_1D.cxx @@ -354,7 +354,7 @@ void StdMeshers_Projection_1D::SetEventListener(SMESH_subMesh* subMesh) srcMesh->GetSubMesh( _sourceHypo->GetSourceEdge() ); if ( srcEdgeSM != subMesh ) - subMesh->SetEventListener( new SMESH_subMeshEventListener(), + subMesh->SetEventListener( new SMESH_subMeshEventListener(true), SMESH_subMeshEventListenerData::MakeData( subMesh ), srcEdgeSM ); } diff --git a/src/StdMeshers/StdMeshers_Projection_2D.cxx b/src/StdMeshers/StdMeshers_Projection_2D.cxx index 5e10f6d07..36f4a3b54 100644 --- a/src/StdMeshers/StdMeshers_Projection_2D.cxx +++ b/src/StdMeshers/StdMeshers_Projection_2D.cxx @@ -631,7 +631,7 @@ void StdMeshers_Projection_2D::SetEventListener(SMESH_subMesh* subMesh) SMESH_subMesh* srcFaceSM = srcMesh->GetSubMesh( _sourceHypo->GetSourceFace() ); - subMesh->SetEventListener( new SMESH_subMeshEventListener(), + subMesh->SetEventListener( new SMESH_subMeshEventListener(true), SMESH_subMeshEventListenerData::MakeData( subMesh ), srcFaceSM ); } diff --git a/src/StdMeshers/StdMeshers_Projection_3D.cxx b/src/StdMeshers/StdMeshers_Projection_3D.cxx index 44b4395f4..241ff7670 100644 --- a/src/StdMeshers/StdMeshers_Projection_3D.cxx +++ b/src/StdMeshers/StdMeshers_Projection_3D.cxx @@ -430,7 +430,7 @@ void StdMeshers_Projection_3D::SetEventListener(SMESH_subMesh* subMesh) srcMesh->GetSubMesh( _sourceHypo->GetSource3DShape() ); if ( srcShapeSM != subMesh ) - subMesh->SetEventListener( new SMESH_subMeshEventListener(), + subMesh->SetEventListener( new SMESH_subMeshEventListener(true), SMESH_subMeshEventListenerData::MakeData( subMesh ), srcShapeSM ); } -- 2.39.2