Aster Jian пре 11 година
родитељ
комит
270a49d09f
1 измењених фајлова са 5 додато и 3 уклоњено
  1. 5 3
      Source/Engine/LuaScript/LuaScript.cpp

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

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