From: eap Date: Thu, 9 Feb 2012 13:11:58 +0000 (+0000) Subject: 0021375: EDF 1671 SMESH: Dump study of current state X-Git-Tag: V6_5_0a1~149 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=785e19b0ca3957d7727f89113bcb68f1bdb9e4da;p=modules%2Fsmesh.git 0021375: EDF 1671 SMESH: Dump study of current state avoid crash at deletion of SMESH_subMesh::myOwnListeners at mesh removal - std::list< std::pair< SMESH_subMesh*, EventListener* > > myOwnListeners; + struct OwnListenerData { + ... + }; + std::list< OwnListenerData > myOwnListeners; --- diff --git a/src/SMESH/SMESH_subMesh.cxx b/src/SMESH/SMESH_subMesh.cxx index bd99a9548..68b1eeef2 100644 --- a/src/SMESH/SMESH_subMesh.cxx +++ b/src/SMESH/SMESH_subMesh.cxx @@ -1992,14 +1992,26 @@ SMESH_Hypothesis::Hypothesis_Status return SMESH_Hypothesis::HYP_OK; } +//================================================================================ +/*! + * \brief Constructor of OwnListenerData + */ +//================================================================================ + +SMESH_subMesh::OwnListenerData::OwnListenerData( SMESH_subMesh* sm, EventListener* el): + mySubMesh( sm ), + myMeshID( sm ? sm->GetFather()->GetId() : -1 ), + mySubMeshID( sm ? sm->GetId() : -1 ), + myListener( el ) +{ +} + //================================================================================ /*! * \brief Sets an event listener and its data to a submesh * \param listener - the listener to store * \param data - the listener data to store * \param where - the submesh to store the listener and it's data - * \param deleteListener - if true then the listener will be deleted as - * it is removed from where submesh * * It remembers the submesh where it puts the listener in order to delete * them when HYP_OK algo_state is lost @@ -2013,7 +2025,7 @@ void SMESH_subMesh::SetEventListener(EventListener* listener, { if ( listener && where ) { where->SetEventListener( listener, data ); - myOwnListeners.push_back( make_pair( where, listener )); + myOwnListeners.push_back( OwnListenerData( where, listener )); } } @@ -2112,9 +2124,15 @@ void SMESH_subMesh::DeleteEventListener(EventListener* listener) void SMESH_subMesh::DeleteOwnListeners() { - list< pair< SMESH_subMesh*, EventListener* > >::iterator sm_l; - for ( sm_l = myOwnListeners.begin(); sm_l != myOwnListeners.end(); ++sm_l) - sm_l->first->DeleteEventListener( sm_l->second ); + list< OwnListenerData >::iterator d; + for ( d = myOwnListeners.begin(); d != myOwnListeners.end(); ++d ) + { + if ( !_father->MeshExists( d->myMeshID )) + continue; + if ( _father->GetId() == d->myMeshID && !_father->GetSubMeshContaining( d->mySubMeshID )) + continue; + d->mySubMesh->DeleteEventListener( d->myListener ); + } myOwnListeners.clear(); } diff --git a/src/SMESH/SMESH_subMesh.hxx b/src/SMESH/SMESH_subMesh.hxx index 744d81631..5ea617531 100644 --- a/src/SMESH/SMESH_subMesh.hxx +++ b/src/SMESH/SMESH_subMesh.hxx @@ -153,7 +153,14 @@ protected: //!< event listeners to notify std::map< EventListener*, EventListenerData* > myEventListeners; //!< event listeners to delete when HYP_OK algo_state is lost - std::list< std::pair< SMESH_subMesh*, EventListener* > > myOwnListeners; + struct OwnListenerData { + SMESH_subMesh* mySubMesh; + int myMeshID; // id of mySubMesh->GetFather() + int mySubMeshID; + EventListener* myListener; + OwnListenerData( SMESH_subMesh* sm=0, EventListener* el=0); + }; + std::list< OwnListenerData > myOwnListeners; /*! * \brief Sets an event listener and its data to a submesh