Hopefully fixes the issue with ref counting in angelscript
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2022-03-06 15:57:25 +01:00
parent e18767995c
commit 4a8b3e13a1
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
3 changed files with 2 additions and 1 deletions

View File

@ -187,6 +187,7 @@ CreatureLib::Battling::BattleScript* AngelScriptResolver::LoadScript(const ArbUt
} }
auto ctx = _contextPool->RequestContext(); auto ctx = _contextPool->RequestContext();
auto obj = const_cast<AngelScriptTypeInfo*>(t.value().get())->Instantiate(ctx); auto obj = const_cast<AngelScriptTypeInfo*>(t.value().get())->Instantiate(ctx);
obj->AddRef();
_contextPool->ReturnContextToPool(ctx); _contextPool->ReturnContextToPool(ctx);
auto ownerType = GetScriptOwnerType(category); auto ownerType = GetScriptOwnerType(category);
return new AngelScriptScript(owner, ownerType, this, t.value(), obj, _contextPool); return new AngelScriptScript(owner, ownerType, this, t.value(), obj, _contextPool);

View File

@ -34,6 +34,7 @@ CreatureLib::Battling::BattleScript* AngelScriptScript::Clone(const ArbUt::Optio
if (_obj != nullptr) { if (_obj != nullptr) {
obj->CopyFrom(_obj); obj->CopyFrom(_obj);
} }
obj->AddRef();
_ctxPool->ReturnContextToPool(ctx); _ctxPool->ReturnContextToPool(ctx);
return new AngelScriptScript(owner, GetAngelscriptOwner()->GetType(), _resolver, _type, obj, _ctxPool); return new AngelScriptScript(owner, GetAngelscriptOwner()->GetType(), _resolver, _type, obj, _ctxPool);

View File

@ -61,7 +61,6 @@ public:
throw ArbUt::Exception("Instantiation failed."); throw ArbUt::Exception("Instantiation failed.");
} }
asIScriptObject* obj = *(asIScriptObject**)ctx->GetAddressOfReturnValue(); asIScriptObject* obj = *(asIScriptObject**)ctx->GetAddressOfReturnValue();
obj->AddRef();
return obj; return obj;
} }