From 003e3ae507d96761b048720e3afc1875e5f4f39e Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Mon, 21 Apr 2014 16:01:37 -0700 Subject: [PATCH] properly unhook delete notifications --- assignment-client/src/octree/OctreeQueryNode.cpp | 3 ++- libraries/octree/src/OctreeElementBag.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/assignment-client/src/octree/OctreeQueryNode.cpp b/assignment-client/src/octree/OctreeQueryNode.cpp index dfaf641753..10d30ad1ae 100644 --- a/assignment-client/src/octree/OctreeQueryNode.cpp +++ b/assignment-client/src/octree/OctreeQueryNode.cpp @@ -57,16 +57,17 @@ OctreeQueryNode::~OctreeQueryNode() { void OctreeQueryNode::nodeKilled() { _isShuttingDown = true; + nodeBag.unhookNotifications(); // if our node is shutting down, then we no longer need octree element notifications if (_octreeSendThread) { // just tell our thread we want to shutdown, this is asynchronous, and fast, we don't need or want it to block // 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() { _isShuttingDown = true; + nodeBag.unhookNotifications(); // if our node is shutting down, then we no longer need octree element notifications if (_octreeSendThread) { // we really need to force our thread to shutdown, this is synchronous, we will block while the thread actually // shuts down because we really need it to shutdown, and it's ok if we wait for it to complete diff --git a/libraries/octree/src/OctreeElementBag.cpp b/libraries/octree/src/OctreeElementBag.cpp index d4084101cb..92a8fe5bff 100644 --- a/libraries/octree/src/OctreeElementBag.cpp +++ b/libraries/octree/src/OctreeElementBag.cpp @@ -27,11 +27,11 @@ OctreeElementBag::~OctreeElementBag() { void OctreeElementBag::unhookNotifications() { if (_hooked) { OctreeElement::removeDeleteHook(this); + _hooked = false; } } 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() }