5454#include " llvoavatarself.h"
5555#include " llwearableitemslist.h"
5656
57- static bool is_tab_header_clicked (LLAccordionCtrlTab * tab, S32 y);
57+ static bool is_tab_header_clicked (LLOutfitAccordionCtrlTab * tab, S32 y);
5858
5959static const LLOutfitTabNameComparator OUTFIT_TAB_NAME_COMPARATOR;
6060static const LLOutfitTabFavComparator OUTFIT_TAB_FAV_COMPARATOR;
@@ -246,7 +246,10 @@ void LLOutfitsList::updateAddedCategory(LLUUID cat_id)
246246 list->setCommitCallback (boost::bind (&LLOutfitsList::onListSelectionChange, this , _1));
247247
248248 // Setting list refresh callback to apply filter on list change.
249- list->setRefreshCompleteCallback (boost::bind (&LLOutfitsList::onRefreshComplete, this , _1));
249+ list->setRefreshCompleteCallback ([this , tab](LLUICtrl* ctrl, const LLSD& sd)
250+ {
251+ onRefreshComplete (ctrl, tab);
252+ });
250253
251254 list->setRightMouseDownCallback (boost::bind (&LLOutfitsList::onWearableItemsListRightClick, this , _1, _2, _3));
252255
@@ -294,7 +297,7 @@ void LLOutfitsList::updateRemovedCategory(LLUUID cat_id)
294297 if (outfits_iter != mOutfitsMap .end ())
295298 {
296299 const LLUUID& outfit_id = outfits_iter->first ;
297- LLAccordionCtrlTab * tab = outfits_iter->second ;
300+ LLOutfitAccordionCtrlTab * tab = outfits_iter->second ;
298301
299302 // An outfit is removed from the list. Do the following:
300303 // 1. Remove outfit category from observer to stop monitoring its changes.
@@ -322,11 +325,11 @@ void LLOutfitsList::onHighlightBaseOutfit(LLUUID base_id, LLUUID prev_id)
322325{
323326 if (mOutfitsMap [prev_id])
324327 {
325- ((LLOutfitAccordionCtrlTab*) mOutfitsMap [prev_id]) ->setOutfitSelected (false );
328+ mOutfitsMap [prev_id]->setOutfitSelected (false );
326329 }
327330 if (mOutfitsMap [base_id])
328331 {
329- ((LLOutfitAccordionCtrlTab*) mOutfitsMap [base_id]) ->setOutfitSelected (true );
332+ mOutfitsMap [base_id]->setOutfitSelected (true );
330333 }
331334}
332335
@@ -370,7 +373,7 @@ void LLOutfitsList::onSetSelectedOutfitByUUID(const LLUUID& outfit_uuid)
370373 {
371374 if (outfit_uuid == iter->first )
372375 {
373- LLAccordionCtrlTab * tab = iter->second ;
376+ LLOutfitAccordionCtrlTab * tab = iter->second ;
374377 if (!tab) continue ;
375378
376379 LLWearableItemsList* list = dynamic_cast <LLWearableItemsList*>(tab->getAccordionView ());
@@ -464,7 +467,7 @@ void LLOutfitsList::onCollapseAllFolders()
464467 iter != mOutfitsMap .end ();
465468 ++iter)
466469 {
467- LLAccordionCtrlTab * tab = iter->second ;
470+ LLOutfitAccordionCtrlTab * tab = iter->second ;
468471 if (tab && tab->isExpanded ())
469472 {
470473 tab->changeOpenClose (true );
@@ -478,7 +481,7 @@ void LLOutfitsList::onExpandAllFolders()
478481 iter != mOutfitsMap .end ();
479482 ++iter)
480483 {
481- LLAccordionCtrlTab * tab = iter->second ;
484+ LLOutfitAccordionCtrlTab * tab = iter->second ;
482485 if (tab && !tab->isExpanded ())
483486 {
484487 tab->changeOpenClose (false );
@@ -501,7 +504,7 @@ void LLOutfitsList::updateChangedCategoryName(LLViewerInventoryCategory *cat, st
501504 if (outfits_iter != mOutfitsMap .end ())
502505 {
503506 // Update tab name with the new category name.
504- LLOutfitAccordionCtrlTab* tab = (LLOutfitAccordionCtrlTab*) outfits_iter->second ;
507+ LLOutfitAccordionCtrlTab* tab = outfits_iter->second ;
505508 if (tab)
506509 {
507510 tab->setName (name);
@@ -554,7 +557,7 @@ void LLOutfitsList::deselectOutfit(const LLUUID& category_id)
554557 LLOutfitListBase::deselectOutfit (category_id);
555558}
556559
557- void LLOutfitsList::restoreOutfitSelection (LLAccordionCtrlTab * tab, const LLUUID& category_id)
560+ void LLOutfitsList::restoreOutfitSelection (LLOutfitAccordionCtrlTab * tab, const LLUUID& category_id)
558561{
559562 // Try restoring outfit selection after filtering.
560563 if (mAccordion ->getSelectedTab () == tab)
@@ -563,27 +566,21 @@ void LLOutfitsList::restoreOutfitSelection(LLAccordionCtrlTab* tab, const LLUUID
563566 }
564567}
565568
566- void LLOutfitsList::onRefreshComplete (LLUICtrl* ctrl)
569+ void LLOutfitsList::onRefreshComplete (LLUICtrl* ctrl, LLOutfitAccordionCtrlTab* tab )
567570{
568571 if (!ctrl || getFilterSubString ().empty ())
569572 return ;
570573
571- LL_PROFILE_ZONE_SCOPED;
572-
573- // TODO: We are doing it multiple times per frame on init
574- // as multiple lists are refreshing. Needs improvements.
575- for (outfits_map_t ::iterator
576- iter = mOutfitsMap .begin (),
577- iter_end = mOutfitsMap .end ();
578- iter != iter_end; ++iter)
574+ LLWearableItemsList* list = dynamic_cast <LLWearableItemsList*>(tab->getAccordionView ());
575+ if (list != ctrl)
579576 {
580- LLAccordionCtrlTab* tab = iter-> second ;
581- if (!tab) continue ;
582-
583- LLWearableItemsList* list = dynamic_cast <LLWearableItemsList*>(tab-> getAccordionView ());
584- if (list != ctrl) continue ;
585-
586- applyFilterToTab (iter-> first , tab, getFilterSubString ());
577+ llassert ( false ) ;
578+ LL_WARNS () << " LLOutfitsList::onRefreshComplete: ctrl does not match tab's list! " << LL_ENDL ;
579+ return ;
580+ }
581+ if (tab-> getFilterGeneration () != getFilterGeneration ())
582+ {
583+ applyFilterToTab (tab-> getFolderID () , tab, getFilterSubString ());
587584 }
588585}
589586
@@ -596,7 +593,7 @@ void LLOutfitsList::onFilterSubStringChanged(const std::string& new_string, cons
596593 while (iter != iter_end)
597594 {
598595 const LLUUID& category_id = iter->first ;
599- LLAccordionCtrlTab * tab = iter++->second ;
596+ LLOutfitAccordionCtrlTab * tab = iter++->second ;
600597 if (!tab) continue ;
601598
602599 LLWearableItemsList* list = dynamic_cast <LLWearableItemsList*>(tab->getAccordionView ());
@@ -635,9 +632,10 @@ void LLOutfitsList::onFilterSubStringChanged(const std::string& new_string, cons
635632
636633void LLOutfitsList::applyFilterToTab (
637634 const LLUUID& category_id,
638- LLAccordionCtrlTab * tab,
635+ LLOutfitAccordionCtrlTab * tab,
639636 const std::string& filter_substring)
640637{
638+ LL_PROFILE_ZONE_SCOPED;
641639 if (!tab) return ;
642640 LLWearableItemsList* list = dynamic_cast <LLWearableItemsList*>(tab->getAccordionView ());
643641 if (!list) return ;
@@ -649,6 +647,7 @@ void LLOutfitsList::applyFilterToTab(
649647 LLStringUtil::toUpper (cur_filter);
650648
651649 tab->setTitle (tab->getTitle (), cur_filter);
650+ tab->setFilterGeneration (getFilterGeneration ());
652651
653652 if (std::string::npos == title.find (cur_filter))
654653 {
@@ -772,7 +771,7 @@ void LLOutfitsList::onCOFChanged()
772771 outfits_map_t ::iterator map_iter = mOutfitsMap .begin (), map_end = mOutfitsMap .end ();
773772 while (map_iter != map_end)
774773 {
775- LLAccordionCtrlTab * tab = (map_iter++)->second ;
774+ LLOutfitAccordionCtrlTab * tab = (map_iter++)->second ;
776775 if (!tab) continue ;
777776
778777 LLWearableItemsList* list = dynamic_cast <LLWearableItemsList*>(tab->getAccordionView ());
@@ -803,7 +802,7 @@ void LLOutfitsList::sortOutfits()
803802
804803void LLOutfitsList::onOutfitRightClick (LLUICtrl* ctrl, S32 x, S32 y, const LLUUID& cat_id)
805804{
806- LLAccordionCtrlTab * tab = dynamic_cast <LLAccordionCtrlTab *>(ctrl);
805+ LLOutfitAccordionCtrlTab * tab = dynamic_cast <LLOutfitAccordionCtrlTab *>(ctrl);
807806 if (mOutfitMenu && is_tab_header_clicked (tab, y) && cat_id.notNull ())
808807 {
809808 // Focus tab header to trigger tab selection change.
@@ -826,7 +825,7 @@ void LLOutfitsList::handleInvFavColorChange()
826825 ++iter)
827826 {
828827 if (!iter->second ) continue ;
829- LLOutfitAccordionCtrlTab* tab = (LLOutfitAccordionCtrlTab*) iter->second ;
828+ LLOutfitAccordionCtrlTab* tab = iter->second ;
830829
831830 // refresh font color
832831 tab->setFavorite (tab->getFavorite ());
@@ -853,7 +852,7 @@ void LLOutfitsList::onChangeSortOrder(const LLSD& userdata)
853852 {
854853 for (outfits_map_t ::value_type& outfit : mOutfitsMap )
855854 {
856- LLAccordionCtrlTab * tab = outfit.second ;
855+ LLOutfitAccordionCtrlTab * tab = outfit.second ;
857856 const LLUUID& category_id = outfit.first ;
858857 if (!tab) continue ;
859858
@@ -894,7 +893,7 @@ LLOutfitListGearMenuBase* LLOutfitsList::createGearMenu()
894893}
895894
896895
897- bool is_tab_header_clicked (LLAccordionCtrlTab * tab, S32 y)
896+ bool is_tab_header_clicked (LLOutfitAccordionCtrlTab * tab, S32 y)
898897{
899898 if (!tab || !tab->getHeaderVisible ()) return false ;
900899
0 commit comments