From 55d2cf8c86df8655fd826443ebe34b1005a9cf90 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Thu, 2 Feb 2012 22:42:09 +0100 Subject: Added a generic Lua user data cache Based on a native Lua table with weak values, so that the user data objects that are created can be garbage collected when no longer referenced. Reviewed-by: Yohann Ferreira --- src/scripting/lua.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 63149792..b9c76c23 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -2703,9 +2703,9 @@ LuaScript::LuaScript(): LuaMapObject::registerType(mState, "MapObject", members_MapObject); // Make script object available to callback functions. - lua_pushlightuserdata(mState, (void *)®istryKey); + lua_pushlightuserdata(mState, const_cast(®istryKey)); lua_pushlightuserdata(mState, this); - lua_settable(mState, LUA_REGISTRYINDEX); + lua_rawset(mState, LUA_REGISTRYINDEX); // Push the error handler to first index of the stack lua_getglobal(mState, "debug"); -- cgit v1.2.3-70-g09d2