diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index 2408d1ba0..b9ed4fb98 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -112,12 +112,12 @@ bool Objects::removeObject (const MWWorld::Ptr& ptr) PtrAnimationMap::iterator iter = mObjects.find(ptr); if(iter != mObjects.end()) { + if (mUnrefQueue.get()) + mUnrefQueue->push(iter->second->getObjectRoot()); + delete iter->second; mObjects.erase(iter); - if (mUnrefQueue.get()) - mUnrefQueue->push(ptr.getRefData().getBaseNode()); - ptr.getRefData().getBaseNode()->getParent(0)->removeChild(ptr.getRefData().getBaseNode()); ptr.getRefData().setBaseNode(NULL);