浏览代码

When closing the vm the registry table is cleaned before garbage collection so check it first.

mingodad 9 年之前
父节点
当前提交
5af50ae6e7
共有 1 个文件被更改,包括 7 次插入2 次删除
  1. 7 2
      SquiLu/squirrel/sqapi.cpp

+ 7 - 2
SquiLu/squirrel/sqapi.cpp

@@ -683,8 +683,13 @@ SQRESULT sq_delete_on_registry_table(HSQUIRRELVM v, SQUserPointer uptr)
 	if(type(key) == OT_NULL) {
 		return sq_throwerror(v, _SC("null key"));
 	}
-    _table(_ss(v)->_registry)->Remove(key);
-    return SQ_OK;
+	SQTable *registry = _table(_ss(v)->_registry);
+    if(registry) //when closing the vm releasehooks are called with NULL registry
+    {
+        registry->Remove(key);
+        return SQ_OK;
+    }
+    return SQ_ERROR;
 }
 
 int sq_preload_modules(HSQUIRRELVM v, sq_modules_preload_st *modules){