Do not detach NPC parts in destructor

coverity_scan
scrawl 9 years ago
parent 40a6e05e17
commit ae031b23d4

@ -1409,8 +1409,13 @@ namespace MWRender
PartHolder::~PartHolder()
{
if (mNode->getNumParents())
if (mNode.get() && mNode->getNumParents())
mNode->getParent(0)->removeChild(mNode);
}
void PartHolder::unlink()
{
mNode = NULL;
}
}

@ -55,6 +55,9 @@ public:
~PartHolder();
/// Unreferences mNode *without* detaching it from the graph. Only use if you know what you are doing.
void unlink();
osg::ref_ptr<osg::Node> getNode()
{
return mNode;

@ -273,6 +273,13 @@ NpcAnimation::~NpcAnimation()
// all from within this destructor. ouch!
&& mPtr.getRefData().getCustomData() && mPtr.getClass().getInventoryStore(mPtr).getListener() == this)
mPtr.getClass().getInventoryStore(mPtr).setListener(NULL, mPtr);
// do not detach (delete) parts yet, this is done so the background thread can handle the deletion
for(size_t i = 0;i < ESM::PRT_Count;i++)
{
if (mObjectParts[i].get())
mObjectParts[i]->unlink();
}
}
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group> parentNode, Resource::ResourceSystem* resourceSystem,

Loading…
Cancel
Save