Crash when destroying entities

nolver

17-08-2006 17:16:40

Excuse me, If this is solved somewhere else. I've been searching the forums with no look :(

I'm having a crash when trying to create an entity that has been previuslly destroyed.

I'm creating the entity this way:


//create the node
prevNode = this.mSceneMgr.RootSceneNode.CreateChildSceneNode("MeshEditor_PrvNode");

//create the entity
if (meshFile != string.Empty)
{
//create the entity
meshEntity = mSceneMgr.CreateEntity("MeshEditor_MeshEntity", meshFile);
prevNode.AttachObject(meshEntity);
}


And destroying it this way:


//detach
if (prevNode != null) prevNode.DetachAllObjects();

//destroy
if (meshEntity != null) meshEntity.Dispose();
if (prevNode != null)
{
this.mSceneMgr.RootSceneNode.RemoveAndDestroyChild("MeshEditor_PrvNode");
prevNode.Dispose();
}


When I try to run the creation code for second time, right after executing the destruction code, Ogre engine tells that there is already an existing entity with that name.

What I'm I doing wrong?

DigitalCyborg

15-09-2006 02:41:23

you are destroying only the node and not the entity.