Browse Source

Fix ScriptSubscribeToEvent to deal with multi handler of same event.
This fix is needed to make 26_ConsoleInput.lua sample works as expected.

Yao Wei Tjong 姚伟忠 11 years ago
parent
commit
3e942ec7fc
1 changed files with 5 additions and 12 deletions
  1. 5 12
      Source/Engine/LuaScript/LuaScript.cpp

+ 5 - 12
Source/Engine/LuaScript/LuaScript.cpp

@@ -174,9 +174,7 @@ void LuaScript::ScriptSubscribeToEvent(const String& eventName, const String& fu
     {
     {
         LuaFunctionVector& functions = eventHandleFunctions_[eventType];
         LuaFunctionVector& functions = eventHandleFunctions_[eventType];
         
         
-        HashSet<Object*>* receivers = context_->GetEventReceivers(eventType);
-        if (!receivers || !receivers->Contains(this))
-            SubscribeToEvent(eventType, HANDLER(LuaScript, HandleEvent));
+        SubscribeToEvent(eventType, HANDLER(LuaScript, HandleEvent));
 
 
         if (!functions.Contains(function))
         if (!functions.Contains(function))
             functions.Push(function);
             functions.Push(function);
@@ -225,15 +223,10 @@ void LuaScript::ScriptSubscribeToEvent(void* sender, const String& eventName, co
     {
     {
         LuaFunctionVector& functions = objectHandleFunctions_[object][eventType];
         LuaFunctionVector& functions = objectHandleFunctions_[object][eventType];
 
 
-        HashSet<Object*>* receivers = context_->GetEventReceivers(object, eventType);
-        if (!receivers || !receivers->Contains(this))
-        {
-            SubscribeToEvent(object, eventType, HANDLER(LuaScript, HandleObjectEvent));
-            
-            // Fix issue #256
-            if (!functions.Empty())
-                functions.Clear();
-        }
+        SubscribeToEvent(object, eventType, HANDLER(LuaScript, HandleObjectEvent));
+
+        if (!functions.Empty())
+            functions.Clear();
 
 
         if (!functions.Contains(function))
         if (!functions.Contains(function))
             functions.Push(function);
             functions.Push(function);