segfault on drawAll() after deleting a node
segfault on drawAll() after deleting a node
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?
It's an IAnimatedMeshSceneNode, created with:
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 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.
Code: Select all
IAnimatedMesh* mesh = sm->getMesh("media/sydney.md2");
IAnimatedMeshSceneNode* node = sm->addAnimatedMeshSceneNode(mesh);
Code: Select all
playerIDToNode[results.at(1)]->removeAll();
playerIDToNode[results.at(1)]->remove();
playerIDToNode.erase(results.at(1));
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.