From 24331d3c90478ed57ca697a8e28f51e78ca86b14 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Thu, 9 Apr 2020 01:56:32 -0500 Subject: [PATCH] Prefer LLPointer over potential for dangling LLSpatialGroup pointers. --- indra/newview/llspatialpartition.cpp | 4 ++-- indra/newview/llspatialpartition.h | 4 ++-- indra/newview/llvieweroctree.cpp | 5 ++--- indra/newview/llvieweroctree.h | 3 ++- indra/newview/llviewerregion.cpp | 1 + indra/newview/pipeline.cpp | 5 +++-- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 9e1066072..97decd6fe 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -752,7 +752,7 @@ void LLSpatialGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* c { if (child->getListenerCount() == 0) { - new LLSpatialGroup(child, getSpatialPartition()); + LLPointer tmp = new LLSpatialGroup(child, getSpatialPartition()); } else { @@ -817,7 +817,7 @@ LLSpatialPartition::LLSpatialPartition(U32 data_mask, BOOL render_by_group, U32 mSlopRatio = 0.25f; mInfiniteFarClip = FALSE; - new LLSpatialGroup(mOctree, this); + LLPointer tmp = new LLSpatialGroup(mOctree, this); } diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index b52726be1..d46314f4e 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -116,7 +116,7 @@ public: BOOL mParticle; F32 mPartSize; F32 mVSize; - LLSpatialGroup* mGroup; + LLPointer mGroup; LL_ALIGN_16(LLFace* mFace); //associated face F32 mDistance; U32 mDrawMode; @@ -478,7 +478,7 @@ class LLCullResult public: LLCullResult() {} - typedef std::vector sg_list_t; + typedef std::vector > sg_list_t; typedef std::vector drawable_list_t; typedef std::vector bridge_list_t; typedef std::vector drawinfo_list_t; diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 4af787a8d..de4dcc580 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -272,11 +272,10 @@ void LLViewerOctreeEntry::removeData(LLViewerOctreeEntryData* data) mData[data->getDataType()] = NULL; - if(mGroup != NULL && !mData[LLDRAWABLE]) + if(!mGroup.isNull() && !mData[LLDRAWABLE]) { - LLViewerOctreeGroup* group = mGroup; + mGroup->removeFromGroup(data); mGroup = NULL; - group->removeFromGroup(data); llassert(mBinIndex == -1); } diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h index b60875b58..31a11dfca 100644 --- a/indra/newview/llvieweroctree.h +++ b/indra/newview/llvieweroctree.h @@ -109,7 +109,7 @@ private: private: LLViewerOctreeEntryData* mData[NUM_DATA_TYPE]; //do not use LLPointer here. - LLViewerOctreeGroup* mGroup; + LLPointer mGroup; //aligned members LL_ALIGN_16(LLVector4a mExtents[2]); @@ -229,6 +229,7 @@ public: void handleChildRemoval(const OctreeNode* parent, const OctreeNode* child) final override; OctreeNode* getOctreeNode() {return mOctreeNode;} + const OctreeNode* getOctreeNode() const { return mOctreeNode; } LLViewerOctreeGroup* getParent(); const LLVector4a* getBounds() const {return mBounds;} diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 26a8dc092..94531600d 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -117,6 +117,7 @@ public: mSeedCapMaxAttemptsBeforeLogin(MAX_SEED_CAP_ATTEMPTS_BEFORE_LOGIN), mSeedCapAttempts(0), mHttpResponderID(0), + mLandp(NULL), // I'd prefer to set the LLCapabilityListener name to match the region // name -- it's disappointing that's not available at construction time. // We could instead store an LLCapabilityListener*, making diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index f8cedfcf9..ab83c4f21 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3459,8 +3459,9 @@ void forAllDrawables(LLCullResult::sg_iterator begin, { for (LLCullResult::sg_iterator i = begin; i != end; ++i) { - OctreeGuard guard((*i)->getOctreeNode()); - for (LLSpatialGroup::element_iter j = (*i)->getDataBegin(); j != (*i)->getDataEnd(); ++j) + LLSpatialGroup* group = (*i).get(); + OctreeGuard guard(group->getOctreeNode()); + for (LLSpatialGroup::element_iter j = group->getDataBegin(); j != group->getDataEnd(); ++j) { func((LLDrawable*)(*j)->getDrawable()); }