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 );
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 );
}
}
// ------------------------------------------------------------------
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)
struct SMESH_subMeshEventListenerData
{
- //!< to recognize data type
- int myType;
- //!< generally: submeshes depending on the one storing this data
- std::list<SMESH_subMesh*> mySubMeshes;
- //!< subMesh where data
+ bool myIsDeletable; //!< if true, it will be deleted by SMESH_subMesh
+ int myType; //!< to recognize data type
+ std::list<SMESH_subMesh*> 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.
* \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;
srcMesh->GetSubMesh( _sourceHypo->GetSourceEdge() );
if ( srcEdgeSM != subMesh )
- subMesh->SetEventListener( new SMESH_subMeshEventListener(),
+ subMesh->SetEventListener( new SMESH_subMeshEventListener(true),
SMESH_subMeshEventListenerData::MakeData( subMesh ),
srcEdgeSM );
}
SMESH_subMesh* srcFaceSM =
srcMesh->GetSubMesh( _sourceHypo->GetSourceFace() );
- subMesh->SetEventListener( new SMESH_subMeshEventListener(),
+ subMesh->SetEventListener( new SMESH_subMeshEventListener(true),
SMESH_subMeshEventListenerData::MakeData( subMesh ),
srcFaceSM );
}
srcMesh->GetSubMesh( _sourceHypo->GetSource3DShape() );
if ( srcShapeSM != subMesh )
- subMesh->SetEventListener( new SMESH_subMeshEventListener(),
+ subMesh->SetEventListener( new SMESH_subMeshEventListener(true),
SMESH_subMeshEventListenerData::MakeData( subMesh ),
srcShapeSM );
}