// this function is called from angelscript
CScriptHandle CScriptFunction::createObject(const std::string& name, const core::vector3df& pos)
{
int id = builder.GetModule()->GetTypeIdByDecl(name.c_str());
if(id == asINVALID_TYPE)
{
//error msg
return CScriptHandle();
}
asIScriptObject* s = reinterpret_cast<asIScriptObject*>(engine->CreateScriptObject(id));
//here the ref count is sometimes 2
if(!scriptObj)
return CScriptHandle();
// set pos
// add it to an objArray
return CScriptHandle(scriptObj, scriptObj->GetObjectType());
}
// The CScriptHandle increased the ref count when it
// stored the handle internally so we need to release one
yes but if the CScriptHandle will be destroyed the ref counter will dec
but the problem is direct after the engine createObject function so i think it is a angelscript problem
i will write a little example that reproduce the problem but now i have no time sry