properly unhook delete notifications

This commit is contained in:
ZappoMan 2014-04-21 16:01:37 -07:00
parent f3aa9d3b8f
commit 003e3ae507
2 changed files with 3 additions and 2 deletions

View file

@ -57,16 +57,17 @@ OctreeQueryNode::~OctreeQueryNode() {
void OctreeQueryNode::nodeKilled() { void OctreeQueryNode::nodeKilled() {
_isShuttingDown = true; _isShuttingDown = true;
nodeBag.unhookNotifications(); // if our node is shutting down, then we no longer need octree element notifications
if (_octreeSendThread) { if (_octreeSendThread) {
// just tell our thread we want to shutdown, this is asynchronous, and fast, we don't need or want it to block // 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 // while the thread actually shuts down
_octreeSendThread->setIsShuttingDown(); _octreeSendThread->setIsShuttingDown();
} }
nodeBag.unhookNotifications(); // if our node is shutting down, then we no longer need octree element notifications
} }
void OctreeQueryNode::forceNodeShutdown() { void OctreeQueryNode::forceNodeShutdown() {
_isShuttingDown = true; _isShuttingDown = true;
nodeBag.unhookNotifications(); // if our node is shutting down, then we no longer need octree element notifications
if (_octreeSendThread) { if (_octreeSendThread) {
// we really need to force our thread to shutdown, this is synchronous, we will block while the thread actually // 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 // shuts down because we really need it to shutdown, and it's ok if we wait for it to complete

View file

@ -27,11 +27,11 @@ OctreeElementBag::~OctreeElementBag() {
void OctreeElementBag::unhookNotifications() { void OctreeElementBag::unhookNotifications() {
if (_hooked) { if (_hooked) {
OctreeElement::removeDeleteHook(this); OctreeElement::removeDeleteHook(this);
_hooked = false;
} }
} }
void OctreeElementBag::elementDeleted(OctreeElement* element) { 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() remove(element); // note: remove can safely handle nodes that aren't in it, so we don't need to check contains()
} }