mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-14 04:03:46 +00:00
reformulation of subscriber message consumer
add extra safeties to subscriber message recipts and just for good measure, don't bother listening for an event that will never be triggered
This commit is contained in:
parent
12db0500e8
commit
6389b32f9b
2 changed files with 26 additions and 19 deletions
|
|
@ -79,24 +79,26 @@ bool EventManagerListener::onMessageReceived( StringTableEntry queue, const char
|
|||
if( subscribers == NULL )
|
||||
return true;
|
||||
|
||||
for( Vector<Subscriber>::iterator iter = subscribers->begin(); iter != subscribers->end(); iter++ )
|
||||
for (U32 i = 0; i < subscribers->size(); i++)
|
||||
{
|
||||
if( iter->listener == NULL )
|
||||
Subscriber* itter = &((*subscribers)[i]);
|
||||
if (itter->listener == NULL)
|
||||
{
|
||||
subscribers->erase_fast( iter -- );
|
||||
continue;
|
||||
(*subscribers).erase(i);
|
||||
}
|
||||
else if (!itter->removeFlag)
|
||||
{
|
||||
itter->callDepth++;
|
||||
Con::executef(itter->listener, itter->callback, data);
|
||||
itter->callDepth--;
|
||||
if (itter->removeFlag && itter->callDepth == 0)
|
||||
{
|
||||
(*subscribers).erase(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (!iter->removeFlag)
|
||||
{
|
||||
iter->callDepth++;
|
||||
Con::executef( iter->listener, iter->callback, data );
|
||||
iter->callDepth--;
|
||||
if (iter->removeFlag && iter->callDepth==0)
|
||||
{
|
||||
subscribers->erase_fast(iter--);
|
||||
}
|
||||
}
|
||||
if (subscribers->size() == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue