Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actualzerochen

Posted 12 October 2012 - 01:35 PM

// 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

#12zerochen

Posted 12 October 2012 - 01:28 PM

// 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 the little example that reproduce the problem but now i have no time sry

#11zerochen

Posted 12 October 2012 - 01:27 PM

// 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 the little example that reproduce but now i have no time

#10zerochen

Posted 12 October 2012 - 01:26 PM

// 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

#9zerochen

Posted 12 October 2012 - 01:25 PM

// 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

#8zerochen

Posted 12 October 2012 - 01:21 PM


// 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());

}


PARTNERS