diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 45130efeb9fa0dfb1570a6fe03d2417441f97898..b9d4c016c27cd62e21524adee552ef90e1fef78d 100755 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -841,11 +841,16 @@ void LLSpatialGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntry* en void LLSpatialGroup::handleDestruction(const TreeNode* node) { + if(isDead()) + { + return; + } setState(DEAD); - for (element_iter i = getDataBegin(); i != getDataEnd(); ++i) + for (element_iter i = getDataBegin(); getElementCount() > 0 && i != getDataEnd();) { LLViewerOctreeEntry* entry = *i; + if (entry->getGroup() == this) { if(entry->hasDrawable()) @@ -853,10 +858,14 @@ void LLSpatialGroup::handleDestruction(const TreeNode* node) ((LLDrawable*)entry->getDrawable())->setGroup(NULL); } else - { + { llerrs << "No Drawable found in the entry." << llendl; } } + else + { + ++i; + } } //clean up avatar attachment stats