From 86c230e4902ec06bb65e81b638d60e6b80b51613 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Thu, 3 Jun 2010 11:26:38 +0300 Subject: EXT-7503 WIP Made first inventory fetch in My Outfits panel only on first panel opening. * LLOutfitsList is not Inventory Observer anymore * Content is fetched in onOpen now * Added call of the LLOutfitsList::onOpen when "My Outfits" tab is switched on in My Appearance panel Reviewed by Brad Payne at https://codereview.productengine.com/secondlife/r/456/ --HG-- branch : product-engine --- indra/newview/lloutfitslist.cpp | 55 +++++++++++++++---------------- indra/newview/lloutfitslist.h | 12 +++---- indra/newview/llpaneloutfitsinventory.cpp | 1 + 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index 98ec272e96..7bf41b0f92 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -84,11 +84,9 @@ LLOutfitsList::LLOutfitsList() : LLPanel() , mAccordion(NULL) , mListCommands(NULL) + , mIsInitialized(false) { mCategoriesObserver = new LLInventoryCategoriesObserver(); - gInventory.addObserver(mCategoriesObserver); - - gInventory.addObserver(this); mOutfitMenu = new OutfitContextMenu(); } @@ -102,11 +100,6 @@ LLOutfitsList::~LLOutfitsList() gInventory.removeObserver(mCategoriesObserver); delete mCategoriesObserver; } - - if (gInventory.containsObserver(this)) - { - gInventory.removeObserver(this); - } } BOOL LLOutfitsList::postBuild() @@ -117,32 +110,36 @@ BOOL LLOutfitsList::postBuild() } //virtual -void LLOutfitsList::changed(U32 mask) +void LLOutfitsList::onOpen(const LLSD& /*info*/) { - if (!gInventory.isInventoryUsable()) - return; + if (!mIsInitialized) + { + // *TODO: I'm not sure is this check necessary but it never match while developing. + if (!gInventory.isInventoryUsable()) + return; - const LLUUID outfits = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); - LLViewerInventoryCategory* category = gInventory.getCategory(outfits); - if (!category) - return; + const LLUUID outfits = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); + + // *TODO: I'm not sure is this check necessary but it never match while developing. + LLViewerInventoryCategory* category = gInventory.getCategory(outfits); + if (!category) + return; + + gInventory.addObserver(mCategoriesObserver); - // Start observing changes in "My Outfits" category. - mCategoriesObserver->addCategory(outfits, + // Start observing changes in "My Outfits" category. + mCategoriesObserver->addCategory(outfits, boost::bind(&LLOutfitsList::refreshList, this, outfits)); - // Fetch "My Outfits" contents and refresh the list to display - // initially fetched items. If not all items are fetched now - // the observer will refresh the list as soon as the new items - // arrive. - category->fetch(); - refreshList(outfits); - - // This observer is used to start the initial outfits fetch - // when inventory becomes usable. It is no longer needed because - // "My Outfits" category is now observed by - // LLInventoryCategoriesObserver. - gInventory.removeObserver(this); + // Fetch "My Outfits" contents and refresh the list to display + // initially fetched items. If not all items are fetched now + // the observer will refresh the list as soon as the new items + // arrive. + category->fetch(); + refreshList(outfits); + + mIsInitialized = true; + } } void LLOutfitsList::refreshList(const LLUUID& category_id) diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h index d3da850e19..6dbdf00067 100644 --- a/indra/newview/lloutfitslist.h +++ b/indra/newview/lloutfitslist.h @@ -49,12 +49,10 @@ class LLListContextMenu; * A list of agents's outfits from "My Outfits" inventory category * which displays each outfit in an accordion tab with a flat list * of items inside it. - * Uses LLInventoryCategoriesObserver to monitor changes to "My Outfits" - * inventory category and refresh the outfits listed in it. - * This class is derived from LLInventoryObserver to know when inventory - * becomes usable and it is safe to request data from inventory model. + * + * Starts fetching nevessary inventory content on first openning. */ -class LLOutfitsList : public LLPanel, public LLInventoryObserver +class LLOutfitsList : public LLPanel { public: LLOutfitsList(); @@ -62,7 +60,7 @@ public: /*virtual*/ BOOL postBuild(); - /*virtual*/ void changed(U32 mask); + /*virtual*/ void onOpen(const LLSD& info); void refreshList(const LLUUID& category_id); @@ -128,6 +126,8 @@ private: outfits_map_t mOutfitsMap; LLListContextMenu* mOutfitMenu; + + bool mIsInitialized; }; #endif //LL_LLOUTFITSLIST_H diff --git a/indra/newview/llpaneloutfitsinventory.cpp b/indra/newview/llpaneloutfitsinventory.cpp index 21f69d3470..9babddc033 100644 --- a/indra/newview/llpaneloutfitsinventory.cpp +++ b/indra/newview/llpaneloutfitsinventory.cpp @@ -632,6 +632,7 @@ void LLPanelOutfitsInventory::onTabChange() else { mMyOutfitsPanel->setFilterSubString(mFilterSubString); + mMyOutfitsPanel->onOpen(LLSD()); } updateVerbs(); -- cgit v1.2.3 From 5459e26392e3b3b80c0bf8bbc930d0a93ee8e214 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Thu, 3 Jun 2010 12:47:18 +0300 Subject: EXT-7503 WIP Made first inventory fetch for Add to Outfit panel on the first openning, updated reliability of LLInventoryFetchItemsObserver * Moved initialization (with start fetch) of the LLFilteredWearableListManager into LLPanelOutfitEdit::onOpen * LLFilteredWearableListManager::changed now ignores non-related inventory changes (CALLING_CARD, GESTURE, SORT) Tried to fix an issue with empty Gesture list on startup with clean inventory cache. Reason: logic is based on count of "inventory changed" events. In case of there was too many requests requested items can be removed from queue by mistake. * Increased a number of the "change()" method calls to wait fetched items. Unfortunately this only works if My Inventory category does not have too many children. An does not work if it has 2000+ items Logic to remove item from the incompleted list should be based on timer and number of attempts. Also add some debug information about fetching inventory category and its content to log. Reviewed by Brad Payne at https://codereview.productengine.com/secondlife/r/456/ --HG-- branch : product-engine --- indra/newview/llfilteredwearablelist.cpp | 9 +++++++++ indra/newview/llinventorymodelbackgroundfetch.cpp | 2 ++ indra/newview/llinventoryobserver.cpp | 2 +- indra/newview/llpaneloutfitedit.cpp | 4 +++- indra/newview/llviewerinventory.cpp | 1 + 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/indra/newview/llfilteredwearablelist.cpp b/indra/newview/llfilteredwearablelist.cpp index 28e159421c..0c13bbcab7 100644 --- a/indra/newview/llfilteredwearablelist.cpp +++ b/indra/newview/llfilteredwearablelist.cpp @@ -54,6 +54,15 @@ LLFilteredWearableListManager::~LLFilteredWearableListManager() void LLFilteredWearableListManager::changed(U32 mask) { + if (LLInventoryObserver::CALLING_CARD == mask + || LLInventoryObserver::GESTURE == mask + || LLInventoryObserver::SORT == mask + ) + { + // skip non-related changes + return; + } + if(!gInventory.isInventoryUsable()) { return; diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 0ff6ab2644..b4f0947b2c 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -112,6 +112,8 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& cat_id, BOOL recursive { if (!mAllFoldersFetched) { + LL_DEBUGS("InventoryFetch") << "Start fetching category: " << cat_id << ", recursive: " << recursive << LL_ENDL; + mBackgroundFetchActive = TRUE; if (cat_id.isNull()) { diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp index 8557548887..d2b402fe14 100644 --- a/indra/newview/llinventoryobserver.cpp +++ b/indra/newview/llinventoryobserver.cpp @@ -68,7 +68,7 @@ // you're fetching an item and a notification gets triggered because // you renamed some other item). This counter is to specify how many // notification to wait for before giving up. -static const U32 MAX_NUM_NOTIFICATIONS_TO_PROCESS = 20; +static const U32 MAX_NUM_NOTIFICATIONS_TO_PROCESS = 127; LLInventoryObserver::LLInventoryObserver() { diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp index 85b4259a29..0ca5938c97 100644 --- a/indra/newview/llpaneloutfitedit.cpp +++ b/indra/newview/llpaneloutfitedit.cpp @@ -311,7 +311,6 @@ BOOL LLPanelOutfitEdit::postBuild() mWearableItemsPanel = getChild("filtered_wearables_panel"); mWearableItemsList = getChild("filtered_wearables_list"); - mWearableListManager = new LLFilteredWearableListManager(mWearableItemsList, mWearableListMaskCollector); mSaveComboBtn.reset(new LLSaveOutfitComboBtn(this)); return TRUE; @@ -322,6 +321,9 @@ void LLPanelOutfitEdit::onOpen(const LLSD& key) { if (!mInitialized) { + // *TODO: this method is called even panel is not visible to user because its parent layout panel is hidden. + // So, we can defer initializing a bit. + mWearableListManager = new LLFilteredWearableListManager(mWearableItemsList, mWearableListMaskCollector); displayCurrentOutfit(); mInitialized = true; } diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 77b0d9f8d3..4cb5e86fc2 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -606,6 +606,7 @@ bool LLViewerInventoryCategory::fetch() if((VERSION_UNKNOWN == mVersion) && mDescendentsRequested.hasExpired()) //Expired check prevents multiple downloads. { + LL_DEBUGS("InventoryFetch") << "Fetching category children: " << mName << ", UUID: " << mUUID << LL_ENDL; const F32 FETCH_TIMER_EXPIRY = 10.0f; mDescendentsRequested.reset(); mDescendentsRequested.setTimerExpirySec(FETCH_TIMER_EXPIRY); -- cgit v1.2.3 From 07ca580cfab9b587175743130c0abbeb3bf10637 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Thu, 3 Jun 2010 13:59:28 +0300 Subject: EXT-7503 WIP Made first inventory fetch for Add to Outfit panel on the first openning, updated reliability of LLInventoryFetchItemsObserver This patch follows (fce2d4f9dc1a). And contains missed by merging changes and fixes Win line endings. Reviewed by Brad Payne at https://codereview.productengine.com/secondlife/r/456/ --HG-- branch : product-engine --- indra/newview/llfilteredwearablelist.cpp | 14 +++++++------- indra/newview/llpaneloutfitedit.cpp | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/indra/newview/llfilteredwearablelist.cpp b/indra/newview/llfilteredwearablelist.cpp index 0c13bbcab7..306fa5ad6d 100644 --- a/indra/newview/llfilteredwearablelist.cpp +++ b/indra/newview/llfilteredwearablelist.cpp @@ -54,13 +54,13 @@ LLFilteredWearableListManager::~LLFilteredWearableListManager() void LLFilteredWearableListManager::changed(U32 mask) { - if (LLInventoryObserver::CALLING_CARD == mask - || LLInventoryObserver::GESTURE == mask - || LLInventoryObserver::SORT == mask - ) - { - // skip non-related changes - return; + if (LLInventoryObserver::CALLING_CARD == mask + || LLInventoryObserver::GESTURE == mask + || LLInventoryObserver::SORT == mask + ) + { + // skip non-related changes + return; } if(!gInventory.isInventoryUsable()) diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp index dee9572357..4982e98f8e 100644 --- a/indra/newview/llpaneloutfitedit.cpp +++ b/indra/newview/llpaneloutfitedit.cpp @@ -385,9 +385,10 @@ void LLPanelOutfitEdit::onOpen(const LLSD& key) { if (!mInitialized) { - // *TODO: this method is called even panel is not visible to user because its parent layout panel is hidden. + // *TODO: this method is called even panel is not visible to user because its parent layout panel is hidden. // So, we can defer initializing a bit. mWearableListManager = new LLFilteredWearableListManager(mWearableItemsList, mWearableListMaskCollector); + mWearableListManager->populateList(); displayCurrentOutfit(); mInitialized = true; } -- cgit v1.2.3