From 95498368767fcdd8e14b47aae48af51daaf31d4f Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Tue, 16 Jul 2024 13:14:12 +0200 Subject: #2036 BugSplat Crash #1494874: LLScrollingPanelList::updatePanelVisiblilty()(220) --- indra/llui/llscrollingpanellist.cpp | 44 ++++++++++++++----------------------- 1 file changed, 17 insertions(+), 27 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llscrollingpanellist.cpp b/indra/llui/llscrollingpanellist.cpp index b158d7b1b7..7696a27320 100644 --- a/indra/llui/llscrollingpanellist.cpp +++ b/indra/llui/llscrollingpanellist.cpp @@ -84,42 +84,35 @@ void LLScrollingPanelList::removePanel(LLScrollingPanel* panel) if (!mPanelList.empty()) { - for (iter = mPanelList.begin(); iter != mPanelList.end(); ++iter, ++index) - { - if (*iter == panel) - { - break; - } - } + LLScrollingPanelList::panel_list_t::const_iterator iter = + std::find(mPanelList.begin(), mPanelList.end(), panel); if (iter != mPanelList.end()) { - removePanel(index); + removeChild(panel); + mPanelList.erase(iter); + rearrange(); } } } -void LLScrollingPanelList::removePanel( U32 panel_index ) +void LLScrollingPanelList::removePanel(U32 panel_index) { - if ( mPanelList.empty() || panel_index >= mPanelList.size() ) + if (panel_index >= mPanelList.size()) { LL_WARNS() << "Panel index " << panel_index << " is out of range!" << LL_ENDL; return; } - else - { - removeChild( mPanelList.at(panel_index) ); - mPanelList.erase( mPanelList.begin() + panel_index ); - } + LLScrollingPanelList::panel_list_t::const_iterator iter = mPanelList.begin() + panel_index; + removeChild(*iter); + mPanelList.erase(iter); rearrange(); } void LLScrollingPanelList::updatePanels(bool allow_modify) { - for (std::deque::iterator iter = mPanelList.begin(); - iter != mPanelList.end(); ++iter) + for (LLScrollingPanel* childp : mPanelList) { - LLScrollingPanel *childp = *iter; childp->updatePanel(allow_modify); } } @@ -131,10 +124,8 @@ void LLScrollingPanelList::rearrange() if (!mPanelList.empty()) { new_width = new_height = mPadding * 2; - for (std::deque::iterator iter = mPanelList.begin(); - iter != mPanelList.end(); ++iter) + for (LLScrollingPanel* childp : mPanelList) { - LLScrollingPanel* childp = *iter; const LLRect& rect = childp->getRect(); if (mIsHorizontal) { @@ -180,10 +171,8 @@ void LLScrollingPanelList::rearrange() // Reposition each of the child views S32 pos = mIsHorizontal ? mPadding : rc.getHeight() - mPadding; - for (std::deque::iterator iter = mPanelList.begin(); - iter != mPanelList.end(); ++iter) + for (LLScrollingPanel* childp : mPanelList) { - LLScrollingPanel* childp = *iter; const LLRect& rect = childp->getRect(); if (mIsHorizontal) { @@ -211,10 +200,11 @@ void LLScrollingPanelList::updatePanelVisiblilty() getParent()->getRect().getHeight() - mPadding, &parent_screen_rect.mRight, &parent_screen_rect.mTop ); - for (std::deque::iterator iter = mPanelList.begin(); - iter != mPanelList.end(); ++iter) + for (LLScrollingPanel* childp : mPanelList) { - LLScrollingPanel *childp = *iter; + if (childp->isDead()) + continue; + const LLRect& local_rect = childp->getRect(); LLRect screen_rect; childp->localPointToScreen( -- cgit v1.2.3