mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-05-12 13:36:51 +03:00
Fixed register/unregistration
This commit is contained in:
parent
57e450a745
commit
30d26c3e44
1 changed files with 38 additions and 58 deletions
|
@ -3397,15 +3397,13 @@ void Listener::Unregister(const_str name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DisableListenerNotify) {
|
|
||||||
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) {
|
||||||
listener->StoppedWaitFor(name, false);
|
listener->StoppedWaitFor(name, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3427,17 +3425,13 @@ Unregister a specified listener with the specified label
|
||||||
*/
|
*/
|
||||||
void Listener::Unregister(const_str name, Listener *listener)
|
void Listener::Unregister(const_str name, Listener *listener)
|
||||||
{
|
{
|
||||||
if (UnregisterSource(name, listener)) {
|
if (UnregisterSource(name, listener) && !DisableListenerNotify) {
|
||||||
if (!DisableListenerNotify) {
|
|
||||||
StoppedNotify();
|
StoppedNotify();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (listener->UnregisterTarget(name, this)) {
|
if (listener->UnregisterTarget(name, this) && !DisableListenerNotify) {
|
||||||
if (!DisableListenerNotify) {
|
|
||||||
listener->StoppedWaitFor(name, false);
|
listener->StoppedWaitFor(name, false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3479,12 +3473,10 @@ void Listener::UnregisterAll(void)
|
||||||
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->StoppedWaitFor(stoppedNames.ObjectAt(i), true);
|
listener->StoppedWaitFor(stoppedNames.ObjectAt(i), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3494,34 +3486,35 @@ UnregisterSource
|
||||||
*/
|
*/
|
||||||
bool Listener::UnregisterSource(const_str name, Listener *listener)
|
bool Listener::UnregisterSource(const_str name, Listener *listener)
|
||||||
{
|
{
|
||||||
|
ConList* list;
|
||||||
|
|
||||||
if (!m_NotifyList) {
|
if (!m_NotifyList) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConList *list = m_NotifyList->findKeyValue(name);
|
list = m_NotifyList->findKeyValue(name);
|
||||||
bool found = false;
|
|
||||||
|
|
||||||
if (!list) {
|
if (!list) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = list->NumObjects(); i > 0; i--) {
|
list->RemoveObject(listener);
|
||||||
if (list->ObjectAt(i) == listener) {
|
|
||||||
list->RemoveObjectAt(i);
|
if (list->NumObjects()) {
|
||||||
found = true;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list->NumObjects() == 0) {
|
|
||||||
m_NotifyList->remove(name);
|
m_NotifyList->remove(name);
|
||||||
|
|
||||||
if (m_NotifyList->isEmpty()) {
|
if (!m_NotifyList->isEmpty()) {
|
||||||
delete m_NotifyList;
|
// still has objects in it
|
||||||
m_NotifyList = NULL;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return found;
|
delete m_NotifyList;
|
||||||
|
m_NotifyList = NULL;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3531,34 +3524,29 @@ UnregisterTarget
|
||||||
*/
|
*/
|
||||||
bool Listener::UnregisterTarget(const_str name, Listener *listener)
|
bool Listener::UnregisterTarget(const_str name, Listener *listener)
|
||||||
{
|
{
|
||||||
|
ConList* list;
|
||||||
|
|
||||||
if (!m_WaitForList) {
|
if (!m_WaitForList) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConList *list = m_WaitForList->findKeyValue(name);
|
list = m_WaitForList->findKeyValue(name);
|
||||||
bool found = false;
|
|
||||||
|
|
||||||
if (!list) {
|
if (!list) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = list->NumObjects(); i > 0; i--) {
|
list->RemoveObject(listener);
|
||||||
if (list->ObjectAt(i) == listener) {
|
|
||||||
list->RemoveObjectAt(i);
|
if (!m_WaitForList->isEmpty()) {
|
||||||
found = true;
|
// still has objects in it
|
||||||
}
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list->NumObjects() == 0) {
|
|
||||||
m_WaitForList->remove(name);
|
|
||||||
|
|
||||||
if (m_WaitForList->isEmpty()) {
|
|
||||||
delete m_WaitForList;
|
delete m_WaitForList;
|
||||||
m_WaitForList = NULL;
|
m_WaitForList = NULL;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return found;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3988,13 +3976,9 @@ ExecuteScriptInternal
|
||||||
*/
|
*/
|
||||||
void Listener::ExecuteScriptInternal(Event *ev, ScriptVariable& returnValue)
|
void Listener::ExecuteScriptInternal(Event *ev, ScriptVariable& returnValue)
|
||||||
{
|
{
|
||||||
SafePtr<ScriptThread> thread = CreateScriptInternal(ev->GetValue(1));
|
ScriptThread* thread = CreateScriptInternal(ev->GetValue(1));
|
||||||
ScriptThread *currentThread;
|
|
||||||
bool fReturn = returnValue.GetType() != VARIABLE_NONE;
|
|
||||||
|
|
||||||
thread->ScriptExecute(&ev->data[1], ev->dataSize - 1, returnValue);
|
thread->ScriptExecute(&ev->data[1], ev->dataSize - 1, returnValue);
|
||||||
|
|
||||||
currentThread = Director.m_CurrentThread;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -4004,13 +3988,9 @@ ExecuteThreadInternal
|
||||||
*/
|
*/
|
||||||
void Listener::ExecuteThreadInternal(Event *ev, ScriptVariable& returnValue)
|
void Listener::ExecuteThreadInternal(Event *ev, ScriptVariable& returnValue)
|
||||||
{
|
{
|
||||||
SafePtr<ScriptThread> thread = CreateThreadInternal(ev->GetValue(1));
|
ScriptThread* thread = CreateThreadInternal(ev->GetValue(1));
|
||||||
ScriptThread *currentThread;
|
|
||||||
bool fReturn = returnValue.GetType() != VARIABLE_NONE;
|
|
||||||
|
|
||||||
thread->ScriptExecute(&ev->data[1], ev->dataSize - 1, returnValue);
|
thread->ScriptExecute(&ev->data[1], ev->dataSize - 1, returnValue);
|
||||||
|
|
||||||
currentThread = Director.m_CurrentThread;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue