diff options
Diffstat (limited to 'indra/newview/llpopupview.cpp')
-rw-r--r-- | indra/newview/llpopupview.cpp | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/indra/newview/llpopupview.cpp b/indra/newview/llpopupview.cpp index d8ad59c90c..4523bf2ba4 100644 --- a/indra/newview/llpopupview.cpp +++ b/indra/newview/llpopupview.cpp @@ -104,14 +104,18 @@ BOOL LLPopupView::handleMouseEvent(boost::function<BOOL(LLView*, S32, S32)> func S32 x, S32 y, bool close_popups) { - for (popup_list_t::iterator popup_it = mPopups.begin(); - popup_it != mPopups.end();) + BOOL handled = FALSE; + + // make a copy of list of popups, in case list is modified during mouse event handling + popup_list_t popups(mPopups); + for (popup_list_t::iterator popup_it = popups.begin(), popup_end = popups.end(); + popup_it != popup_end; + ++popup_it) { LLView* popup = popup_it->get(); if (!popup || !predicate(popup)) { - ++popup_it; continue; } @@ -121,23 +125,19 @@ BOOL LLPopupView::handleMouseEvent(boost::function<BOOL(LLView*, S32, S32)> func { if (func(popup, popup_x, popup_y)) { - return TRUE; + handled = TRUE; + break; } } if (close_popups) { - popup_list_t::iterator cur_popup_it = popup_it++; - mPopups.erase(cur_popup_it); + mPopups.remove(*popup_it); popup->onTopLost(); } - else - { - ++popup_it; - } } - return FALSE; + return handled; } @@ -207,11 +207,7 @@ void LLPopupView::addPopup(LLView* popup) { if (popup) { - popup_list_t::iterator iter = std::find(mPopups.begin(), mPopups.end(), popup->getHandle()); - if(iter != mPopups.end()) - { - mPopups.erase(iter); - } + mPopups.remove(popup->getHandle()); mPopups.push_front(popup->getHandle()); } } @@ -220,11 +216,7 @@ void LLPopupView::removePopup(LLView* popup) { if (popup) { - popup_list_t::iterator iter = std::find(mPopups.begin(), mPopups.end(), popup->getHandle()); - if(iter != mPopups.end()) - { - mPopups.erase(iter); - } + mPopups.remove(popup->getHandle()); popup->onTopLost(); } } |