unhook node bag from element notifications on shutdown to speed up cleanup

This commit is contained in:
ZappoMan 2014-04-21 15:45:12 -07:00
parent 779b5a6827
commit f3aa9d3b8f
3 changed files with 12 additions and 1 deletions

View file

@ -62,6 +62,7 @@ void OctreeQueryNode::nodeKilled() {
// while the thread actually shuts down
_octreeSendThread->setIsShuttingDown();
}
nodeBag.unhookNotifications(); // if our node is shutting down, then we no longer need octree element notifications
}
void OctreeQueryNode::forceNodeShutdown() {

View file

@ -16,13 +16,20 @@ OctreeElementBag::OctreeElementBag() :
_bagElements()
{
OctreeElement::addDeleteHook(this);
_hooked = true;
};
OctreeElementBag::~OctreeElementBag() {
OctreeElement::removeDeleteHook(this);
unhookNotifications();
deleteAll();
}
void OctreeElementBag::unhookNotifications() {
if (_hooked) {
OctreeElement::removeDeleteHook(this);
}
}
void OctreeElementBag::elementDeleted(OctreeElement* element) {
qDebug() << "OctreeElementBag::elementDeleted()...";
remove(element); // note: remove can safely handle nodes that aren't in it, so we don't need to check contains()

View file

@ -36,8 +36,11 @@ public:
void deleteAll();
virtual void elementDeleted(OctreeElement* element);
void unhookNotifications();
private:
QSet<OctreeElement*> _bagElements;
bool _hooked;
};
#endif // hifi_OctreeElementBag_h