From 9586144b53060ac2e6e83aaa435f05ed71e9c7f0 Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 24 Sep 2012 11:25:47 +0000 Subject: [PATCH] + EventListenerData* GetEventListenerData(const std::string& listenerName) const; --- src/SMESH/SMESH_subMesh.cxx | 28 ++++++++++++++++++++++++++-- src/SMESH/SMESH_subMesh.hxx | 7 +++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/SMESH/SMESH_subMesh.cxx b/src/SMESH/SMESH_subMesh.cxx index e4060d0c2..d048ce2b0 100644 --- a/src/SMESH/SMESH_subMesh.cxx +++ b/src/SMESH/SMESH_subMesh.cxx @@ -2097,6 +2097,23 @@ EventListenerData* SMESH_subMesh::GetEventListenerData(EventListener* listener) return 0; } +//================================================================================ +/*! + * \brief Return an event listener data + * \param listenerName - the listener name + * \retval EventListenerData* - found data, maybe NULL + */ +//================================================================================ + +EventListenerData* SMESH_subMesh::GetEventListenerData(const string& listenerName) const +{ + map< EventListener*, EventListenerData* >::const_iterator l_d = _eventListeners.begin(); + for ( ; l_d != _eventListeners.end(); ++l_d ) + if ( listenerName == l_d->first->GetName() ) + return l_d->second; + return 0; +} + //================================================================================ /*! * \brief Notify stored event listeners on the occured event @@ -2137,8 +2154,15 @@ void SMESH_subMesh::DeleteEventListener(EventListener* listener) map< EventListener*, EventListenerData* >::iterator l_d = _eventListeners.find( listener ); if ( l_d != _eventListeners.end() ) { - if ( l_d->first && l_d->first->IsDeletable() ) delete l_d->first; - if ( l_d->second && l_d->second->IsDeletable() ) delete l_d->second; + if ( l_d->first && l_d->first->IsDeletable() ) + { + l_d->first->BeforeDelete( this, l_d->second ); + delete l_d->first; + } + if ( l_d->second && l_d->second->IsDeletable() ) + { + delete l_d->second; + } _eventListeners.erase( l_d ); } } diff --git a/src/SMESH/SMESH_subMesh.hxx b/src/SMESH/SMESH_subMesh.hxx index 028a249b2..057f532a7 100644 --- a/src/SMESH/SMESH_subMesh.hxx +++ b/src/SMESH/SMESH_subMesh.hxx @@ -138,6 +138,13 @@ class SMESH_EXPORT SMESH_subMesh */ EventListenerData* GetEventListenerData(EventListener* listener) const; + /*! + * \brief Return an event listener data + * \param listenerName - the listener name + * \retval EventListenerData* - found data, maybe NULL + */ + EventListenerData* GetEventListenerData(const std::string& listenerName) const; + /*! * \brief Unregister the listener and delete it and it's data * \param listener - the event listener to delete -- 2.39.2