From 58fc314e6f14709c56f0e7eb50943cf5723a44dc Mon Sep 17 00:00:00 2001 From: ThePhD Date: Thu, 9 Jun 2016 15:49:53 -0400 Subject: [PATCH] Fiiixes! Thanks to @CatPlusPlus and @melak47 for helping me fix this one. Closes #112 . --- .gitignore | 3 +++ sol/usertype_metatable.hpp | 15 +++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 73e113e1..28811ff0 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,6 @@ docs/build/ m.lua single/sol.hpp *.db +lua53.dll +main.exe +main.o diff --git a/sol/usertype_metatable.hpp b/sol/usertype_metatable.hpp index 039b62fe..1437a336 100644 --- a/sol/usertype_metatable.hpp +++ b/sol/usertype_metatable.hpp @@ -246,12 +246,6 @@ namespace sol { return f.find_call(std::false_type(), std::make_index_sequence::value>(), L, accessor); } - static int gc_call(lua_State* L) { - usertype_metatable& f = stack::get>(L, up_value_index(1)); - f.~usertype_metatable(); - return 0; - } - virtual int push_um(lua_State* L) override { return stack::push(L, std::move(*this)); } @@ -335,10 +329,15 @@ namespace sol { t.pop(); } else { + // NOT NEEDED + // Perhaps we should look into + // whether or not doing ti like this + // is better than just letting user handle it? + // Add cleanup to metatable // Essentially, when the metatable dies, // this too will call the class and kill itself - const char* metakey = &usertype_traits::gc_table[0]; + /*const char* metakey = &usertype_traits::gc_table[0]; lua_createtable(L, 1, 0); stack_reference cleanup(L, -1); stack::set_field(L, meta_function::garbage_collect, make_closure(umt_t::gc_call, umt), cleanup.stack_index()); @@ -348,7 +347,7 @@ namespace sol { // otherwise, it will trigger the __index metamethod // we just set stack::raw_set_field(L, metakey, t, t.stack_index()); - cleanup.pop(); + cleanup.pop();*/ } }