mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-28 09:40:34 +05:00
0022202: EDF SMESH: Regression in a script meshing prisms and hexaedrons
Fix notifyListenersOnEvent() for the case of removing an EventListener
This commit is contained in:
parent
55e345e578
commit
36550205e6
@ -2258,19 +2258,29 @@ void SMESH_subMesh::notifyListenersOnEvent( const int event,
|
|||||||
const event_type eventType,
|
const event_type eventType,
|
||||||
SMESH_Hypothesis* hyp)
|
SMESH_Hypothesis* hyp)
|
||||||
{
|
{
|
||||||
map< EventListener*, EventListenerData* >::iterator l_d = _eventListeners.begin();
|
set< EventListener* > notified;
|
||||||
for ( ; l_d != _eventListeners.end(); )
|
const size_t nbListeners = _eventListeners.size();
|
||||||
|
while ( notified.size() != nbListeners )
|
||||||
{
|
{
|
||||||
std::pair< EventListener*, EventListenerData* > li_da = *l_d++; /* copy to enable removal
|
map< EventListener*, EventListenerData* >::iterator l_d = _eventListeners.begin();
|
||||||
of a listener from
|
for ( ; l_d != _eventListeners.end(); ++l_d )
|
||||||
_eventListeners by
|
|
||||||
its ProcessEvent() */
|
|
||||||
if ( li_da.first->myBusySM.insert( this ).second )
|
|
||||||
{
|
{
|
||||||
const size_t nbListenersBefore = _eventListeners.size();
|
std::pair< EventListener*, EventListenerData* > li_da = *l_d;
|
||||||
li_da.first->ProcessEvent( event, eventType, this, li_da.second, hyp );
|
|
||||||
if ( nbListenersBefore == _eventListeners.size() )
|
if ( notified.insert( li_da.first ).second &&
|
||||||
li_da.first->myBusySM.erase( this ); // a listener hopefully not removed
|
li_da.first->myBusySM.insert( this ).second )
|
||||||
|
{
|
||||||
|
const bool isDeletable = li_da.first->IsDeletable();
|
||||||
|
|
||||||
|
li_da.first->ProcessEvent( event, eventType, this, li_da.second, hyp );
|
||||||
|
|
||||||
|
const bool isRemoved = !_eventListeners.count( li_da.first );
|
||||||
|
if ( !isDeletable || !isRemoved )
|
||||||
|
li_da.first->myBusySM.erase( this ); // a listener is hopefully not dead
|
||||||
|
|
||||||
|
if ( isRemoved )
|
||||||
|
break; // restart looping on _eventListeners
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user