mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-05-11 13:06:40 +03:00
Fixed BroadcastEvent not returning true with 1 processed listener + Fixed UnregisterTarget not removing the name
This commit is contained in:
parent
7e66483b1a
commit
43bb5ce653
1 changed files with 34 additions and 15 deletions
|
@ -3035,11 +3035,13 @@ BroadcastEvent
|
||||||
*/
|
*/
|
||||||
bool Listener::BroadcastEvent(const_str name, Event& event)
|
bool Listener::BroadcastEvent(const_str name, Event& event)
|
||||||
{
|
{
|
||||||
|
ConList* listeners;
|
||||||
|
|
||||||
if (!m_NotifyList) {
|
if (!m_NotifyList) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConList *listeners = m_NotifyList->findKeyValue(name);
|
listeners = m_NotifyList->findKeyValue(name);
|
||||||
|
|
||||||
if (!listeners) {
|
if (!listeners) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -3057,7 +3059,10 @@ Broadcast an event to the notify list
|
||||||
*/
|
*/
|
||||||
bool Listener::BroadcastEvent(Event& event, ConList *listeners)
|
bool Listener::BroadcastEvent(Event& event, ConList *listeners)
|
||||||
{
|
{
|
||||||
|
Listener* listener;
|
||||||
int num = listeners->NumObjects();
|
int num = listeners->NumObjects();
|
||||||
|
int i;
|
||||||
|
bool found;
|
||||||
|
|
||||||
if (!num) {
|
if (!num) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -3068,16 +3073,26 @@ bool Listener::BroadcastEvent(Event& event, ConList *listeners)
|
||||||
|
|
||||||
if (listener) {
|
if (listener) {
|
||||||
listener->ProcessEvent(event);
|
listener->ProcessEvent(event);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConList listenersCopy = *listeners;
|
ConList listenersCopy;
|
||||||
bool found = false;
|
found = false;
|
||||||
|
|
||||||
for (int i = listenersCopy.NumObjects(); i > 0; i--) {
|
listenersCopy.Resize(num);
|
||||||
Listener *listener = listenersCopy.ObjectAt(i);
|
|
||||||
|
for (i = num; i > 0; i--) {
|
||||||
|
listener = listeners->ObjectAt(i);
|
||||||
|
if (listener) {
|
||||||
|
listenersCopy.AddObject(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = listenersCopy.NumObjects(); i > 0; i--) {
|
||||||
|
listener = listenersCopy.ObjectAt(i);
|
||||||
|
|
||||||
if (listener) {
|
if (listener) {
|
||||||
listener->ProcessEvent(event);
|
listener->ProcessEvent(event);
|
||||||
|
@ -3105,17 +3120,19 @@ CancelWaiting
|
||||||
*/
|
*/
|
||||||
void Listener::CancelWaiting(const_str name)
|
void Listener::CancelWaiting(const_str name)
|
||||||
{
|
{
|
||||||
|
ConList* list;
|
||||||
|
|
||||||
if (!m_WaitForList) {
|
if (!m_WaitForList) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConList *list = m_WaitForList->findKeyValue(name);
|
list = m_WaitForList->findKeyValue(name);
|
||||||
ConList stoppedListeners;
|
|
||||||
|
|
||||||
if (!list) {
|
if (!list) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConList stoppedListeners;
|
||||||
CancelWaitingSources(name, *list, stoppedListeners);
|
CancelWaitingSources(name, *list, stoppedListeners);
|
||||||
|
|
||||||
m_WaitForList->remove(name);
|
m_WaitForList->remove(name);
|
||||||
|
@ -3132,10 +3149,8 @@ void Listener::CancelWaiting(const_str name)
|
||||||
for (int i = stoppedListeners.NumObjects(); i > 0; i--) {
|
for (int i = stoppedListeners.NumObjects(); i > 0; i--) {
|
||||||
Listener *listener = stoppedListeners.ObjectAt(i);
|
Listener *listener = stoppedListeners.ObjectAt(i);
|
||||||
|
|
||||||
if (listener) {
|
if (listener && !DisableListenerNotify) {
|
||||||
if (!DisableListenerNotify) {
|
listener->StoppedNotify();
|
||||||
listener->StoppedNotify();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3171,10 +3186,8 @@ void Listener::CancelWaitingAll()
|
||||||
for (int i = stoppedListeners.NumObjects(); i > 0; i--) {
|
for (int i = stoppedListeners.NumObjects(); i > 0; i--) {
|
||||||
Listener *listener = stoppedListeners.ObjectAt(i);
|
Listener *listener = stoppedListeners.ObjectAt(i);
|
||||||
|
|
||||||
if (listener) {
|
if (listener && !DisableListenerNotify) {
|
||||||
if (!DisableListenerNotify) {
|
listener->StoppedNotify();
|
||||||
listener->StoppedNotify();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3538,6 +3551,12 @@ bool Listener::UnregisterTarget(const_str name, Listener *listener)
|
||||||
|
|
||||||
list->RemoveObject(listener);
|
list->RemoveObject(listener);
|
||||||
|
|
||||||
|
if (list->NumObjects()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_WaitForList->remove(name);
|
||||||
|
|
||||||
if (!m_WaitForList->isEmpty()) {
|
if (!m_WaitForList->isEmpty()) {
|
||||||
// still has objects in it
|
// still has objects in it
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue