]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
0022202: EDF SMESH: Regression in a script meshing prisms and hexaedrons V7_2_0 V7_2_0_public V7_2_0rc2
authoreap <eap@opencascade.com>
Mon, 29 Apr 2013 14:18:32 +0000 (14:18 +0000)
committereap <eap@opencascade.com>
Mon, 29 Apr 2013 14:18:32 +0000 (14:18 +0000)
Fix notifyListenersOnEvent() for the case of removing an EventListener (attempt No.2)

src/SMESH/SMESH_subMesh.cxx

index ba6118097abbdb381d088f6c49961030587b1407..19df51879a632adabcfc1260007c7178aed8b9e1 100644 (file)
@@ -2258,29 +2258,22 @@ void SMESH_subMesh::notifyListenersOnEvent( const int         event,
                                             const event_type  eventType,
                                             SMESH_Hypothesis* hyp)
 {
-  set< EventListener* > notified;
-  const size_t nbListeners = _eventListeners.size();
-  while ( notified.size() != nbListeners )
+  list< pair< EventListener*, EventListenerData* > > eventListeners( _eventListeners.begin(),
+                                                                     _eventListeners.end());
+  list< pair< EventListener*, EventListenerData* > >::iterator l_d = eventListeners.begin();
+  for ( ; l_d != eventListeners.end(); ++l_d )
   {
-    map< EventListener*, EventListenerData* >::iterator l_d = _eventListeners.begin();
-    for ( ; l_d != _eventListeners.end(); ++l_d )
-    {
-      std::pair< EventListener*, EventListenerData* > li_da = *l_d;
-
-      if ( notified.insert( li_da.first ).second &&
-           li_da.first->myBusySM.insert( this ).second )
-      {
-        const bool isDeletable = li_da.first->IsDeletable();
+    std::pair< EventListener*, EventListenerData* > li_da = *l_d;
+    if ( !_eventListeners.count( li_da.first )) continue;
 
-        li_da.first->ProcessEvent( event, eventType, this, li_da.second, hyp );
+    if ( li_da.first->myBusySM.insert( this ).second )
+    {
+      const bool isDeletable = li_da.first->IsDeletable();
 
-        const bool isRemoved = !_eventListeners.count( li_da.first );
-        if ( !isDeletable || !isRemoved )
-          li_da.first->myBusySM.erase( this ); // a listener is hopefully not dead
+      li_da.first->ProcessEvent( event, eventType, this, li_da.second, hyp );
 
-        if ( isRemoved )
-          break; // restart looping on _eventListeners
-      }
+      if ( !isDeletable || !_eventListeners.count( li_da.first ))
+        li_da.first->myBusySM.erase( this ); // a listener is hopefully not dead
     }
   }
 }