lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Using C++, lua5.1, luabind 0.7

*** Lua code: ***
class 'TestClass' (ScriptProxy)
function TestClass:__init()
    super(self)
end
function TestClass:__finalize()
end

*** C++ code ***
class ScriptProxy
{
public:
	ScriptProxy(luabind::object self) : self_(self) {};
	luabind::object self_;
};

// test 1
luaL_dostring(lua_state, "return TestClass()");
luabind::object obj(luabind::from_stack(ls, -1));
// test 2 (results are same)
ScriptProxy* sp = luabind::object_cast<ScriptProxy*>(lua_state,
"TestClass")[luabind::adopt(luabind::result)]);
delete sp;

lua_gc(l_, LUA_GCCOLLECT, 0); // collect garbage

Result: TestClass instance is not deleted, garbage collection ignores him,
it has references anywhere? but where? "_finalaze" method is calling only on
program exit (when "lua_close" function called). How to solve this problem?

Thank you.
-- 
View this message in context: http://n2.nabble.com/luabind-0-7-problem-with-luabind-object-reference-tp4192769p4192769.html
Sent from the Lua list mailing list archive at Nabble.com.