Page 1 of 1

segfault on drawAll() after deleting a node

Posted: Sun Nov 26, 2006 9:23 pm
by Paradigm^
Hi all. I'm having a little trouble after I delete a node. I'm doing node->removeAll() and then node->remove() and it works fine, but I'm getting a segmentation fault on the next drawAll() call in my main loop - so presumably, the scene manager thinks it's still there and is trying to do something with it. Is there anything I'm missing that I need to do to tell the scene manager that this node isn't there any more?

Posted: Mon Nov 27, 2006 1:58 am
by sgt_pinky
Which type scene node is it? Show us some code.

If it's created with a 'createXXX()' routine, there should be a corresponding 'drop()' somewhere - that could be one problem.

Posted: Mon Nov 27, 2006 12:44 pm
by Paradigm^
It's an IAnimatedMeshSceneNode, created with:

Code: Select all

IAnimatedMesh* mesh = sm->getMesh("media/sydney.md2");
IAnimatedMeshSceneNode* node = sm->addAnimatedMeshSceneNode(mesh);
A pointer to it is stored in a couple of places - a map and a vector - but I've checked that those pointers go at the same time the node gets deleted. As I said, I'm deleting the node with

Code: Select all

playerIDToNode[results.at(1)]->removeAll();
playerIDToNode[results.at(1)]->remove();
playerIDToNode.erase(results.at(1));
where playerIDToNode is the map I was talking about and results.at(1) is the key in the map pointing to the node I want to remove.

I didn't want to go into the specifics as I'm 90% sure I've narrowed it down to drawAll() getting confused and trying to render it - I could paste 400+ lines of code but the most part of that isn't remotely going to be relevant. Figured it'd be more helpful to give a rundown of the problem and ask what situations might drawAll() try to render a node that isn't there?

update:/ Fixed it - I wasn't deleting the node's triangle selector from my metaSelectors.