summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/BLua.cc14
-rw-r--r--lib/LuaTask.cc4
2 files changed, 10 insertions, 8 deletions
diff --git a/lib/BLua.cc b/lib/BLua.cc
index aab4578..76a0c6d 100644
--- a/lib/BLua.cc
+++ b/lib/BLua.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: BLua.cc,v 1.56 2008-01-15 17:01:03 pixel Exp $ */
+/* $Id: BLua.cc,v 1.57 2008-01-23 17:53:12 pixel Exp $ */
#include <stdlib.h>
#include "BLua.h"
@@ -459,11 +459,8 @@ Lua * Lua::spawn_from_thread(lua_State * __L) {
L->father = Father();
}
-Lua::~Lua() {
- if (!_is_thread) {
-// lua_setgcthreshold(L, 0);
- lua_close(L);
- } else {
+void Lua::weaken() {
+ if (_is_thread) {
push(); // -1 = nil
push("BLUA_THREADS"); // -2 = nil, -1 = "BLUA_THREADS"
copy(); // -3 = nil, -2 = "BLUA_THREADS", -1 = "BLUA_THREADS"
@@ -474,7 +471,12 @@ Lua::~Lua() {
settable(LUA_REGISTRYINDEX); // -1 = thread
pop();
}
+}
+Lua::~Lua() {
+ weaken();
+ if (!_is_thread)
+ lua_close(L);
L = 0;
}
diff --git a/lib/LuaTask.cc b/lib/LuaTask.cc
index 12f1db5..7b1e045 100644
--- a/lib/LuaTask.cc
+++ b/lib/LuaTask.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: LuaTask.cc,v 1.26 2008-01-23 17:41:10 pixel Exp $ */
+/* $Id: LuaTask.cc,v 1.27 2008-01-23 17:53:12 pixel Exp $ */
#include <LuaTask.h>
#include <LuaHandle.h>
@@ -60,7 +60,7 @@ LuaTask::~LuaTask() {
settop(0);
}
if (destroy_VM)
- delete L;
+ L->weaken();
}
LuaTask * LuaTask::gettop() {