Skip to content

Commit

Permalink
Make sure none of the irrlicht member objects of GenericCAO are delet…
Browse files Browse the repository at this point in the history
…ed prior deletion of GenericCAO
  • Loading branch information
sapier authored and sapier committed Jun 29, 2014
1 parent 3c5df42 commit 1367895
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/content_cao.cpp
Expand Up @@ -751,6 +751,7 @@ void GenericCAO::removeFromScene(bool permanent)
if(m_meshnode)
{
m_meshnode->remove();
m_meshnode->drop();
m_meshnode = NULL;
}
if(m_animated_meshnode)
Expand All @@ -762,8 +763,15 @@ void GenericCAO::removeFromScene(bool permanent)
if(m_spritenode)
{
m_spritenode->remove();
m_spritenode->drop();
m_spritenode = NULL;
}
if (m_textnode)
{
m_textnode->remove();
m_textnode->drop();
m_textnode = NULL;
}
}

void GenericCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
Expand All @@ -787,6 +795,7 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
infostream<<"GenericCAO::addToScene(): single_sprite"<<std::endl;
m_spritenode = smgr->addBillboardSceneNode(
NULL, v2f(1, 1), v3f(0,0,0), -1);
m_spritenode->grab();
m_spritenode->setMaterialTexture(0,
tsrc->getTexture("unknown_node.png"));
m_spritenode->setMaterialFlag(video::EMF_LIGHTING, false);
Expand Down Expand Up @@ -852,6 +861,7 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
buf->drop();
}
m_meshnode = smgr->addMeshSceneNode(mesh, NULL);
m_meshnode->grab();
mesh->drop();
// Set it to use the materials of the meshbuffers directly.
// This is needed for changing the texture in the future
Expand All @@ -861,6 +871,7 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
infostream<<"GenericCAO::addToScene(): cube"<<std::endl;
scene::IMesh *mesh = createCubeMesh(v3f(BS,BS,BS));
m_meshnode = smgr->addMeshSceneNode(mesh, NULL);
m_meshnode->grab();
mesh->drop();

m_meshnode->setScale(v3f(m_prop.visual_size.X,
Expand Down Expand Up @@ -912,6 +923,7 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
scene::IMesh *mesh = manip->createMeshUniquePrimitives(item_mesh);

m_meshnode = smgr->addMeshSceneNode(mesh, NULL);
m_meshnode->grab();
mesh->drop();

m_meshnode->setScale(v3f(m_prop.visual_size.X/2,
Expand Down Expand Up @@ -939,6 +951,7 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
std::wstring wname = narrow_to_wide(m_name);
m_textnode = smgr->addTextSceneNode(gui->getBuiltInFont(),
wname.c_str(), video::SColor(255,255,255,255), node);
m_textnode->grab();
m_textnode->setPosition(v3f(0, BS*1.1, 0));
}

Expand Down

0 comments on commit 1367895

Please sign in to comment.