Browse Source

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

mingodad 9 năm trước cách đây
mục cha
commit
5af50ae6e7
1 tập tin đã thay đổi với 7 bổ sung2 xóa
  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) {
 	if(type(key) == OT_NULL) {
 		return sq_throwerror(v, _SC("null key"));
 		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){
 int sq_preload_modules(HSQUIRRELVM v, sq_modules_preload_st *modules){