From 48c22756f553ca588cd36a323be7df615faf13c1 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Sun, 13 Nov 2011 02:49:32 -0200 Subject: [PATCH] fix lua event bug --- src/framework/luascript/luaobject.h | 30 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/framework/luascript/luaobject.h b/src/framework/luascript/luaobject.h index 160988e4..641bfe93 100644 --- a/src/framework/luascript/luaobject.h +++ b/src/framework/luascript/luaobject.h @@ -77,22 +77,20 @@ private: template int LuaObject::callLuaField(const std::string& field, const T&... args) { - if(m_fieldsTableRef != -1) { - // note that the field must be retrieved from this object lua value - // to force using the __index metamethod of it's metatable - // so cannot use LuaObject::getField here - // push field - g_lua.pushObject(asLuaObject()); - g_lua.getField(field); - - if(!g_lua.isNil()) { - // the first argument is always this object (self) - g_lua.insert(-2); - g_lua.polymorphicPush(args...); - return g_lua.protectedCall(1 + sizeof...(args)); - } else { - g_lua.pop(2); - } + // note that the field must be retrieved from this object lua value + // to force using the __index metamethod of it's metatable + // so cannot use LuaObject::getField here + // push field + g_lua.pushObject(asLuaObject()); + g_lua.getField(field); + + if(!g_lua.isNil()) { + // the first argument is always this object (self) + g_lua.insert(-2); + g_lua.polymorphicPush(args...); + return g_lua.protectedCall(1 + sizeof...(args)); + } else { + g_lua.pop(2); } return 0; }