From 60867888bae9439beee21e84036d0ad2dd3839e6 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Tue, 21 Jun 2011 16:57:24 -0600 Subject: fix for SH-369: [PUBLIC-JIRA-USERS] [crashhunters] LLVOAvatar::updateImpostors crash --- indra/llcharacter/llcharacter.cpp | 25 +++++++++++++++++++------ indra/llcharacter/llcharacter.h | 1 + indra/newview/llvoavatar.cpp | 4 ++++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/indra/llcharacter/llcharacter.cpp b/indra/llcharacter/llcharacter.cpp index 5f84be2c5d..c9fb8534f1 100644 --- a/indra/llcharacter/llcharacter.cpp +++ b/indra/llcharacter/llcharacter.cpp @@ -38,7 +38,7 @@ LLStringTable LLCharacter::sVisualParamNames(1024); std::vector< LLCharacter* > LLCharacter::sInstances; - +BOOL LLCharacter::sAllowInstancesChange = TRUE ; //----------------------------------------------------------------------------- // LLCharacter() @@ -51,8 +51,10 @@ LLCharacter::LLCharacter() mAppearanceSerialNum( 0 ), mSkeletonSerialNum( 0 ) { - mMotionController.setCharacter( this ); + llassert_always(sAllowInstancesChange) ; sInstances.push_back(this); + + mMotionController.setCharacter( this ); mPauseRequest = new LLPauseRequestHandle(); } @@ -62,18 +64,29 @@ LLCharacter::LLCharacter() // Class Destructor //----------------------------------------------------------------------------- LLCharacter::~LLCharacter() -{ +{ for (LLVisualParam *param = getFirstVisualParam(); param; param = getNextVisualParam()) { delete param; } - std::vector::iterator iter = std::find(sInstances.begin(), sInstances.end(), this); - if (iter != sInstances.end()) + + U32 i ; + U32 size = sInstances.size() ; + for(i = 0 ; i < size ; i++) { - sInstances.erase(iter); + if(sInstances[i] == this) + { + break ; + } } + + llassert_always(i < size) ; + + llassert_always(sAllowInstancesChange) ; + sInstances[i] = sInstances[size - 1] ; + sInstances.pop_back() ; } diff --git a/indra/llcharacter/llcharacter.h b/indra/llcharacter/llcharacter.h index a6347fcc3c..e81a27c2bc 100644 --- a/indra/llcharacter/llcharacter.h +++ b/indra/llcharacter/llcharacter.h @@ -266,6 +266,7 @@ public: void setSkeletonSerialNum( U32 num ) { mSkeletonSerialNum = num; } static std::vector< LLCharacter* > sInstances; + static BOOL sAllowInstancesChange ; //debug use protected: LLMotionController mMotionController; diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 1b53348b43..8eda6346b0 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -8242,6 +8242,8 @@ U32 LLVOAvatar::getPartitionType() const //static void LLVOAvatar::updateImpostors() { + LLCharacter::sAllowInstancesChange = FALSE ; + for (std::vector::iterator iter = LLCharacter::sInstances.begin(); iter != LLCharacter::sInstances.end(); ++iter) { @@ -8251,6 +8253,8 @@ void LLVOAvatar::updateImpostors() gPipeline.generateImpostor(avatar); } } + + LLCharacter::sAllowInstancesChange = TRUE ; } BOOL LLVOAvatar::isImpostor() const -- cgit v1.2.3