Explorar el Código

Attempt to fix releasing resources when closing a vm.

mingodad hace 9 años
padre
commit
255396da3a
Se han modificado 3 ficheros con 5 adiciones y 1 borrados
  1. 2 1
      SquiLu/squirrel/sqapi.cpp
  2. 2 0
      SquiLu/squirrel/sqvm.cpp
  3. 1 0
      SquiLu/squirrel/sqvm.h

+ 2 - 1
SquiLu/squirrel/sqapi.cpp

@@ -204,7 +204,7 @@ SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po)
 	__Release(po->_type,po->_unVal);
 	return ret; //the ret val doesn't work(and cannot be fixed)
 #else
-	return _ss(v)->_refs_table.Release(*po);
+	return v->_closing ? SQ_OK : _ss(v)->_refs_table.Release(*po);
 #endif
 }
 
@@ -722,6 +722,7 @@ SQRESULT sq_delete_on_registry_table(HSQUIRRELVM v, SQUserPointer uptr)
 	if(type(key) == OT_NULL) {
 		return sq_throwerror(v, _SC("null key"));
 	}
+	if(v->_closing) return SQ_OK;
 	SQTable *registry = _table(_ss(v)->_registry);
     if(registry) //when closing the vm releasehooks are called with NULL registry
     {

+ 2 - 0
SquiLu/squirrel/sqvm.cpp

@@ -124,6 +124,7 @@ bool SQVM::ARITH_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,
 
 SQVM::SQVM(SQSharedState *ss)
 {
+    _closing=SQFalse;
 	_sharedstate=ss;
 	_suspended = SQFalse;
 	_suspended_target = -1;
@@ -162,6 +163,7 @@ SQVM::SQVM(SQSharedState *ss)
 
 void SQVM::Finalize()
 {
+    _closing=SQTrue;
     CallAtExitHandler();
 #ifdef SQ_WITH_DELAYED_RELEASE_HOOKS
     _sharedstate->CallDelayedReleaseHooks(this);

+ 1 - 0
SquiLu/squirrel/sqvm.h

@@ -198,6 +198,7 @@ public:
 	OpProfileVec _op_profile;
 	HighResolutionTimer _op_profile_timer;
 #endif
+	SQBool _closing;
 };
 
 struct AutoDec{