1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 18:35:20 +00:00

Do not detach NPC parts in destructor

This commit is contained in:
scrawl 2016-02-09 16:10:42 +01:00
parent 40a6e05e17
commit ae031b23d4
3 changed files with 16 additions and 1 deletions

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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,