From 2e47e6d816f08bf75ed7dd06230996cfa606a737 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 25 Mar 2010 17:21:39 -0600 Subject: fix for EXT-5854:Unable to Pay Object That Features Transparant (alpha) Texture. (transplanted from 3939f139f6caff2bb192a2afde18e51aada4d57a) --- indra/llrender/llimagegl.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 68b556c3bb..cd851cf8a3 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1705,8 +1705,8 @@ void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in) U32 size = pick_width * pick_height; size = (size + 7) / 8; // pixelcount-to-bits mPickMask = new U8[size]; - mPickMaskWidth = pick_width; - mPickMaskHeight = pick_height; + mPickMaskWidth = pick_width - 1; + mPickMaskHeight = pick_height - 1; memset(mPickMask, 0, sizeof(U8) * size); @@ -1749,20 +1749,20 @@ BOOL LLImageGL::getMask(const LLVector2 &tc) llassert(false); } - llassert(mPickMaskWidth > 0 && mPickMaskHeight > 0); + llassert(mPickMaskWidth >= 0 && mPickMaskHeight >= 0); S32 x = llfloor(u * mPickMaskWidth); S32 y = llfloor(v * mPickMaskHeight); - if (LL_UNLIKELY(x >= mPickMaskWidth)) + if (LL_UNLIKELY(x > mPickMaskWidth)) { LL_WARNS_ONCE("render") << "Ooh, width overrun on pick mask read, that coulda been bad." << LL_ENDL; - x = llmax(0, mPickMaskWidth-1); + x = llmax((U16)0, mPickMaskWidth); } - if (LL_UNLIKELY(y >= mPickMaskHeight)) + if (LL_UNLIKELY(y > mPickMaskHeight)) { LL_WARNS_ONCE("render") << "Ooh, height overrun on pick mask read, that woulda been bad." << LL_ENDL; - y = llmax(0, mPickMaskHeight-1); + y = llmax((U16)0, mPickMaskHeight); } S32 idx = y*mPickMaskWidth+x; -- cgit v1.2.3 From 12e570913cadc1c2abb82306d42f9cd93dd7cba6 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Fri, 26 Mar 2010 16:57:56 -0700 Subject: EXT-EXT-6317 - cursor does not indicate clicking will trigger an action when over transparent objects reviewed by Leyla (transplanted from 4b90aa824b05ef6d29973b55bec8eb6210e1edf9) --- indra/newview/lltoolpie.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index d15db536e6..aa5c99439c 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -496,6 +496,8 @@ void LLToolPie::selectionPropertiesReceived() BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask) { mHoverPick = gViewerWindow->pickImmediate(x, y, FALSE); + // perform a separate pick that detects transparent objects since they respond to 1-click actions + LLPickInfo click_action_pick = gViewerWindow->pickImmediate(x, y, TRUE); // Show screen-space highlight glow effect bool show_highlight = false; @@ -507,10 +509,11 @@ BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask) parent = object->getRootEdit(); } - if (object && useClickAction(mask, object, parent)) + LLViewerObject* click_action_object = click_action_pick.getObject(); + if (click_action_object && useClickAction(mask, click_action_object, click_action_object->getRootEdit())) { show_highlight = true; - ECursorType cursor = cursor_from_object(object); + ECursorType cursor = cursor_from_object(click_action_object); gViewerWindow->setCursor(cursor); lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPie (inactive)" << llendl; } -- cgit v1.2.3 From 6a1677d9e5907b4e34a0e71084a95c1fa138569d Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Fri, 26 Mar 2010 08:54:58 +0000 Subject: If the EXT-5854 fix is correct, this assert no longer makes sense. (transplanted from 3bef6f249a0ab74f823e67fb32339abb92b13165) --- indra/llrender/llimagegl.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index cd851cf8a3..8addee606b 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1749,8 +1749,6 @@ BOOL LLImageGL::getMask(const LLVector2 &tc) llassert(false); } - llassert(mPickMaskWidth >= 0 && mPickMaskHeight >= 0); - S32 x = llfloor(u * mPickMaskWidth); S32 y = llfloor(v * mPickMaskHeight); -- cgit v1.2.3 From cdbdb1168694bcbfc58208f2941f513b556a0d6e Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Tue, 6 Apr 2010 14:47:20 -0400 Subject: EXT-4151 : Immediately check if a fetchObserver filter is done, else add to observer list automatically FetchObservers now take in a list of IDs to check against. Made some naming changes. --- indra/newview/llagentwearables.cpp | 21 +++++---- indra/newview/llagentwearablesfetch.cpp | 35 ++++++++------- indra/newview/llagentwearablesfetch.h | 4 +- indra/newview/llappearancemgr.h | 17 ++++--- indra/newview/llfloatergesture.cpp | 6 ++- indra/newview/llfriendcard.cpp | 15 ++++--- indra/newview/llgesturemgr.cpp | 5 ++- indra/newview/llgesturemgr.h | 2 +- indra/newview/llinventorybridge.cpp | 27 ++++++++---- indra/newview/llinventoryobserver.cpp | 43 +++++++++++------- indra/newview/llinventoryobserver.h | 78 +++++++++++++++++---------------- indra/newview/llpaneloutfitedit.cpp | 3 +- indra/newview/llsidepanelappearance.cpp | 12 ++--- indra/newview/llstartup.cpp | 3 +- indra/newview/lltooldraganddrop.cpp | 16 ++++--- indra/newview/llviewermenu.cpp | 15 ++++--- indra/newview/llviewermessage.cpp | 29 +++++++----- 17 files changed, 187 insertions(+), 144 deletions(-) diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp index 9d3b5763e8..bc8931827e 100644 --- a/indra/newview/llagentwearables.cpp +++ b/indra/newview/llagentwearables.cpp @@ -905,8 +905,9 @@ void LLAgentWearables::processAgentInitialWearablesUpdate(LLMessageSystem* mesgs // Get the UUID of the current outfit folder (will be created if it doesn't exist) const LLUUID current_outfit_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); - - LLInitialWearablesFetch* outfit = new LLInitialWearablesFetch(); + uuid_vec_t folders; + folders.push_back(current_outfit_id); + LLInitialWearablesFetch* outfit = new LLInitialWearablesFetch(folders); //lldebugs << "processAgentInitialWearablesUpdate()" << llendl; // Add wearables @@ -952,9 +953,7 @@ void LLAgentWearables::processAgentInitialWearablesUpdate(LLMessageSystem* mesgs // Get the complete information on the items in the inventory and set up an observer // that will trigger when the complete information is fetched. - uuid_vec_t folders; - folders.push_back(current_outfit_id); - outfit->fetch(folders); + outfit->startFetch(); if(outfit->isEverythingComplete()) { // everything is already here - call done. @@ -2061,16 +2060,16 @@ void LLAgentWearables::populateMyOutfitsFolder(void) { llinfos << "starting outfit population" << llendl; - LLLibraryOutfitsFetch* outfits = new LLLibraryOutfitsFetch(); + const LLUUID& my_outfits_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); + uuid_vec_t folders; + folders.push_back(my_outfits_id); + LLLibraryOutfitsFetch* outfits = new LLLibraryOutfitsFetch(folders); + outfits->mMyOutfitsID = my_outfits_id; // Get the complete information on the items in the inventory and // setup an observer that will wait for that to happen. - uuid_vec_t folders; - outfits->mMyOutfitsID = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); - - folders.push_back(outfits->mMyOutfitsID); gInventory.addObserver(outfits); - outfits->fetch(folders); + outfits->startFetch(); if (outfits->isEverythingComplete()) { outfits->done(); diff --git a/indra/newview/llagentwearablesfetch.cpp b/indra/newview/llagentwearablesfetch.cpp index 3d6740f5a1..6b7edaa302 100644 --- a/indra/newview/llagentwearablesfetch.cpp +++ b/indra/newview/llagentwearablesfetch.cpp @@ -39,7 +39,8 @@ #include "llinventoryfunctions.h" #include "llvoavatarself.h" -LLInitialWearablesFetch::LLInitialWearablesFetch() +LLInitialWearablesFetch::LLInitialWearablesFetch(const uuid_vec_t& ids) : + LLInventoryFetchDescendentsObserver(ids) { } @@ -86,12 +87,11 @@ void LLInitialWearablesFetch::processContents() delete this; } -class LLFetchAndLinkObserver: public LLInventoryFetchObserver +class LLFetchAndLinkObserver: public LLInventoryFetchItemsObserver { public: LLFetchAndLinkObserver(uuid_vec_t& ids): - m_ids(ids), - LLInventoryFetchObserver(true) // retry for missing items + LLInventoryFetchItemsObserver(ids, true) // retry for missing items { } ~LLFetchAndLinkObserver() @@ -103,8 +103,8 @@ public: // Link to all fetched items in COF. LLPointer link_waiter = new LLUpdateAppearanceOnDestroy; - for (uuid_vec_t::iterator it = m_ids.begin(); - it != m_ids.end(); + for (uuid_vec_t::iterator it = mIDs.begin(); + it != mIDs.end(); ++it) { LLUUID id = *it; @@ -123,8 +123,6 @@ public: link_waiter); } } -private: - uuid_vec_t m_ids; }; void LLInitialWearablesFetch::processWearablesMessage() @@ -173,9 +171,9 @@ void LLInitialWearablesFetch::processWearablesMessage() // Need to fetch the inventory items for ids, then create links to them after they arrive. LLFetchAndLinkObserver *fetcher = new LLFetchAndLinkObserver(ids); - fetcher->fetch(ids); + fetcher->startFetch(); // If no items to be fetched, done will never be triggered. - // TODO: Change LLInventoryFetchObserver::fetchItems to trigger done() on this condition. + // TODO: Change LLInventoryFetchItemsObserver::fetchItems to trigger done() on this condition. if (fetcher->isEverythingComplete()) { fetcher->done(); @@ -191,7 +189,8 @@ void LLInitialWearablesFetch::processWearablesMessage() } } -LLLibraryOutfitsFetch::LLLibraryOutfitsFetch() : +LLLibraryOutfitsFetch::LLLibraryOutfitsFetch(const uuid_vec_t& ids) : + LLInventoryFetchDescendentsObserver(ids), mCurrFetchStep(LOFS_FOLDER), mOutfitsPopulated(false) { @@ -288,7 +287,8 @@ void LLLibraryOutfitsFetch::folderDone() uuid_vec_t folders; folders.push_back(mClothingID); folders.push_back(mLibraryClothingID); - fetch(folders); + setFolders(folders); + startFetch(); if (isEverythingComplete()) { done(); @@ -337,8 +337,8 @@ void LLLibraryOutfitsFetch::outfitsDone() } mComplete.clear(); - - fetch(folders); + setFolders(folders); + startFetch(); if (isEverythingComplete()) { done(); @@ -434,8 +434,8 @@ void LLLibraryOutfitsFetch::importedFolderFetch() folders.push_back(mImportedClothingID); mComplete.clear(); - - fetch(folders); + setFolders(folders); + startFetch(); if (isEverythingComplete()) { done(); @@ -464,7 +464,8 @@ void LLLibraryOutfitsFetch::importedFolderDone() } mComplete.clear(); - fetch(folders); + setFolders(folders); + startFetch(); if (isEverythingComplete()) { done(); diff --git a/indra/newview/llagentwearablesfetch.h b/indra/newview/llagentwearablesfetch.h index 1d0c6739ba..33368811c0 100644 --- a/indra/newview/llagentwearablesfetch.h +++ b/indra/newview/llagentwearablesfetch.h @@ -47,7 +47,7 @@ class LLInitialWearablesFetch : public LLInventoryFetchDescendentsObserver { public: - LLInitialWearablesFetch(); + LLInitialWearablesFetch(const uuid_vec_t& ids); ~LLInitialWearablesFetch(); virtual void done(); @@ -92,7 +92,7 @@ public: LOFS_CONTENTS }; - LLLibraryOutfitsFetch(); + LLLibraryOutfitsFetch(const uuid_vec_t& ids); ~LLLibraryOutfitsFetch(); virtual void done(); diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index 40b8844731..1cf8d584db 100644 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -244,10 +244,12 @@ void doOnIdleRepeating(T callable) } template -class CallAfterCategoryFetchStage2: public LLInventoryFetchObserver +class CallAfterCategoryFetchStage2: public LLInventoryFetchItemsObserver { public: - CallAfterCategoryFetchStage2(T callable): + CallAfterCategoryFetchStage2(const uuid_vec_t& ids, + T callable) : + LLInventoryFetchItemsObserver(ids), mCallable(callable) { } @@ -268,7 +270,8 @@ template class CallAfterCategoryFetchStage1: public LLInventoryFetchDescendentsObserver { public: - CallAfterCategoryFetchStage1(T callable): + CallAfterCategoryFetchStage1(const uuid_vec_t& ids, T callable) : + LLInventoryFetchDescendentsObserver(ids), mCallable(callable) { } @@ -297,7 +300,6 @@ public: return; } - CallAfterCategoryFetchStage2 *stage2 = new CallAfterCategoryFetchStage2(mCallable); uuid_vec_t ids; for(S32 i = 0; i < count; ++i) { @@ -307,7 +309,8 @@ public: gInventory.removeObserver(this); // do the fetch - stage2->fetch(ids); + CallAfterCategoryFetchStage2 *stage2 = new CallAfterCategoryFetchStage2(ids, mCallable); + stage2->startFetch(); if(stage2->isEverythingComplete()) { // everything is already here - call done. @@ -328,10 +331,10 @@ protected: template void callAfterCategoryFetch(const LLUUID& cat_id, T callable) { - CallAfterCategoryFetchStage1 *stage1 = new CallAfterCategoryFetchStage1(callable); uuid_vec_t folders; folders.push_back(cat_id); - stage1->fetch(folders); + CallAfterCategoryFetchStage1 *stage1 = new CallAfterCategoryFetchStage1(folders, callable); + stage1->startFetch(); if (stage1->isEverythingComplete()) { stage1->done(); diff --git a/indra/newview/llfloatergesture.cpp b/indra/newview/llfloatergesture.cpp index 8ee8d13a9c..04fb6bca3c 100644 --- a/indra/newview/llfloatergesture.cpp +++ b/indra/newview/llfloatergesture.cpp @@ -148,7 +148,8 @@ void LLFloaterGesture::done() if (!unloaded_folders.empty()) { LL_DEBUGS("Gesture")<< "Fetching subdirectories....." << LL_ENDL; - fetch(unloaded_folders); + setFolders(unloaded_folders); + startFetch(); } else { @@ -202,7 +203,8 @@ BOOL LLFloaterGesture::postBuild() folders.push_back(mGestureFolderID); //perform loading Gesture directory anyway to make sure that all subdirectory are loaded too. See method done() for details. gInventory.addObserver(this); - fetch(folders); + setFolders(folders); + startFetch(); if (mGestureList) { diff --git a/indra/newview/llfriendcard.cpp b/indra/newview/llfriendcard.cpp index 6f069cca17..aaa09ba5da 100644 --- a/indra/newview/llfriendcard.cpp +++ b/indra/newview/llfriendcard.cpp @@ -111,8 +111,11 @@ class LLInitialFriendCardsFetch : public LLInventoryFetchDescendentsObserver public: typedef boost::function callback_t; - LLInitialFriendCardsFetch(callback_t cb) - : mCheckFolderCallback(cb) {} + LLInitialFriendCardsFetch(const uuid_vec_t& ids, + callback_t cb) : + LLInventoryFetchDescendentsObserver(ids), + mCheckFolderCallback(cb) + {} /* virtual */ void done(); @@ -407,13 +410,11 @@ void LLFriendCardsManager::findMatchedFriendCards(const LLUUID& avatarID, LLInve void LLFriendCardsManager::fetchAndCheckFolderDescendents(const LLUUID& folder_id, callback_t cb) { - // This instance will be deleted in LLInitialFriendCardsFetch::done(). - LLInitialFriendCardsFetch* fetch = new LLInitialFriendCardsFetch(cb); - uuid_vec_t folders; folders.push_back(folder_id); - - fetch->fetch(folders); + // This instance will be deleted in LLInitialFriendCardsFetch::done(). + LLInitialFriendCardsFetch* fetch = new LLInitialFriendCardsFetch(folders, cb); + fetch->startFetch(); if(fetch->isEverythingComplete()) { // everything is already here - call done. diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp index a4342a4bc9..034806acfc 100644 --- a/indra/newview/llgesturemgr.cpp +++ b/indra/newview/llgesturemgr.cpp @@ -100,7 +100,7 @@ void LLGestureMgr::init() void LLGestureMgr::changed(U32 mask) { - LLInventoryFetchObserver::changed(mask); + LLInventoryFetchItemsObserver::changed(mask); if (mask & LLInventoryObserver::GESTURE) { @@ -1033,7 +1033,8 @@ void LLGestureMgr::onLoadComplete(LLVFS *vfs, // Watch this item and set gesture name when item exists in inventory uuid_vec_t ids; ids.push_back(item_id); - self.fetch(ids); + self.setItems(ids); + self.startFetch(); } self.mActive[item_id] = gesture; diff --git a/indra/newview/llgesturemgr.h b/indra/newview/llgesturemgr.h index 081ca983a9..5f2c3e2d61 100644 --- a/indra/newview/llgesturemgr.h +++ b/indra/newview/llgesturemgr.h @@ -54,7 +54,7 @@ public: virtual void changed() = 0; }; -class LLGestureMgr : public LLSingleton, public LLInventoryFetchObserver +class LLGestureMgr : public LLSingleton, public LLInventoryFetchItemsObserver { public: diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index b552b5ac07..82043ab523 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -1933,13 +1933,17 @@ BOOL move_inv_category_world_to_agent(const LLUUID& object_id, } //Used by LLFolderBridge as callback for directory recursion. -class LLRightClickInventoryFetchObserver : public LLInventoryFetchObserver +class LLRightClickInventoryFetchObserver : public LLInventoryFetchItemsObserver { public: - LLRightClickInventoryFetchObserver() : + LLRightClickInventoryFetchObserver(const uuid_vec_t& ids) : + LLInventoryFetchItemsObserver(ids), mCopyItems(false) { }; - LLRightClickInventoryFetchObserver(const LLUUID& cat_id, bool copy_items) : + LLRightClickInventoryFetchObserver(const uuid_vec_t& ids, + const LLUUID& cat_id, + bool copy_items) : + LLInventoryFetchItemsObserver(ids), mCatID(cat_id), mCopyItems(copy_items) { }; @@ -1963,7 +1967,11 @@ protected: class LLRightClickInventoryFetchDescendentsObserver : public LLInventoryFetchDescendentsObserver { public: - LLRightClickInventoryFetchDescendentsObserver(bool copy_items) : mCopyItems(copy_items) {} + LLRightClickInventoryFetchDescendentsObserver(const uuid_vec_t& ids, + bool copy_items) : + LLInventoryFetchDescendentsObserver(ids), + mCopyItems(copy_items) + {} ~LLRightClickInventoryFetchDescendentsObserver() {} virtual void done(); protected: @@ -2006,14 +2014,14 @@ void LLRightClickInventoryFetchDescendentsObserver::done() } #endif - LLRightClickInventoryFetchObserver* outfit; - outfit = new LLRightClickInventoryFetchObserver(mComplete.front(), mCopyItems); uuid_vec_t ids; for(S32 i = 0; i < count; ++i) { ids.push_back(item_array.get(i)->getUUID()); } + LLRightClickInventoryFetchObserver* outfit = new LLRightClickInventoryFetchObserver(ids, mComplete.front(), mCopyItems); + // clean up, and remove this as an observer since the call to the // outfit could notify observers and throw us into an infinite // loop. @@ -2026,7 +2034,7 @@ void LLRightClickInventoryFetchDescendentsObserver::done() inc_busy_count(); // do the fetch - outfit->fetch(ids); + outfit->startFetch(); outfit->done(); //Not interested in waiting and this will be right 99% of the time. //Uncomment the following code for laggy Inventory UI. /* if(outfit->isEverythingComplete()) @@ -2715,7 +2723,7 @@ void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) mMenu = &menu; sSelf = this; - LLRightClickInventoryFetchDescendentsObserver* fetch = new LLRightClickInventoryFetchDescendentsObserver(FALSE); + uuid_vec_t folders; LLViewerInventoryCategory* category = (LLViewerInventoryCategory*)model->getCategory(mUUID); @@ -2723,7 +2731,8 @@ void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { folders.push_back(category->getUUID()); } - fetch->fetch(folders); + LLRightClickInventoryFetchDescendentsObserver* fetch = new LLRightClickInventoryFetchDescendentsObserver(folders, FALSE); + fetch->startFetch(); inc_busy_count(); if(fetch->isEverythingComplete()) { diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp index 83e1bbd5a0..0f8d76a4cc 100644 --- a/indra/newview/llinventoryobserver.cpp +++ b/indra/newview/llinventoryobserver.cpp @@ -108,12 +108,19 @@ void LLInventoryCompletionObserver::watchItem(const LLUUID& id) } } -LLInventoryFetchObserver::LLInventoryFetchObserver(bool retry_if_missing) : +LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(bool retry_if_missing) : mRetryIfMissing(retry_if_missing) { } -void LLInventoryFetchObserver::changed(U32 mask) +LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(const uuid_vec_t& ids, + bool retry_if_missing) : + mIDs(ids), + mRetryIfMissing(retry_if_missing) +{ +} + +void LLInventoryFetchItemsObserver::changed(U32 mask) { // scan through the incomplete items and move or erase them as // appropriate. @@ -153,11 +160,11 @@ void LLInventoryFetchObserver::changed(U32 mask) done(); } } - //llinfos << "LLInventoryFetchObserver::changed() mComplete size " << mComplete.size() << llendl; - //llinfos << "LLInventoryFetchObserver::changed() mIncomplete size " << mIncomplete.size() << llendl; + //llinfos << "LLInventoryFetchItemsObserver::changed() mComplete size " << mComplete.size() << llendl; + //llinfos << "LLInventoryFetchItemsObserver::changed() mIncomplete size " << mIncomplete.size() << llendl; } -bool LLInventoryFetchObserver::isEverythingComplete() const +bool LLInventoryFetchItemsObserver::isEverythingComplete() const { return mIncomplete.empty(); } @@ -223,11 +230,11 @@ void fetch_items_from_llsd(const LLSD& items_llsd) } } -void LLInventoryFetchObserver::fetch(const uuid_vec_t& ids) +void LLInventoryFetchItemsObserver::startFetch() { LLUUID owner_id; LLSD items_llsd; - for(uuid_vec_t::const_iterator it = ids.begin(); it < ids.end(); ++it) + for(uuid_vec_t::const_iterator it = mIDs.begin(); it < mIDs.end(); ++it) { LLViewerInventoryItem* item = gInventory.getItem(*it); if(item) @@ -262,6 +269,14 @@ void LLInventoryFetchObserver::fetch(const uuid_vec_t& ids) fetch_items_from_llsd(items_llsd); } +LLInventoryFetchDescendentsObserver::LLInventoryFetchDescendentsObserver() +{ +} + +LLInventoryFetchDescendentsObserver::LLInventoryFetchDescendentsObserver(const uuid_vec_t& ids) : + mIDs(ids) +{ +} // virtual void LLInventoryFetchDescendentsObserver::changed(U32 mask) { @@ -287,9 +302,9 @@ void LLInventoryFetchDescendentsObserver::changed(U32 mask) } } -void LLInventoryFetchDescendentsObserver::fetch(const uuid_vec_t& ids) +void LLInventoryFetchDescendentsObserver::startFetch() { - for(uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); ++it) + for(uuid_vec_t::const_iterator it = mIDs.begin(); it != mIDs.end(); ++it) { LLViewerInventoryCategory* cat = gInventory.getCategory(*it); if(!cat) continue; @@ -400,11 +415,10 @@ void LLInventoryFetchComboObserver::changed(U32 mask) } } -void LLInventoryFetchComboObserver::fetch( - const uuid_vec_t& folder_ids, - const uuid_vec_t& item_ids) +void LLInventoryFetchComboObserver::startFetch(const uuid_vec_t& folder_ids, + const uuid_vec_t& item_ids) { - lldebugs << "LLInventoryFetchComboObserver::fetch()" << llendl; + lldebugs << "LLInventoryFetchComboObserver::startFetch()" << llendl; for(uuid_vec_t::const_iterator fit = folder_ids.begin(); fit != folder_ids.end(); ++fit) { LLViewerInventoryCategory* cat = gInventory.getCategory(*fit); @@ -544,8 +558,7 @@ void LLInventoryAddedObserver::changed(U32 mask) } } -LLInventoryTransactionObserver::LLInventoryTransactionObserver( - const LLTransactionID& transaction_id) : +LLInventoryTransactionObserver::LLInventoryTransactionObserver(const LLTransactionID& transaction_id) : mTransactionID(transaction_id) { } diff --git a/indra/newview/llinventoryobserver.h b/indra/newview/llinventoryobserver.h index ba70552ebc..03f9e9c553 100644 --- a/indra/newview/llinventoryobserver.h +++ b/indra/newview/llinventoryobserver.h @@ -73,68 +73,46 @@ public: }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Class LLInventoryCompletionObserver -// -// Base class for doing something when when all observed items are locally -// complete. Implements the changed() method of LLInventoryObserver -// and declares a new method named done() which is called when all watched items -// have complete information in the inventory model. -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -class LLInventoryCompletionObserver : public LLInventoryObserver -{ -public: - LLInventoryCompletionObserver() {} - virtual void changed(U32 mask); - - void watchItem(const LLUUID& id); - -protected: - virtual void done() = 0; - - uuid_vec_t mComplete; - uuid_vec_t mIncomplete; -}; - - -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Class LLInventoryFetchObserver +// Class LLInventoryFetchItemsObserver // -// This class is much like the LLInventoryCompletionObserver, except -// that it handles all the the fetching necessary. Override the done() -// method to do the thing you want. +// Fetches inventory items, calls done() when all inventory has arrived. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class LLInventoryFetchObserver : public LLInventoryObserver +class LLInventoryFetchItemsObserver : public LLInventoryObserver { public: - LLInventoryFetchObserver(bool retry_if_missing = false); + LLInventoryFetchItemsObserver(bool retry_if_missing = false); + LLInventoryFetchItemsObserver(const uuid_vec_t& ids, bool retry_if_missing = false); virtual void changed(U32 mask); bool isEverythingComplete() const; - void fetch(const uuid_vec_t& ids); + void setItems(const uuid_vec_t& ids) { mIDs = ids; } + void startFetch(); + virtual void done() {}; protected: bool mRetryIfMissing; uuid_vec_t mComplete; uuid_vec_t mIncomplete; + uuid_vec_t mIDs; }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLInventoryFetchDescendentsObserver // -// This class is much like the LLInventoryCompletionObserver, except -// that it handles fetching based on category. Override the done() -// method to do the thing you want. +// Fetches children of a category/folder, calls done() when all +// inventory has arrived. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class LLInventoryFetchDescendentsObserver : public LLInventoryObserver { public: - LLInventoryFetchDescendentsObserver() {} + LLInventoryFetchDescendentsObserver(); + LLInventoryFetchDescendentsObserver(const uuid_vec_t& ids); virtual void changed(U32 mask); - void fetch(const uuid_vec_t& ids); + void setFolders(const uuid_vec_t& ids) { mIDs = ids; } + void startFetch(); bool isEverythingComplete() const; virtual void done() = 0; @@ -142,6 +120,7 @@ protected: bool isComplete(LLViewerInventoryCategory* cat); uuid_vec_t mIncomplete; uuid_vec_t mComplete; + uuid_vec_t mIDs; }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -158,7 +137,7 @@ public: LLInventoryFetchComboObserver() : mDone(false) {} virtual void changed(U32 mask); - void fetch(const uuid_vec_t& folder_ids, const uuid_vec_t& item_ids); + void startFetch(const uuid_vec_t& folder_ids, const uuid_vec_t& item_ids); virtual void done() = 0; @@ -237,6 +216,29 @@ protected: LLTransactionID mTransactionID; }; +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Class LLInventoryCompletionObserver +// +// Base class for doing something when when all observed items are locally +// complete. Implements the changed() method of LLInventoryObserver +// and declares a new method named done() which is called when all watched items +// have complete information in the inventory model. +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +class LLInventoryCompletionObserver : public LLInventoryObserver +{ +public: + LLInventoryCompletionObserver() {} + virtual void changed(U32 mask); + + void watchItem(const LLUUID& id); + +protected: + virtual void done() = 0; + + uuid_vec_t mComplete; + uuid_vec_t mIncomplete; +}; #endif // LL_LLINVENTORYOBSERVERS_H diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp index ccd1bfe224..5701fcb582 100644 --- a/indra/newview/llpaneloutfitedit.cpp +++ b/indra/newview/llpaneloutfitedit.cpp @@ -484,7 +484,8 @@ void LLPanelOutfitEdit::updateLookInfo() uuid_vec_t folders; folders.push_back(mLookID); - mFetchLook->fetch(folders); + mFetchLook->setFolders(folders); + mFetchLook->startFetch(); if (mFetchLook->isEverythingComplete()) { mFetchLook->done(); diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp index 511196809a..6dd4dc1ce7 100644 --- a/indra/newview/llsidepanelappearance.cpp +++ b/indra/newview/llsidepanelappearance.cpp @@ -52,10 +52,12 @@ static LLRegisterPanelClassWrapper t_appearance("sidepanel_appearance"); -class LLCurrentlyWornFetchObserver : public LLInventoryFetchObserver +class LLCurrentlyWornFetchObserver : public LLInventoryFetchItemsObserver { public: - LLCurrentlyWornFetchObserver(LLSidepanelAppearance *panel) : + LLCurrentlyWornFetchObserver(const uuid_vec_t &ids, + LLSidepanelAppearance *panel) : + LLInventoryFetchItemsObserver(ids), mPanel(panel) {} ~LLCurrentlyWornFetchObserver() {} @@ -390,10 +392,10 @@ void LLSidepanelAppearance::fetchInventory() } } - LLCurrentlyWornFetchObserver *fetch_worn = new LLCurrentlyWornFetchObserver(this); - fetch_worn->fetch(ids); + LLCurrentlyWornFetchObserver *fetch_worn = new LLCurrentlyWornFetchObserver(ids, this); + fetch_worn->startFetch(); // If no items to be fetched, done will never be triggered. - // TODO: Change LLInventoryFetchObserver::fetchItems to trigger done() on this condition. + // TODO: Change LLInventoryFetchItemsObserver::fetchItems to trigger done() on this condition. if (fetch_worn->isEverythingComplete()) { fetch_worn->done(); diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index d7c8b5fcd4..340327a1e2 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -1771,7 +1771,8 @@ bool idle_startup() } } // no need to add gesture to inventory observer, it's already made in constructor - LLGestureMgr::instance().fetch(item_ids); + LLGestureMgr::instance().setItems(item_ids); + LLGestureMgr::instance().startFetch(); } } gDisplaySwapBuffers = TRUE; diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 1e81e675e6..cc90b0753f 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -244,11 +244,13 @@ public: } }; -class LLCategoryDropObserver : public LLInventoryFetchObserver +class LLCategoryDropObserver : public LLInventoryFetchItemsObserver { public: LLCategoryDropObserver( + const uuid_vec_t& ids, const LLUUID& obj_id, LLToolDragAndDrop::ESource src) : + LLInventoryFetchItemsObserver(ids), mObjectID(obj_id), mSource(src) {} @@ -331,8 +333,8 @@ void LLCategoryDropDescendentsObserver::done() std::back_insert_iterator copier(ids); std::copy(unique_ids.begin(), unique_ids.end(), copier); LLCategoryDropObserver* dropper; - dropper = new LLCategoryDropObserver(mObjectID, mSource); - dropper->fetch(ids); + dropper = new LLCategoryDropObserver(ids, mObjectID, mSource); + dropper->startFetch(); if (dropper->isEverythingComplete()) { dropper->done(); @@ -480,7 +482,7 @@ void LLToolDragAndDrop::beginDrag(EDragAndDropType type, if (!folder_ids.empty() || !item_ids.empty()) { LLCategoryFireAndForget fetcher; - fetcher.fetch(folder_ids, item_ids); + fetcher.startFetch(folder_ids, item_ids); } } } @@ -550,7 +552,7 @@ void LLToolDragAndDrop::beginMultiDrag( std::back_insert_iterator copier(folder_ids); std::copy(cat_ids.begin(), cat_ids.end(), copier); LLCategoryFireAndForget fetcher; - fetcher.fetch(folder_ids, item_ids); + fetcher.startFetch(folder_ids, item_ids); } } } @@ -2576,8 +2578,8 @@ EAcceptance LLToolDragAndDrop::dad3dUpdateInventoryCategory( const LLViewerInventoryItem *item = (*item_iter); ids.push_back(item->getUUID()); } - LLCategoryDropObserver* dropper = new LLCategoryDropObserver(obj->getID(), mSource); - dropper->fetch(ids); + LLCategoryDropObserver* dropper = new LLCategoryDropObserver(ids, obj->getID(), mSource); + dropper->startFetch(); if (dropper->isEverythingComplete()) { dropper->done(); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index d91b6d0b1e..807595960e 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -6096,10 +6096,12 @@ class LLAttachmentDetach : public view_listener_t //Adding an observer for a Jira 2422 and needs to be a fetch observer //for Jira 3119 -class LLWornItemFetchedObserver : public LLInventoryFetchObserver +class LLWornItemFetchedObserver : public LLInventoryFetchItemsObserver { public: - LLWornItemFetchedObserver() {} + LLWornItemFetchedObserver(const uuid_vec_t& ids) : + LLInventoryFetchItemsObserver(ids) + {} virtual ~LLWornItemFetchedObserver() {} protected: @@ -6153,13 +6155,12 @@ class LLAttachmentEnableDrop : public view_listener_t // when the item finishes fetching worst case scenario // if a fetch is already out there (being sent from a slow sim) // we refetch and there are 2 fetches - LLWornItemFetchedObserver* wornItemFetched = new LLWornItemFetchedObserver(); + uuid_vec_t items; //add item to the inventory item to be fetched - items.push_back((*attachment_iter)->getItemID()); - - wornItemFetched->fetch(items); - gInventory.addObserver(wornItemFetched); + LLWornItemFetchedObserver* worn_item_fetched = new LLWornItemFetchedObserver(items); + worn_item_fetched->startFetch(); + gInventory.addObserver(worn_item_fetched); } } } diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index a471876ce1..6f39de996e 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -700,10 +700,13 @@ static LLNotificationFunctorRegistration jgr_3("JoinGroupCanAfford", join_group_ //----------------------------------------------------------------------------- // Instant Message //----------------------------------------------------------------------------- -class LLOpenAgentOffer : public LLInventoryFetchObserver +class LLOpenAgentOffer : public LLInventoryFetchItemsObserver { public: - LLOpenAgentOffer(const std::string& from_name) : mFromName(from_name) {} + LLOpenAgentOffer(const uuid_vec_t& ids, + const std::string& from_name) : + LLInventoryFetchItemsObserver(ids), + mFromName(from_name) {} /*virtual*/ void done() { open_inventory_offer(mComplete, mFromName); @@ -1206,8 +1209,8 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& // so we can fetch it out of our inventory. uuid_vec_t items; items.push_back(mObjectID); - LLOpenAgentOffer* open_agent_offer = new LLOpenAgentOffer(from_string); - open_agent_offer->fetch(items); + LLOpenAgentOffer* open_agent_offer = new LLOpenAgentOffer(items, from_string); + open_agent_offer->startFetch(); if(catp || (itemp && itemp->isComplete())) { open_agent_offer->done(); @@ -1270,7 +1273,7 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& items.push_back(mObjectID); LLDiscardAgentOffer* discard_agent_offer; discard_agent_offer = new LLDiscardAgentOffer(mFolderID, mObjectID); - discard_agent_offer->fetch(folders, items); + discard_agent_offer->startFetch(folders, items); if(catp || (itemp && itemp->isComplete())) { discard_agent_offer->done(); @@ -1604,8 +1607,8 @@ void inventory_offer_handler(LLOfferInfo* info) // Prefetch the item into your local inventory. uuid_vec_t items; items.push_back(info->mObjectID); - LLInventoryFetchObserver* fetch_item = new LLInventoryFetchObserver(); - fetch_item->fetch(items); + LLInventoryFetchItemsObserver* fetch_item = new LLInventoryFetchItemsObserver(items); + fetch_item->startFetch(); if(fetch_item->isEverythingComplete()) { fetch_item->done(); @@ -2123,8 +2126,8 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) // Prefetch the offered item so that it can be discarded by the appropriate observer. (EXT-4331) uuid_vec_t items; items.push_back(info->mObjectID); - LLInventoryFetchObserver* fetch_item = new LLInventoryFetchObserver(); - fetch_item->fetch(items); + LLInventoryFetchItemsObserver* fetch_item = new LLInventoryFetchItemsObserver(items); + fetch_item->startFetch(); delete fetch_item; // Same as closing window @@ -2844,7 +2847,9 @@ void process_teleport_progress(LLMessageSystem* msg, void**) class LLFetchInWelcomeArea : public LLInventoryFetchDescendentsObserver { public: - LLFetchInWelcomeArea() {} + LLFetchInWelcomeArea(const uuid_vec_t &ids) : + LLInventoryFetchDescendentsObserver(ids) + {} virtual void done() { LLIsType is_landmark(LLAssetType::AT_LANDMARK); @@ -2926,8 +2931,8 @@ BOOL LLPostTeleportNotifiers::tick() folders.push_back(folder_id); if(!folders.empty()) { - LLFetchInWelcomeArea* fetcher = new LLFetchInWelcomeArea; - fetcher->fetch(folders); + LLFetchInWelcomeArea* fetcher = new LLFetchInWelcomeArea(folders); + fetcher->startFetch(); if(fetcher->isEverythingComplete()) { fetcher->done(); -- cgit v1.2.3 From c3d9316dff568d5265d856a708e3909deae09f18 Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Tue, 6 Apr 2010 17:30:23 -0400 Subject: EXT-6727 : Allow LLInventoryObservers to target a single item (instead of a vector of items) Added new constructors to LLInventoryFetch types to allow passing in a single item. --- indra/newview/llagentwearables.cpp | 8 ++------ indra/newview/llagentwearablesfetch.cpp | 8 ++++---- indra/newview/llagentwearablesfetch.h | 4 ++-- indra/newview/llappearancemgr.cpp | 2 +- indra/newview/llappearancemgr.h | 8 +++----- indra/newview/llfriendcard.cpp | 8 +++----- indra/newview/llinventoryobserver.cpp | 22 ++++++++++++++++++---- indra/newview/llinventoryobserver.h | 11 +++++++---- indra/newview/llpaneloutfitedit.cpp | 6 ++---- indra/newview/llviewermenu.cpp | 9 +++------ indra/newview/llviewermessage.cpp | 16 +++++----------- 11 files changed, 50 insertions(+), 52 deletions(-) diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp index bc8931827e..aedea5660f 100644 --- a/indra/newview/llagentwearables.cpp +++ b/indra/newview/llagentwearables.cpp @@ -905,9 +905,7 @@ void LLAgentWearables::processAgentInitialWearablesUpdate(LLMessageSystem* mesgs // Get the UUID of the current outfit folder (will be created if it doesn't exist) const LLUUID current_outfit_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); - uuid_vec_t folders; - folders.push_back(current_outfit_id); - LLInitialWearablesFetch* outfit = new LLInitialWearablesFetch(folders); + LLInitialWearablesFetch* outfit = new LLInitialWearablesFetch(current_outfit_id); //lldebugs << "processAgentInitialWearablesUpdate()" << llendl; // Add wearables @@ -2061,9 +2059,7 @@ void LLAgentWearables::populateMyOutfitsFolder(void) llinfos << "starting outfit population" << llendl; const LLUUID& my_outfits_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); - uuid_vec_t folders; - folders.push_back(my_outfits_id); - LLLibraryOutfitsFetch* outfits = new LLLibraryOutfitsFetch(folders); + LLLibraryOutfitsFetch* outfits = new LLLibraryOutfitsFetch(my_outfits_id); outfits->mMyOutfitsID = my_outfits_id; // Get the complete information on the items in the inventory and diff --git a/indra/newview/llagentwearablesfetch.cpp b/indra/newview/llagentwearablesfetch.cpp index 6b7edaa302..04a970b683 100644 --- a/indra/newview/llagentwearablesfetch.cpp +++ b/indra/newview/llagentwearablesfetch.cpp @@ -39,8 +39,8 @@ #include "llinventoryfunctions.h" #include "llvoavatarself.h" -LLInitialWearablesFetch::LLInitialWearablesFetch(const uuid_vec_t& ids) : - LLInventoryFetchDescendentsObserver(ids) +LLInitialWearablesFetch::LLInitialWearablesFetch(const LLUUID& cof_id) : + LLInventoryFetchDescendentsObserver(cof_id) { } @@ -189,8 +189,8 @@ void LLInitialWearablesFetch::processWearablesMessage() } } -LLLibraryOutfitsFetch::LLLibraryOutfitsFetch(const uuid_vec_t& ids) : - LLInventoryFetchDescendentsObserver(ids), +LLLibraryOutfitsFetch::LLLibraryOutfitsFetch(const LLUUID& my_outfits_id) : + LLInventoryFetchDescendentsObserver(my_outfits_id), mCurrFetchStep(LOFS_FOLDER), mOutfitsPopulated(false) { diff --git a/indra/newview/llagentwearablesfetch.h b/indra/newview/llagentwearablesfetch.h index 33368811c0..6695727d46 100644 --- a/indra/newview/llagentwearablesfetch.h +++ b/indra/newview/llagentwearablesfetch.h @@ -47,7 +47,7 @@ class LLInitialWearablesFetch : public LLInventoryFetchDescendentsObserver { public: - LLInitialWearablesFetch(const uuid_vec_t& ids); + LLInitialWearablesFetch(const LLUUID& cof_id); ~LLInitialWearablesFetch(); virtual void done(); @@ -92,7 +92,7 @@ public: LOFS_CONTENTS }; - LLLibraryOutfitsFetch(const uuid_vec_t& ids); + LLLibraryOutfitsFetch(const LLUUID& my_outfits_id); ~LLLibraryOutfitsFetch(); virtual void done(); diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index e0f1d5348d..7700d4de7f 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -49,7 +49,7 @@ #include "llviewerregion.h" #include "llwearablelist.h" -LLUUID findDescendentCategoryIDByName(const LLUUID& parent_id,const std::string& name) +LLUUID findDescendentCategoryIDByName(const LLUUID& parent_id, const std::string& name) { LLInventoryModel::cat_array_t cat_array; LLInventoryModel::item_array_t item_array; diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index 1cf8d584db..27a4ffd8cb 100644 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -270,8 +270,8 @@ template class CallAfterCategoryFetchStage1: public LLInventoryFetchDescendentsObserver { public: - CallAfterCategoryFetchStage1(const uuid_vec_t& ids, T callable) : - LLInventoryFetchDescendentsObserver(ids), + CallAfterCategoryFetchStage1(const LLUUID& cat_id, T callable) : + LLInventoryFetchDescendentsObserver(cat_id), mCallable(callable) { } @@ -331,9 +331,7 @@ protected: template void callAfterCategoryFetch(const LLUUID& cat_id, T callable) { - uuid_vec_t folders; - folders.push_back(cat_id); - CallAfterCategoryFetchStage1 *stage1 = new CallAfterCategoryFetchStage1(folders, callable); + CallAfterCategoryFetchStage1 *stage1 = new CallAfterCategoryFetchStage1(cat_id, callable); stage1->startFetch(); if (stage1->isEverythingComplete()) { diff --git a/indra/newview/llfriendcard.cpp b/indra/newview/llfriendcard.cpp index aaa09ba5da..945d2d26da 100644 --- a/indra/newview/llfriendcard.cpp +++ b/indra/newview/llfriendcard.cpp @@ -111,9 +111,9 @@ class LLInitialFriendCardsFetch : public LLInventoryFetchDescendentsObserver public: typedef boost::function callback_t; - LLInitialFriendCardsFetch(const uuid_vec_t& ids, + LLInitialFriendCardsFetch(const LLUUID& folder_id, callback_t cb) : - LLInventoryFetchDescendentsObserver(ids), + LLInventoryFetchDescendentsObserver(folder_id), mCheckFolderCallback(cb) {} @@ -410,10 +410,8 @@ void LLFriendCardsManager::findMatchedFriendCards(const LLUUID& avatarID, LLInve void LLFriendCardsManager::fetchAndCheckFolderDescendents(const LLUUID& folder_id, callback_t cb) { - uuid_vec_t folders; - folders.push_back(folder_id); // This instance will be deleted in LLInitialFriendCardsFetch::done(). - LLInitialFriendCardsFetch* fetch = new LLInitialFriendCardsFetch(folders, cb); + LLInitialFriendCardsFetch* fetch = new LLInitialFriendCardsFetch(folder_id, cb); fetch->startFetch(); if(fetch->isEverythingComplete()) { diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp index 0f8d76a4cc..fecd18b4bb 100644 --- a/indra/newview/llinventoryobserver.cpp +++ b/indra/newview/llinventoryobserver.cpp @@ -113,9 +113,17 @@ LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(bool retry_if_missi { } -LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(const uuid_vec_t& ids, +LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(const LLUUID& item_id, bool retry_if_missing) : - mIDs(ids), + mRetryIfMissing(retry_if_missing) +{ + mIDs.clear(); + mIDs.push_back(item_id); +} + +LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(const uuid_vec_t& item_ids, + bool retry_if_missing) : + mIDs(item_ids), mRetryIfMissing(retry_if_missing) { } @@ -273,8 +281,14 @@ LLInventoryFetchDescendentsObserver::LLInventoryFetchDescendentsObserver() { } -LLInventoryFetchDescendentsObserver::LLInventoryFetchDescendentsObserver(const uuid_vec_t& ids) : - mIDs(ids) +LLInventoryFetchDescendentsObserver::LLInventoryFetchDescendentsObserver(const LLUUID& cat_id) +{ + mIDs.clear(); + mIDs.push_back(cat_id); +} + +LLInventoryFetchDescendentsObserver::LLInventoryFetchDescendentsObserver(const uuid_vec_t& cat_ids) : + mIDs(cat_ids) { } // virtual diff --git a/indra/newview/llinventoryobserver.h b/indra/newview/llinventoryobserver.h index 03f9e9c553..420afdfadc 100644 --- a/indra/newview/llinventoryobserver.h +++ b/indra/newview/llinventoryobserver.h @@ -81,8 +81,9 @@ public: class LLInventoryFetchItemsObserver : public LLInventoryObserver { public: - LLInventoryFetchItemsObserver(bool retry_if_missing = false); - LLInventoryFetchItemsObserver(const uuid_vec_t& ids, bool retry_if_missing = false); + LLInventoryFetchItemsObserver(bool retry_if_missing = false); // deprecated + LLInventoryFetchItemsObserver(const LLUUID& item_id, bool retry_if_missing = false); // single item + LLInventoryFetchItemsObserver(const uuid_vec_t& item_ids, bool retry_if_missing = false); // multiple items virtual void changed(U32 mask); bool isEverythingComplete() const; @@ -108,10 +109,12 @@ class LLInventoryFetchDescendentsObserver : public LLInventoryObserver { public: LLInventoryFetchDescendentsObserver(); - LLInventoryFetchDescendentsObserver(const uuid_vec_t& ids); + LLInventoryFetchDescendentsObserver(const LLUUID& cat_id); + LLInventoryFetchDescendentsObserver(const uuid_vec_t& cat_ids); virtual void changed(U32 mask); - void setFolders(const uuid_vec_t& ids) { mIDs = ids; } + void setFolders(const uuid_vec_t& cat_ids) { mIDs = cat_ids; } + void setFolders(const LLUUID& cat_id) { mIDs.clear(); mIDs.push_back(cat_id); } void startFetch(); bool isEverythingComplete() const; virtual void done() = 0; diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp index 5701fcb582..e93293a0f0 100644 --- a/indra/newview/llpaneloutfitedit.cpp +++ b/indra/newview/llpaneloutfitedit.cpp @@ -481,10 +481,8 @@ void LLPanelOutfitEdit::updateLookInfo() if (getVisible()) { mLookContents->clearRows(); - - uuid_vec_t folders; - folders.push_back(mLookID); - mFetchLook->setFolders(folders); + + mFetchLook->setFolders(mLookID); mFetchLook->startFetch(); if (mFetchLook->isEverythingComplete()) { diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 807595960e..820db7e3ff 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -6099,8 +6099,8 @@ class LLAttachmentDetach : public view_listener_t class LLWornItemFetchedObserver : public LLInventoryFetchItemsObserver { public: - LLWornItemFetchedObserver(const uuid_vec_t& ids) : - LLInventoryFetchItemsObserver(ids) + LLWornItemFetchedObserver(const LLUUID& worn_item_id) : + LLInventoryFetchItemsObserver(worn_item_id) {} virtual ~LLWornItemFetchedObserver() {} @@ -6155,10 +6155,7 @@ class LLAttachmentEnableDrop : public view_listener_t // when the item finishes fetching worst case scenario // if a fetch is already out there (being sent from a slow sim) // we refetch and there are 2 fetches - - uuid_vec_t items; //add item to the inventory item to be fetched - items.push_back((*attachment_iter)->getItemID()); - LLWornItemFetchedObserver* worn_item_fetched = new LLWornItemFetchedObserver(items); + LLWornItemFetchedObserver* worn_item_fetched = new LLWornItemFetchedObserver((*attachment_iter)->getItemID()); worn_item_fetched->startFetch(); gInventory.addObserver(worn_item_fetched); } diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 6f39de996e..35eb3390a5 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -703,9 +703,9 @@ static LLNotificationFunctorRegistration jgr_3("JoinGroupCanAfford", join_group_ class LLOpenAgentOffer : public LLInventoryFetchItemsObserver { public: - LLOpenAgentOffer(const uuid_vec_t& ids, + LLOpenAgentOffer(const LLUUID& object_id, const std::string& from_name) : - LLInventoryFetchItemsObserver(ids), + LLInventoryFetchItemsObserver(object_id), mFromName(from_name) {} /*virtual*/ void done() { @@ -1207,9 +1207,7 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& // This is an offer from an agent. In this case, the back // end has already copied the items into your inventory, // so we can fetch it out of our inventory. - uuid_vec_t items; - items.push_back(mObjectID); - LLOpenAgentOffer* open_agent_offer = new LLOpenAgentOffer(items, from_string); + LLOpenAgentOffer* open_agent_offer = new LLOpenAgentOffer(mObjectID, from_string); open_agent_offer->startFetch(); if(catp || (itemp && itemp->isComplete())) { @@ -1605,9 +1603,7 @@ void inventory_offer_handler(LLOfferInfo* info) p.name = "UserGiveItem"; // Prefetch the item into your local inventory. - uuid_vec_t items; - items.push_back(info->mObjectID); - LLInventoryFetchItemsObserver* fetch_item = new LLInventoryFetchItemsObserver(items); + LLInventoryFetchItemsObserver* fetch_item = new LLInventoryFetchItemsObserver(info->mObjectID); fetch_item->startFetch(); if(fetch_item->isEverythingComplete()) { @@ -2124,9 +2120,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) if (is_muted) { // Prefetch the offered item so that it can be discarded by the appropriate observer. (EXT-4331) - uuid_vec_t items; - items.push_back(info->mObjectID); - LLInventoryFetchItemsObserver* fetch_item = new LLInventoryFetchItemsObserver(items); + LLInventoryFetchItemsObserver* fetch_item = new LLInventoryFetchItemsObserver(info->mObjectID); fetch_item->startFetch(); delete fetch_item; -- cgit v1.2.3 From f096f02278f3b8c8fdd962c85b237492defa93ec Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Tue, 6 Apr 2010 18:58:26 -0400 Subject: EXT-6728 : Have LLInventoryFetchItems/DescendentsObserver inherit from a base abstract LLInventoryFetchObserver class Added a new abstract class LLInventoryFetchObserver from which LLInventoryFetchItems and LLInventoryFetchDescendents inherit. Also changed isEverythingComplete to isFinished and made some other minor superficial changes. --- indra/newview/llagentwearables.cpp | 4 +- indra/newview/llagentwearablesfetch.cpp | 18 +++---- indra/newview/llappearancemgr.h | 4 +- indra/newview/llfloatergesture.cpp | 4 +- indra/newview/llfloaterproperties.cpp | 6 +-- indra/newview/llfriendcard.cpp | 2 +- indra/newview/llgesturemgr.cpp | 4 +- indra/newview/llinventorybridge.cpp | 14 ++--- indra/newview/llinventoryobserver.cpp | 95 ++++++++++++++++++++------------- indra/newview/llinventoryobserver.h | 69 ++++++++++++++---------- indra/newview/llinventorypanel.cpp | 2 +- indra/newview/llpaneloutfitedit.cpp | 4 +- indra/newview/llpreview.cpp | 2 +- indra/newview/llpreviewgesture.cpp | 4 +- indra/newview/llpreviewscript.cpp | 2 +- indra/newview/llsidepanelappearance.cpp | 2 +- indra/newview/llsidepaneliteminfo.cpp | 6 +-- indra/newview/llstartup.cpp | 2 +- indra/newview/lltooldraganddrop.cpp | 35 ++++++------ indra/newview/llviewerinventory.h | 2 +- indra/newview/llviewermessage.cpp | 8 +-- 21 files changed, 162 insertions(+), 127 deletions(-) diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp index aedea5660f..7f248eee30 100644 --- a/indra/newview/llagentwearables.cpp +++ b/indra/newview/llagentwearables.cpp @@ -952,7 +952,7 @@ void LLAgentWearables::processAgentInitialWearablesUpdate(LLMessageSystem* mesgs // Get the complete information on the items in the inventory and set up an observer // that will trigger when the complete information is fetched. outfit->startFetch(); - if(outfit->isEverythingComplete()) + if(outfit->isFinished()) { // everything is already here - call done. outfit->done(); @@ -2066,7 +2066,7 @@ void LLAgentWearables::populateMyOutfitsFolder(void) // setup an observer that will wait for that to happen. gInventory.addObserver(outfits); outfits->startFetch(); - if (outfits->isEverythingComplete()) + if (outfits->isFinished()) { outfits->done(); } diff --git a/indra/newview/llagentwearablesfetch.cpp b/indra/newview/llagentwearablesfetch.cpp index 04a970b683..aafbb0d22c 100644 --- a/indra/newview/llagentwearablesfetch.cpp +++ b/indra/newview/llagentwearablesfetch.cpp @@ -174,7 +174,7 @@ void LLInitialWearablesFetch::processWearablesMessage() fetcher->startFetch(); // If no items to be fetched, done will never be triggered. // TODO: Change LLInventoryFetchItemsObserver::fetchItems to trigger done() on this condition. - if (fetcher->isEverythingComplete()) + if (fetcher->isFinished()) { fetcher->done(); } @@ -287,9 +287,9 @@ void LLLibraryOutfitsFetch::folderDone() uuid_vec_t folders; folders.push_back(mClothingID); folders.push_back(mLibraryClothingID); - setFolders(folders); + setFetchIDs(folders); startFetch(); - if (isEverythingComplete()) + if (isFinished()) { done(); } @@ -337,9 +337,9 @@ void LLLibraryOutfitsFetch::outfitsDone() } mComplete.clear(); - setFolders(folders); + setFetchIDs(folders); startFetch(); - if (isEverythingComplete()) + if (isFinished()) { done(); } @@ -434,9 +434,9 @@ void LLLibraryOutfitsFetch::importedFolderFetch() folders.push_back(mImportedClothingID); mComplete.clear(); - setFolders(folders); + setFetchIDs(folders); startFetch(); - if (isEverythingComplete()) + if (isFinished()) { done(); } @@ -464,9 +464,9 @@ void LLLibraryOutfitsFetch::importedFolderDone() } mComplete.clear(); - setFolders(folders); + setFetchIDs(folders); startFetch(); - if (isEverythingComplete()) + if (isFinished()) { done(); } diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index 27a4ffd8cb..93b3cecb6f 100644 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -311,7 +311,7 @@ public: // do the fetch CallAfterCategoryFetchStage2 *stage2 = new CallAfterCategoryFetchStage2(ids, mCallable); stage2->startFetch(); - if(stage2->isEverythingComplete()) + if(stage2->isFinished()) { // everything is already here - call done. stage2->done(); @@ -333,7 +333,7 @@ void callAfterCategoryFetch(const LLUUID& cat_id, T callable) { CallAfterCategoryFetchStage1 *stage1 = new CallAfterCategoryFetchStage1(cat_id, callable); stage1->startFetch(); - if (stage1->isEverythingComplete()) + if (stage1->isFinished()) { stage1->done(); } diff --git a/indra/newview/llfloatergesture.cpp b/indra/newview/llfloatergesture.cpp index 04fb6bca3c..eff7131145 100644 --- a/indra/newview/llfloatergesture.cpp +++ b/indra/newview/llfloatergesture.cpp @@ -148,7 +148,7 @@ void LLFloaterGesture::done() if (!unloaded_folders.empty()) { LL_DEBUGS("Gesture")<< "Fetching subdirectories....." << LL_ENDL; - setFolders(unloaded_folders); + setFetchIDs(unloaded_folders); startFetch(); } else @@ -203,7 +203,7 @@ BOOL LLFloaterGesture::postBuild() folders.push_back(mGestureFolderID); //perform loading Gesture directory anyway to make sure that all subdirectory are loaded too. See method done() for details. gInventory.addObserver(this); - setFolders(folders); + setFetchIDs(folders); startFetch(); if (mGestureList) diff --git a/indra/newview/llfloaterproperties.cpp b/indra/newview/llfloaterproperties.cpp index bb9d151cd2..30b654de24 100644 --- a/indra/newview/llfloaterproperties.cpp +++ b/indra/newview/llfloaterproperties.cpp @@ -237,7 +237,7 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item) // do not enable the UI for incomplete items. LLViewerInventoryItem* i = (LLViewerInventoryItem*)item; - BOOL is_complete = i->isComplete(); + BOOL is_complete = i->isFinished(); const BOOL cannot_restrict_permissions = LLInventoryType::cannotRestrictPermissions(i->getInventoryType()); const BOOL is_calling_card = (i->getInventoryType() == LLInventoryType::IT_CALLINGCARD); const LLPermissions& perm = item->getPermissions(); @@ -683,7 +683,7 @@ void LLFloaterProperties::onCommitPermissions() CheckNextOwnerTransfer->get(), PERM_TRANSFER); } if(perm != item->getPermissions() - && item->isComplete()) + && item->isFinished()) { LLPointer new_item = new LLViewerInventoryItem(item); new_item->setPermissions(perm); @@ -813,7 +813,7 @@ void LLFloaterProperties::updateSaleInfo() sale_info.setSaleType(LLSaleInfo::FS_NOT); } if(sale_info != item->getSaleInfo() - && item->isComplete()) + && item->isFinished()) { LLPointer new_item = new LLViewerInventoryItem(item); diff --git a/indra/newview/llfriendcard.cpp b/indra/newview/llfriendcard.cpp index 945d2d26da..7f28e09933 100644 --- a/indra/newview/llfriendcard.cpp +++ b/indra/newview/llfriendcard.cpp @@ -413,7 +413,7 @@ void LLFriendCardsManager::fetchAndCheckFolderDescendents(const LLUUID& folder_i // This instance will be deleted in LLInitialFriendCardsFetch::done(). LLInitialFriendCardsFetch* fetch = new LLInitialFriendCardsFetch(folder_id, cb); fetch->startFetch(); - if(fetch->isEverythingComplete()) + if(fetch->isFinished()) { // everything is already here - call done. fetch->done(); diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp index 034806acfc..3d38ff3730 100644 --- a/indra/newview/llgesturemgr.cpp +++ b/indra/newview/llgesturemgr.cpp @@ -1031,9 +1031,7 @@ void LLGestureMgr::onLoadComplete(LLVFS *vfs, else { // Watch this item and set gesture name when item exists in inventory - uuid_vec_t ids; - ids.push_back(item_id); - self.setItems(ids); + self.setFetchID(item_id); self.startFetch(); } self.mActive[item_id] = gesture; diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 82043ab523..87b3c2e835 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -1133,7 +1133,7 @@ void LLItemBridge::performAction(LLInventoryModel* model, std::string action) void LLItemBridge::selectItem() { LLViewerInventoryItem* item = static_cast(getItem()); - if(item && !item->isComplete()) + if(item && !item->isFinished()) { item->fetchFromServer(); } @@ -2037,7 +2037,7 @@ void LLRightClickInventoryFetchDescendentsObserver::done() outfit->startFetch(); outfit->done(); //Not interested in waiting and this will be right 99% of the time. //Uncomment the following code for laggy Inventory UI. -/* if(outfit->isEverythingComplete()) +/* if(outfit->isFinished()) { // everything is already here - call done. outfit->done(); @@ -2734,7 +2734,7 @@ void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) LLRightClickInventoryFetchDescendentsObserver* fetch = new LLRightClickInventoryFetchDescendentsObserver(folders, FALSE); fetch->startFetch(); inc_busy_count(); - if(fetch->isEverythingComplete()) + if(fetch->isFinished()) { // everything is already here - call done. fetch->done(); @@ -3195,7 +3195,7 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item, else if(LLToolDragAndDrop::SOURCE_LIBRARY == source) { LLViewerInventoryItem* item = (LLViewerInventoryItem*)inv_item; - if(item && item->isComplete()) + if(item && item->isFinished()) { accept = TRUE; if(drop) @@ -4054,7 +4054,7 @@ void LLObjectBridge::performAction(LLInventoryModel* model, std::string action) { rez_attachment(item, NULL); } - else if(item && item->isComplete()) + else if(item && item->isFinished()) { // must be in library. copy it to our inventory and put it on. LLPointer cb = new RezAttachmentCallback(0); @@ -4687,7 +4687,7 @@ BOOL LLWearableBridge::canWearOnAvatar(void* user_data) if(!self->isAgentInventory()) { LLViewerInventoryItem* item = (LLViewerInventoryItem*)self->getItem(); - if(!item || !item->isComplete()) return FALSE; + if(!item || !item->isFinished()) return FALSE; } return (!get_is_item_worn(self->mUUID)); } @@ -5307,7 +5307,7 @@ public: // must be in the inventory library. copy it to our inventory // and put it on right away. LLViewerInventoryItem* item = getItem(); - if(item && item->isComplete()) + if(item && item->isFinished()) { LLPointer cb = new WearOnAvatarCallback(); copy_inventory_item( diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp index fecd18b4bb..ab32db9c8e 100644 --- a/indra/newview/llinventoryobserver.cpp +++ b/indra/newview/llinventoryobserver.cpp @@ -71,6 +71,36 @@ LLInventoryObserver::~LLInventoryObserver() { } +LLInventoryFetchObserver::LLInventoryFetchObserver(const LLUUID& id) +{ + mIDs.clear(); + if (id != LLUUID::null) + { + setFetchID(id); + } +} + +LLInventoryFetchObserver::LLInventoryFetchObserver(const uuid_vec_t& ids) +{ + setFetchIDs(ids); +} + +BOOL LLInventoryFetchObserver::isFinished() const +{ + return mIncomplete.empty(); +} + +void LLInventoryFetchObserver::setFetchIDs(const uuid_vec_t& ids) +{ + mIDs = ids; +} +void LLInventoryFetchObserver::setFetchID(const LLUUID& id) +{ + mIDs.clear(); + mIDs.push_back(id); +} + + void LLInventoryCompletionObserver::changed(U32 mask) { // scan through the incomplete items and move or erase them as @@ -79,13 +109,13 @@ void LLInventoryCompletionObserver::changed(U32 mask) { for(uuid_vec_t::iterator it = mIncomplete.begin(); it < mIncomplete.end(); ) { - LLViewerInventoryItem* item = gInventory.getItem(*it); + const LLViewerInventoryItem* item = gInventory.getItem(*it); if(!item) { it = mIncomplete.erase(it); continue; } - if(item->isComplete()) + if(item->isFinished()) { mComplete.push_back(*it); it = mIncomplete.erase(it); @@ -108,13 +138,16 @@ void LLInventoryCompletionObserver::watchItem(const LLUUID& id) } } -LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(bool retry_if_missing) : +/* +LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(BOOL retry_if_missing) : mRetryIfMissing(retry_if_missing) { } +*/ LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(const LLUUID& item_id, - bool retry_if_missing) : + BOOL retry_if_missing) : + LLInventoryFetchObserver(item_id), mRetryIfMissing(retry_if_missing) { mIDs.clear(); @@ -122,8 +155,8 @@ LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(const LLUUID& item_ } LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(const uuid_vec_t& item_ids, - bool retry_if_missing) : - mIDs(item_ids), + BOOL retry_if_missing) : + LLInventoryFetchObserver(item_ids), mRetryIfMissing(retry_if_missing) { } @@ -155,7 +188,7 @@ void LLInventoryFetchItemsObserver::changed(U32 mask) } continue; } - if(item->isComplete()) + if(item->isFinished()) { mComplete.push_back(*it); it = mIncomplete.erase(it); @@ -172,9 +205,8 @@ void LLInventoryFetchItemsObserver::changed(U32 mask) //llinfos << "LLInventoryFetchItemsObserver::changed() mIncomplete size " << mIncomplete.size() << llendl; } -bool LLInventoryFetchItemsObserver::isEverythingComplete() const +void LLInventoryFetchItemsObserver::done() { - return mIncomplete.empty(); } void fetch_items_from_llsd(const LLSD& items_llsd) @@ -247,7 +279,7 @@ void LLInventoryFetchItemsObserver::startFetch() LLViewerInventoryItem* item = gInventory.getItem(*it); if(item) { - if(item->isComplete()) + if(item->isFinished()) { // It's complete, so put it on the complete container. mComplete.push_back(*it); @@ -277,32 +309,28 @@ void LLInventoryFetchItemsObserver::startFetch() fetch_items_from_llsd(items_llsd); } -LLInventoryFetchDescendentsObserver::LLInventoryFetchDescendentsObserver() -{ -} - -LLInventoryFetchDescendentsObserver::LLInventoryFetchDescendentsObserver(const LLUUID& cat_id) +LLInventoryFetchDescendentsObserver::LLInventoryFetchDescendentsObserver(const LLUUID& cat_id) : + LLInventoryFetchObserver(cat_id) { - mIDs.clear(); - mIDs.push_back(cat_id); } LLInventoryFetchDescendentsObserver::LLInventoryFetchDescendentsObserver(const uuid_vec_t& cat_ids) : - mIDs(cat_ids) + LLInventoryFetchObserver(cat_ids) { } + // virtual void LLInventoryFetchDescendentsObserver::changed(U32 mask) { for(uuid_vec_t::iterator it = mIncomplete.begin(); it < mIncomplete.end();) { - LLViewerInventoryCategory* cat = gInventory.getCategory(*it); + const LLViewerInventoryCategory* cat = gInventory.getCategory(*it); if(!cat) { it = mIncomplete.erase(it); continue; } - if(isComplete(cat)) + if(isCategoryComplete(cat)) { mComplete.push_back(*it); it = mIncomplete.erase(it); @@ -322,7 +350,7 @@ void LLInventoryFetchDescendentsObserver::startFetch() { LLViewerInventoryCategory* cat = gInventory.getCategory(*it); if(!cat) continue; - if(!isComplete(cat)) + if(!isCategoryComplete(cat)) { cat->fetch(); //blindly fetch it without seeing if anything else is fetching it. mIncomplete.push_back(*it); //Add to list of things being downloaded for this observer. @@ -334,19 +362,14 @@ void LLInventoryFetchDescendentsObserver::startFetch() } } -bool LLInventoryFetchDescendentsObserver::isEverythingComplete() const -{ - return mIncomplete.empty(); -} - -bool LLInventoryFetchDescendentsObserver::isComplete(LLViewerInventoryCategory* cat) +BOOL LLInventoryFetchDescendentsObserver::isCategoryComplete(const LLViewerInventoryCategory* cat) const { const S32 version = cat->getVersion(); const S32 expected_num_descendents = cat->getDescendentCount(); if ((version == LLViewerInventoryCategory::VERSION_UNKNOWN) || (expected_num_descendents == LLViewerInventoryCategory::DESCENDENT_COUNT_UNKNOWN)) { - return false; + return FALSE; } // it might be complete - check known descendents against // currently available. @@ -360,14 +383,14 @@ bool LLInventoryFetchDescendentsObserver::isComplete(LLViewerInventoryCategory* // that the cat just doesn't have any items or subfolders). // Unrecoverable, so just return done so that this observer can be cleared // from memory. - return true; + return TRUE; } const S32 current_num_known_descendents = cats->count() + items->count(); // Got the number of descendents that we were expecting, so we're done. if (current_num_known_descendents == expected_num_descendents) { - return true; + return TRUE; } // Error condition, but recoverable. This happens if something was added to the @@ -376,10 +399,10 @@ bool LLInventoryFetchDescendentsObserver::isComplete(LLViewerInventoryCategory* if (current_num_known_descendents >= expected_num_descendents) { llwarns << "Category '" << cat->getName() << "' expected descendentcount:" << expected_num_descendents << " descendents but got descendentcount:" << current_num_known_descendents << llendl; - cat->setDescendentCount(current_num_known_descendents); - return true; + const_cast(cat)->setDescendentCount(current_num_known_descendents); + return TRUE; } - return false; + return FALSE; } void LLInventoryFetchComboObserver::changed(U32 mask) @@ -394,7 +417,7 @@ void LLInventoryFetchComboObserver::changed(U32 mask) it = mIncompleteItems.erase(it); continue; } - if(item->isComplete()) + if(item->isFinished()) { mCompleteItems.push_back(*it); it = mIncompleteItems.erase(it); @@ -424,7 +447,7 @@ void LLInventoryFetchComboObserver::changed(U32 mask) } if(!mDone && mIncompleteItems.empty() && mIncompleteFolders.empty()) { - mDone = true; + mDone = TRUE; done(); } } @@ -464,7 +487,7 @@ void LLInventoryFetchComboObserver::startFetch(const uuid_vec_t& folder_ids, lldebugs << "uanble to find item " << *iit << llendl; continue; } - if(item->isComplete()) + if(item->isFinished()) { // It's complete, so put it on the complete container. mCompleteItems.push_back(*iit); diff --git a/indra/newview/llinventoryobserver.h b/indra/newview/llinventoryobserver.h index 420afdfadc..7480b7e7af 100644 --- a/indra/newview/llinventoryobserver.h +++ b/indra/newview/llinventoryobserver.h @@ -73,57 +73,70 @@ public: }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Class LLInventoryFetchItemsObserver +// Class LLInventoryFetchObserver // -// Fetches inventory items, calls done() when all inventory has arrived. +// Abstract class to handle fetching items, folders, etc. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -class LLInventoryFetchItemsObserver : public LLInventoryObserver +class LLInventoryFetchObserver : public LLInventoryObserver { public: - LLInventoryFetchItemsObserver(bool retry_if_missing = false); // deprecated - LLInventoryFetchItemsObserver(const LLUUID& item_id, bool retry_if_missing = false); // single item - LLInventoryFetchItemsObserver(const uuid_vec_t& item_ids, bool retry_if_missing = false); // multiple items - virtual void changed(U32 mask); + LLInventoryFetchObserver(const LLUUID& id = LLUUID::null); // single item + LLInventoryFetchObserver(const uuid_vec_t& ids); // multiple items + void setFetchID(const LLUUID& id); + void setFetchIDs(const uuid_vec_t& ids); - bool isEverythingComplete() const; - void setItems(const uuid_vec_t& ids) { mIDs = ids; } - void startFetch(); + BOOL isFinished() const; - virtual void done() {}; + virtual void startFetch() = 0; + virtual void done() = 0; + virtual void changed(U32 mask) = 0; protected: - bool mRetryIfMissing; uuid_vec_t mComplete; uuid_vec_t mIncomplete; uuid_vec_t mIDs; }; + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Class LLInventoryFetchItemsObserver +// +// Fetches inventory items, calls done() when all inventory has arrived. +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class LLInventoryFetchItemsObserver : public LLInventoryFetchObserver +{ +public: + // LLInventoryFetchItemsObserver(BOOL retry_if_missing = FALSE); + LLInventoryFetchItemsObserver(const LLUUID& item_id = LLUUID::null, + BOOL retry_if_missing = FALSE); + LLInventoryFetchItemsObserver(const uuid_vec_t& item_ids, + BOOL retry_if_missing = FALSE); + + /*virtual*/ void startFetch(); + /*virtual*/ void changed(U32 mask); + /*virtual*/ void done(); + +protected: + BOOL mRetryIfMissing; +}; + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLInventoryFetchDescendentsObserver // // Fetches children of a category/folder, calls done() when all // inventory has arrived. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class LLInventoryFetchDescendentsObserver : public LLInventoryObserver +class LLInventoryFetchDescendentsObserver : public LLInventoryFetchObserver { public: - LLInventoryFetchDescendentsObserver(); - LLInventoryFetchDescendentsObserver(const LLUUID& cat_id); + // LLInventoryFetchDescendentsObserver(); + LLInventoryFetchDescendentsObserver(const LLUUID& cat_id = LLUUID::null); LLInventoryFetchDescendentsObserver(const uuid_vec_t& cat_ids); - virtual void changed(U32 mask); - - void setFolders(const uuid_vec_t& cat_ids) { mIDs = cat_ids; } - void setFolders(const LLUUID& cat_id) { mIDs.clear(); mIDs.push_back(cat_id); } - void startFetch(); - bool isEverythingComplete() const; - virtual void done() = 0; + /*virtual*/ void startFetch(); + /*virtual*/ void changed(U32 mask); protected: - bool isComplete(LLViewerInventoryCategory* cat); - uuid_vec_t mIncomplete; - uuid_vec_t mComplete; - uuid_vec_t mIDs; + BOOL isCategoryComplete(const LLViewerInventoryCategory* cat) const; }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -137,7 +150,7 @@ protected: class LLInventoryFetchComboObserver : public LLInventoryObserver { public: - LLInventoryFetchComboObserver() : mDone(false) {} + LLInventoryFetchComboObserver() : mDone(FALSE) {} virtual void changed(U32 mask); void startFetch(const uuid_vec_t& folder_ids, const uuid_vec_t& item_ids); diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index c6c2d23a4b..f3ad4b6890 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -901,7 +901,7 @@ bool LLInventoryPanel::attachObject(const LLSD& userdata) { rez_attachment(item, attachmentp); } - else if(item && item->isComplete()) + else if(item && item->isFinished()) { // must be in library. copy it to our inventory and put it on. LLPointer cb = new RezAttachmentCallback(attachmentp); diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp index e93293a0f0..270999e560 100644 --- a/indra/newview/llpaneloutfitedit.cpp +++ b/indra/newview/llpaneloutfitedit.cpp @@ -482,9 +482,9 @@ void LLPanelOutfitEdit::updateLookInfo() { mLookContents->clearRows(); - mFetchLook->setFolders(mLookID); + mFetchLook->setFetchID(mLookID); mFetchLook->startFetch(); - if (mFetchLook->isEverythingComplete()) + if (mFetchLook->isFinished()) { mFetchLook->done(); } diff --git a/indra/newview/llpreview.cpp b/indra/newview/llpreview.cpp index d0db77dcbe..dd31a62642 100644 --- a/indra/newview/llpreview.cpp +++ b/indra/newview/llpreview.cpp @@ -138,7 +138,7 @@ void LLPreview::onCommit() const LLViewerInventoryItem *item = dynamic_cast(getItem()); if(item) { - if (!item->isComplete()) + if (!item->isFinished()) { // We are attempting to save an item that was never loaded llwarns << "LLPreview::onCommit() called with mIsComplete == FALSE" diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp index fce90e4c44..2e061b235d 100644 --- a/indra/newview/llpreviewgesture.cpp +++ b/indra/newview/llpreviewgesture.cpp @@ -141,7 +141,7 @@ LLPreviewGesture* LLPreviewGesture::show(const LLUUID& item_id, const LLUUID& ob // this will call refresh when we have everything. LLViewerInventoryItem* item = (LLViewerInventoryItem*)preview->getItem(); - if (item && !item->isComplete()) + if (item && !item->isFinished()) { LLInventoryGestureAvailable* observer; observer = new LLInventoryGestureAvailable(); @@ -648,7 +648,7 @@ void LLPreviewGesture::refresh() LLPreview::refresh(); // If previewing or item is incomplete, all controls are disabled LLViewerInventoryItem* item = (LLViewerInventoryItem*)getItem(); - bool is_complete = (item && item->isComplete()) ? true : false; + bool is_complete = (item && item->isFinished()) ? true : false; if (mPreviewGesture || !is_complete) { diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 6b0e524f8c..7b926f468d 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -1823,7 +1823,7 @@ void LLLiveLSLEditor::saveIfNeeded() return; } - if(mItem.isNull() || !mItem->isComplete()) + if(mItem.isNull() || !mItem->isFinished()) { // $NOTE: While the error message may not be exactly correct, // it's pretty close. diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp index 6dd4dc1ce7..88043365db 100644 --- a/indra/newview/llsidepanelappearance.cpp +++ b/indra/newview/llsidepanelappearance.cpp @@ -396,7 +396,7 @@ void LLSidepanelAppearance::fetchInventory() fetch_worn->startFetch(); // If no items to be fetched, done will never be triggered. // TODO: Change LLInventoryFetchItemsObserver::fetchItems to trigger done() on this condition. - if (fetch_worn->isEverythingComplete()) + if (fetch_worn->isFinished()) { fetch_worn->done(); } diff --git a/indra/newview/llsidepaneliteminfo.cpp b/indra/newview/llsidepaneliteminfo.cpp index 9b073943b4..0ec351965a 100644 --- a/indra/newview/llsidepaneliteminfo.cpp +++ b/indra/newview/llsidepaneliteminfo.cpp @@ -236,7 +236,7 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item) if (!item) return; // do not enable the UI for incomplete items. - BOOL is_complete = item->isComplete(); + BOOL is_complete = item->isFinished(); const BOOL cannot_restrict_permissions = LLInventoryType::cannotRestrictPermissions(item->getInventoryType()); const BOOL is_calling_card = (item->getInventoryType() == LLInventoryType::IT_CALLINGCARD); const LLPermissions& perm = item->getPermissions(); @@ -743,7 +743,7 @@ void LLSidepanelItemInfo::onCommitPermissions() CheckNextOwnerTransfer->get(), PERM_TRANSFER); } if(perm != item->getPermissions() - && item->isComplete()) + && item->isFinished()) { LLPointer new_item = new LLViewerInventoryItem(item); new_item->setPermissions(perm); @@ -873,7 +873,7 @@ void LLSidepanelItemInfo::updateSaleInfo() sale_info.setSaleType(LLSaleInfo::FS_NOT); } if(sale_info != item->getSaleInfo() - && item->isComplete()) + && item->isFinished()) { LLPointer new_item = new LLViewerInventoryItem(item); diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 340327a1e2..83a97c1ab1 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -1771,7 +1771,7 @@ bool idle_startup() } } // no need to add gesture to inventory observer, it's already made in constructor - LLGestureMgr::instance().setItems(item_ids); + LLGestureMgr::instance().setFetchIDs(item_ids); LLGestureMgr::instance().startFetch(); } } diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index cc90b0753f..8f2e82914a 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -287,7 +287,7 @@ void LLCategoryDropObserver::done() } delete this; } - +/* Doesn't seem to be used anymore. class LLCategoryDropDescendentsObserver : public LLInventoryFetchDescendentsObserver { public: @@ -335,7 +335,7 @@ void LLCategoryDropDescendentsObserver::done() LLCategoryDropObserver* dropper; dropper = new LLCategoryDropObserver(ids, mObjectID, mSource); dropper->startFetch(); - if (dropper->isEverythingComplete()) + if (dropper->isDone()) { dropper->done(); } @@ -346,6 +346,7 @@ void LLCategoryDropDescendentsObserver::done() } delete this; } +*/ LLToolDragAndDrop::DragAndDropEntry::DragAndDropEntry(dragOrDrop3dImpl f_none, dragOrDrop3dImpl f_self, @@ -1205,7 +1206,7 @@ void LLToolDragAndDrop::dropObject(LLViewerObject* raycast_target, LLViewerInventoryItem* item; LLViewerInventoryCategory* cat; locateInventory(item, cat); - if (!item || !item->isComplete()) return; + if (!item || !item->isFinished()) return; //if (regionp // && (regionp->getRegionFlags() & REGION_FLAGS_SANDBOX)) @@ -1836,7 +1837,7 @@ EAcceptance LLToolDragAndDrop::willObjectAcceptInventory(LLViewerObject* obj, LL if (!item || !obj) return ACCEPT_NO; // HACK: downcast LLViewerInventoryItem* vitem = (LLViewerInventoryItem*)item; - if (!vitem->isComplete()) return ACCEPT_NO; + if (!vitem->isFinished()) return ACCEPT_NO; if (vitem->getIsLinkType()) return ACCEPT_NO; // No giving away links // deny attempts to drop from an object onto itself. This is to @@ -1996,7 +1997,7 @@ EAcceptance LLToolDragAndDrop::dad3dRezAttachmentFromInv( LLViewerInventoryItem* item; LLViewerInventoryCategory* cat; locateInventory(item, cat); - if (!item || !item->isComplete()) return ACCEPT_NO; + if (!item || !item->isFinished()) return ACCEPT_NO; // must not be in the trash const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH); @@ -2045,7 +2046,7 @@ EAcceptance LLToolDragAndDrop::dad3dRezObjectOnLand( LLViewerInventoryItem* item; LLViewerInventoryCategory* cat; locateInventory(item, cat); - if (!item || !item->isComplete()) return ACCEPT_NO; + if (!item || !item->isFinished()) return ACCEPT_NO; if (!isAgentAvatarValid() || gAgentAvatarp->isWearingAttachment(item->getUUID())) { @@ -2107,7 +2108,7 @@ EAcceptance LLToolDragAndDrop::dad3dRezObjectOnObject( LLViewerInventoryItem* item; LLViewerInventoryCategory* cat; locateInventory(item, cat); - if (!item || !item->isComplete()) return ACCEPT_NO; + if (!item || !item->isFinished()) return ACCEPT_NO; if (!isAgentAvatarValid() || gAgentAvatarp->isWearingAttachment(item->getUUID())) { return ACCEPT_NO; @@ -2186,7 +2187,7 @@ EAcceptance LLToolDragAndDrop::dad3dRezScript( LLViewerInventoryItem* item; LLViewerInventoryCategory* cat; locateInventory(item, cat); - if (!item || !item->isComplete()) return ACCEPT_NO; + if (!item || !item->isFinished()) return ACCEPT_NO; EAcceptance rv = willObjectAcceptInventory(obj, item); if (drop && (ACCEPT_YES_SINGLE <= rv)) { @@ -2224,7 +2225,7 @@ EAcceptance LLToolDragAndDrop::dad3dTextureObject( LLViewerInventoryItem* item; LLViewerInventoryCategory* cat; locateInventory(item, cat); - if (!item || !item->isComplete()) return ACCEPT_NO; + if (!item || !item->isFinished()) return ACCEPT_NO; EAcceptance rv = willObjectAcceptInventory(obj, item); if ((mask & MASK_CONTROL)) { @@ -2289,7 +2290,7 @@ EAcceptance LLToolDragAndDrop::dad3dWearItem( LLViewerInventoryItem* item; LLViewerInventoryCategory* cat; locateInventory(item, cat); - if (!item || !item->isComplete()) return ACCEPT_NO; + if (!item || !item->isFinished()) return ACCEPT_NO; if (mSource == SOURCE_AGENT || mSource == SOURCE_LIBRARY) { @@ -2344,7 +2345,7 @@ EAcceptance LLToolDragAndDrop::dad3dActivateGesture( LLViewerInventoryItem* item; LLViewerInventoryCategory* cat; locateInventory(item, cat); - if (!item || !item->isComplete()) return ACCEPT_NO; + if (!item || !item->isFinished()) return ACCEPT_NO; if (mSource == SOURCE_AGENT || mSource == SOURCE_LIBRARY) { @@ -2452,7 +2453,7 @@ EAcceptance LLToolDragAndDrop::dad3dUpdateInventory( LLViewerInventoryItem* item; LLViewerInventoryCategory* cat; locateInventory(item, cat); - if (!item || !item->isComplete()) return ACCEPT_NO; + if (!item || !item->isFinished()) return ACCEPT_NO; LLViewerObject* root_object = obj; if (obj && obj->getParent()) { @@ -2580,7 +2581,7 @@ EAcceptance LLToolDragAndDrop::dad3dUpdateInventoryCategory( } LLCategoryDropObserver* dropper = new LLCategoryDropObserver(ids, obj->getID(), mSource); dropper->startFetch(); - if (dropper->isEverythingComplete()) + if (dropper->isFinished()) { dropper->done(); } @@ -2611,7 +2612,7 @@ EAcceptance LLToolDragAndDrop::dad3dGiveInventoryObject( LLViewerInventoryItem* item; LLViewerInventoryCategory* cat; locateInventory(item, cat); - if (!item || !item->isComplete()) return ACCEPT_NO; + if (!item || !item->isFinished()) return ACCEPT_NO; if (!item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID())) { // cannot give away no-transfer objects @@ -2645,7 +2646,7 @@ EAcceptance LLToolDragAndDrop::dad3dGiveInventory( LLViewerInventoryItem* item; LLViewerInventoryCategory* cat; locateInventory(item, cat); - if (!item || !item->isComplete()) return ACCEPT_NO; + if (!item || !item->isFinished()) return ACCEPT_NO; if (!isInventoryGiveAcceptable(item)) { return ACCEPT_NO; @@ -2684,7 +2685,7 @@ EAcceptance LLToolDragAndDrop::dad3dRezFromObjectOnLand( LLViewerInventoryItem* item = NULL; LLViewerInventoryCategory* cat = NULL; locateInventory(item, cat); - if (!item || !item->isComplete()) return ACCEPT_NO; + if (!item || !item->isFinished()) return ACCEPT_NO; if (!gAgent.allowOperation(PERM_COPY, item->getPermissions()) || !item->getPermissions().allowTransferTo(LLUUID::null)) @@ -2705,7 +2706,7 @@ EAcceptance LLToolDragAndDrop::dad3dRezFromObjectOnObject( LLViewerInventoryItem* item; LLViewerInventoryCategory* cat; locateInventory(item, cat); - if (!item || !item->isComplete()) return ACCEPT_NO; + if (!item || !item->isFinished()) return ACCEPT_NO; if ((mask & MASK_CONTROL)) { // *HACK: In order to resolve SL-22177, we need to block drags diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h index 2db88c2ff8..9d449399e8 100644 --- a/indra/newview/llviewerinventory.h +++ b/indra/newview/llviewerinventory.h @@ -138,7 +138,7 @@ public: bool importFileLocal(LLFILE* fp); // new methods - BOOL isComplete() const { return mIsComplete; } + BOOL isFinished() const { return mIsComplete; } void setComplete(BOOL complete) { mIsComplete = complete; } //void updateAssetOnServer() const; diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 35eb3390a5..e800611914 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -1209,7 +1209,7 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& // so we can fetch it out of our inventory. LLOpenAgentOffer* open_agent_offer = new LLOpenAgentOffer(mObjectID, from_string); open_agent_offer->startFetch(); - if(catp || (itemp && itemp->isComplete())) + if(catp || (itemp && itemp->isFinished())) { open_agent_offer->done(); } @@ -1272,7 +1272,7 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& LLDiscardAgentOffer* discard_agent_offer; discard_agent_offer = new LLDiscardAgentOffer(mFolderID, mObjectID); discard_agent_offer->startFetch(folders, items); - if(catp || (itemp && itemp->isComplete())) + if(catp || (itemp && itemp->isFinished())) { discard_agent_offer->done(); } @@ -1605,7 +1605,7 @@ void inventory_offer_handler(LLOfferInfo* info) // Prefetch the item into your local inventory. LLInventoryFetchItemsObserver* fetch_item = new LLInventoryFetchItemsObserver(info->mObjectID); fetch_item->startFetch(); - if(fetch_item->isEverythingComplete()) + if(fetch_item->isFinished()) { fetch_item->done(); } @@ -2927,7 +2927,7 @@ BOOL LLPostTeleportNotifiers::tick() { LLFetchInWelcomeArea* fetcher = new LLFetchInWelcomeArea(folders); fetcher->startFetch(); - if(fetcher->isEverythingComplete()) + if(fetcher->isFinished()) { fetcher->done(); } -- cgit v1.2.3 From e9f06764412af37023f45c4d83b2b97c48d2a13e Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Wed, 7 Apr 2010 11:15:27 -0400 Subject: EXT-6728 : Have LLInventoryFetchItems/DescendentsObserver inherit from a base abstract LLInventoryFetchObserver class Minor cleanup of LLInventoryFetchComboObserver --- indra/newview/llinventoryobserver.cpp | 123 ++++++++++++++++++---------------- indra/newview/llinventoryobserver.h | 59 +++++++--------- indra/newview/lltooldraganddrop.cpp | 12 ++-- indra/newview/llviewermessage.cpp | 13 ++-- 4 files changed, 100 insertions(+), 107 deletions(-) diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp index ab32db9c8e..35bd06125f 100644 --- a/indra/newview/llinventoryobserver.cpp +++ b/indra/newview/llinventoryobserver.cpp @@ -105,17 +105,17 @@ void LLInventoryCompletionObserver::changed(U32 mask) { // scan through the incomplete items and move or erase them as // appropriate. - if(!mIncomplete.empty()) + if (!mIncomplete.empty()) { - for(uuid_vec_t::iterator it = mIncomplete.begin(); it < mIncomplete.end(); ) + for (uuid_vec_t::iterator it = mIncomplete.begin(); it < mIncomplete.end(); ) { const LLViewerInventoryItem* item = gInventory.getItem(*it); - if(!item) + if (!item) { it = mIncomplete.erase(it); continue; } - if(item->isFinished()) + if (item->isFinished()) { mComplete.push_back(*it); it = mIncomplete.erase(it); @@ -123,7 +123,7 @@ void LLInventoryCompletionObserver::changed(U32 mask) } ++it; } - if(mIncomplete.empty()) + if (mIncomplete.empty()) { done(); } @@ -132,7 +132,7 @@ void LLInventoryCompletionObserver::changed(U32 mask) void LLInventoryCompletionObserver::watchItem(const LLUUID& id) { - if(id.notNull()) + if (id.notNull()) { mIncomplete.push_back(id); } @@ -165,12 +165,12 @@ void LLInventoryFetchItemsObserver::changed(U32 mask) { // scan through the incomplete items and move or erase them as // appropriate. - if(!mIncomplete.empty()) + if (!mIncomplete.empty()) { - for(uuid_vec_t::iterator it = mIncomplete.begin(); it < mIncomplete.end(); ) + for (uuid_vec_t::iterator it = mIncomplete.begin(); it < mIncomplete.end(); ) { LLViewerInventoryItem* item = gInventory.getItem(*it); - if(!item) + if (!item) { if (mRetryIfMissing) { @@ -188,7 +188,7 @@ void LLInventoryFetchItemsObserver::changed(U32 mask) } continue; } - if(item->isFinished()) + if (item->isFinished()) { mComplete.push_back(*it); it = mIncomplete.erase(it); @@ -196,7 +196,7 @@ void LLInventoryFetchItemsObserver::changed(U32 mask) } ++it; } - if(mIncomplete.empty()) + if (mIncomplete.empty()) { done(); } @@ -246,7 +246,7 @@ void fetch_items_from_llsd(const LLSD& items_llsd) for (S32 j=0; jnewMessageFast(_PREHASH_FetchInventory); @@ -257,13 +257,13 @@ void fetch_items_from_llsd(const LLSD& items_llsd) msg->nextBlockFast(_PREHASH_InventoryData); msg->addUUIDFast(_PREHASH_OwnerID, item_entry["owner_id"].asUUID()); msg->addUUIDFast(_PREHASH_ItemID, item_entry["item_id"].asUUID()); - if(msg->isSendFull(NULL)) + if (msg->isSendFull(NULL)) { start_new_message = TRUE; gAgent.sendReliableMessage(); } } - if(!start_new_message) + if (!start_new_message) { gAgent.sendReliableMessage(); } @@ -274,12 +274,12 @@ void LLInventoryFetchItemsObserver::startFetch() { LLUUID owner_id; LLSD items_llsd; - for(uuid_vec_t::const_iterator it = mIDs.begin(); it < mIDs.end(); ++it) + for (uuid_vec_t::const_iterator it = mIDs.begin(); it < mIDs.end(); ++it) { LLViewerInventoryItem* item = gInventory.getItem(*it); - if(item) + if (item) { - if(item->isFinished()) + if (item->isFinished()) { // It's complete, so put it on the complete container. mComplete.push_back(*it); @@ -322,15 +322,15 @@ LLInventoryFetchDescendentsObserver::LLInventoryFetchDescendentsObserver(const u // virtual void LLInventoryFetchDescendentsObserver::changed(U32 mask) { - for(uuid_vec_t::iterator it = mIncomplete.begin(); it < mIncomplete.end();) + for (uuid_vec_t::iterator it = mIncomplete.begin(); it < mIncomplete.end();) { const LLViewerInventoryCategory* cat = gInventory.getCategory(*it); - if(!cat) + if (!cat) { it = mIncomplete.erase(it); continue; } - if(isCategoryComplete(cat)) + if (isCategoryComplete(cat)) { mComplete.push_back(*it); it = mIncomplete.erase(it); @@ -338,7 +338,7 @@ void LLInventoryFetchDescendentsObserver::changed(U32 mask) } ++it; } - if(mIncomplete.empty()) + if (mIncomplete.empty()) { done(); } @@ -346,11 +346,11 @@ void LLInventoryFetchDescendentsObserver::changed(U32 mask) void LLInventoryFetchDescendentsObserver::startFetch() { - for(uuid_vec_t::const_iterator it = mIDs.begin(); it != mIDs.end(); ++it) + for (uuid_vec_t::const_iterator it = mIDs.begin(); it != mIDs.end(); ++it) { LLViewerInventoryCategory* cat = gInventory.getCategory(*it); - if(!cat) continue; - if(!isCategoryComplete(cat)) + if (!cat) continue; + if (!isCategoryComplete(cat)) { cat->fetch(); //blindly fetch it without seeing if anything else is fetching it. mIncomplete.push_back(*it); //Add to list of things being downloaded for this observer. @@ -376,7 +376,7 @@ BOOL LLInventoryFetchDescendentsObserver::isCategoryComplete(const LLViewerInven LLInventoryModel::cat_array_t* cats; LLInventoryModel::item_array_t* items; gInventory.getDirectDescendentsOf(cat->getUUID(), cats, items); - if(!cats || !items) + if (!cats || !items) { llwarns << "Category '" << cat->getName() << "' descendents corrupted, fetch failed." << llendl; // NULL means the call failed -- cats/items map doesn't exist (note: this does NOT mean @@ -405,19 +405,27 @@ BOOL LLInventoryFetchDescendentsObserver::isCategoryComplete(const LLViewerInven return FALSE; } +LLInventoryFetchComboObserver::LLInventoryFetchComboObserver(const uuid_vec_t& folder_ids, + const uuid_vec_t& item_ids) : + mFolderIDs(folder_ids), + mItemIDs(item_ids), + mDone(FALSE) +{ +} + void LLInventoryFetchComboObserver::changed(U32 mask) { - if(!mIncompleteItems.empty()) + if (!mIncompleteItems.empty()) { - for(uuid_vec_t::iterator it = mIncompleteItems.begin(); it < mIncompleteItems.end(); ) + for (uuid_vec_t::iterator it = mIncompleteItems.begin(); it < mIncompleteItems.end(); ) { LLViewerInventoryItem* item = gInventory.getItem(*it); - if(!item) + if (!item) { it = mIncompleteItems.erase(it); continue; } - if(item->isFinished()) + if (item->isFinished()) { mCompleteItems.push_back(*it); it = mIncompleteItems.erase(it); @@ -426,17 +434,17 @@ void LLInventoryFetchComboObserver::changed(U32 mask) ++it; } } - if(!mIncompleteFolders.empty()) + if (!mIncompleteFolders.empty()) { - for(uuid_vec_t::iterator it = mIncompleteFolders.begin(); it < mIncompleteFolders.end();) + for (uuid_vec_t::iterator it = mIncompleteFolders.begin(); it < mIncompleteFolders.end();) { LLViewerInventoryCategory* cat = gInventory.getCategory(*it); - if(!cat) + if (!cat) { it = mIncompleteFolders.erase(it); continue; } - if(gInventory.isCategoryComplete(*it)) + if (gInventory.isCategoryComplete(*it)) { mCompleteFolders.push_back(*it); it = mIncompleteFolders.erase(it); @@ -445,22 +453,21 @@ void LLInventoryFetchComboObserver::changed(U32 mask) ++it; } } - if(!mDone && mIncompleteItems.empty() && mIncompleteFolders.empty()) + if (!mDone && mIncompleteItems.empty() && mIncompleteFolders.empty()) { mDone = TRUE; done(); } } -void LLInventoryFetchComboObserver::startFetch(const uuid_vec_t& folder_ids, - const uuid_vec_t& item_ids) +void LLInventoryFetchComboObserver::startFetch() { lldebugs << "LLInventoryFetchComboObserver::startFetch()" << llendl; - for(uuid_vec_t::const_iterator fit = folder_ids.begin(); fit != folder_ids.end(); ++fit) + for (uuid_vec_t::const_iterator fit = mFolderIDs.begin(); fit != mFolderIDs.end(); ++fit) { LLViewerInventoryCategory* cat = gInventory.getCategory(*fit); - if(!cat) continue; - if(!gInventory.isCategoryComplete(*fit)) + if (!cat) continue; + if (!gInventory.isCategoryComplete(*fit)) { cat->fetch(); lldebugs << "fetching folder " << *fit <isFinished()) + if (item->isFinished()) { // It's complete, so put it on the complete container. mCompleteItems.push_back(*iit); @@ -499,7 +506,7 @@ void LLInventoryFetchComboObserver::startFetch(const uuid_vec_t& folder_ids, mIncompleteItems.push_back(*iit); owner_id = item->getPermissions().getOwner(); } - if(std::find(mIncompleteFolders.begin(), mIncompleteFolders.end(), item->getParentUUID()) == mIncompleteFolders.end()) + if (std::find(mIncompleteFolders.begin(), mIncompleteFolders.end(), item->getParentUUID()) == mIncompleteFolders.end()) { LLSD item_entry; item_entry["owner_id"] = owner_id; @@ -516,7 +523,7 @@ void LLInventoryFetchComboObserver::startFetch(const uuid_vec_t& folder_ids, void LLInventoryExistenceObserver::watchItem(const LLUUID& id) { - if(id.notNull()) + if (id.notNull()) { mMIA.push_back(id); } @@ -526,12 +533,12 @@ void LLInventoryExistenceObserver::changed(U32 mask) { // scan through the incomplete items and move or erase them as // appropriate. - if(!mMIA.empty()) + if (!mMIA.empty()) { - for(uuid_vec_t::iterator it = mMIA.begin(); it < mMIA.end(); ) + for (uuid_vec_t::iterator it = mMIA.begin(); it < mMIA.end(); ) { LLViewerInventoryItem* item = gInventory.getItem(*it); - if(!item) + if (!item) { ++it; continue; @@ -539,7 +546,7 @@ void LLInventoryExistenceObserver::changed(U32 mask) mExist.push_back(*it); it = mMIA.erase(it); } - if(mMIA.empty()) + if (mMIA.empty()) { done(); } @@ -548,7 +555,7 @@ void LLInventoryExistenceObserver::changed(U32 mask) void LLInventoryAddedObserver::changed(U32 mask) { - if(!(mask & LLInventoryObserver::ADD)) + if (!(mask & LLInventoryObserver::ADD)) { return; } @@ -580,7 +587,7 @@ void LLInventoryAddedObserver::changed(U32 mask) LLPointer titem = new LLViewerInventoryItem; S32 num_blocks = msg->getNumberOfBlocksFast(_PREHASH_InventoryData); - for(S32 i = 0; i < num_blocks; ++i) + for (S32 i = 0; i < num_blocks; ++i) { titem->unpackMessage(msg, _PREHASH_InventoryData, i); if (!(titem->getUUID().isNull())) @@ -602,18 +609,18 @@ LLInventoryTransactionObserver::LLInventoryTransactionObserver(const LLTransacti void LLInventoryTransactionObserver::changed(U32 mask) { - if(mask & LLInventoryObserver::ADD) + if (mask & LLInventoryObserver::ADD) { // This could be it - see if we are processing a bulk update LLMessageSystem* msg = gMessageSystem; - if(msg->getMessageName() + if (msg->getMessageName() && (0 == strcmp(msg->getMessageName(), "BulkUpdateInventory"))) { // we have a match for the message - now check the // transaction id. LLUUID id; msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_TransactionID, id); - if(id == mTransactionID) + if (id == mTransactionID) { // woo hoo, we found it uuid_vec_t folders; @@ -621,19 +628,19 @@ void LLInventoryTransactionObserver::changed(U32 mask) S32 count; count = msg->getNumberOfBlocksFast(_PREHASH_FolderData); S32 i; - for(i = 0; i < count; ++i) + for (i = 0; i < count; ++i) { msg->getUUIDFast(_PREHASH_FolderData, _PREHASH_FolderID, id, i); - if(id.notNull()) + if (id.notNull()) { folders.push_back(id); } } count = msg->getNumberOfBlocksFast(_PREHASH_ItemData); - for(i = 0; i < count; ++i) + for (i = 0; i < count; ++i) { msg->getUUIDFast(_PREHASH_ItemData, _PREHASH_ItemID, id, i); - if(id.notNull()) + if (id.notNull()) { items.push_back(id); } diff --git a/indra/newview/llinventoryobserver.h b/indra/newview/llinventoryobserver.h index 7480b7e7af..e4ae9097bd 100644 --- a/indra/newview/llinventoryobserver.h +++ b/indra/newview/llinventoryobserver.h @@ -97,7 +97,6 @@ protected: uuid_vec_t mIDs; }; - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLInventoryFetchItemsObserver // @@ -106,7 +105,6 @@ protected: class LLInventoryFetchItemsObserver : public LLInventoryFetchObserver { public: - // LLInventoryFetchItemsObserver(BOOL retry_if_missing = FALSE); LLInventoryFetchItemsObserver(const LLUUID& item_id = LLUUID::null, BOOL retry_if_missing = FALSE); LLInventoryFetchItemsObserver(const uuid_vec_t& item_ids, @@ -129,7 +127,6 @@ protected: class LLInventoryFetchDescendentsObserver : public LLInventoryFetchObserver { public: - // LLInventoryFetchDescendentsObserver(); LLInventoryFetchDescendentsObserver(const LLUUID& cat_id = LLUUID::null); LLInventoryFetchDescendentsObserver(const uuid_vec_t& cat_ids); @@ -142,46 +139,44 @@ protected: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLInventoryFetchComboObserver // -// This class does an appropriate combination of fetch descendents and -// item fetches based on completion of categories and items. Much like -// the fetch and fetch descendents, this will call done() when everything -// has arrived. +// Does an appropriate combination of fetch descendents and +// item fetches based on completion of categories and items. Much like +// the fetch and fetch descendents, this will call done() when everything +// has arrived. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class LLInventoryFetchComboObserver : public LLInventoryObserver { public: - LLInventoryFetchComboObserver() : mDone(FALSE) {} - virtual void changed(U32 mask); - - void startFetch(const uuid_vec_t& folder_ids, const uuid_vec_t& item_ids); + LLInventoryFetchComboObserver(const uuid_vec_t& folder_ids, + const uuid_vec_t& item_ids); + /*virtual*/ void changed(U32 mask); + void startFetch(); virtual void done() = 0; - protected: - bool mDone; + BOOL mDone; uuid_vec_t mCompleteFolders; uuid_vec_t mIncompleteFolders; uuid_vec_t mCompleteItems; uuid_vec_t mIncompleteItems; + + uuid_vec_t mItemIDs; + uuid_vec_t mFolderIDs; }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLInventoryExistenceObserver // -// This class is used as a base class for doing somethign when all the -// observed item ids exist in the inventory somewhere. You can derive -// a class from this class and implement the done() method to do -// something useful. +// Used as a base class for doing something when all the +// observed item ids exist in the inventory somewhere. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - class LLInventoryExistenceObserver : public LLInventoryObserver { public: LLInventoryExistenceObserver() {} - virtual void changed(U32 mask); + /*virtual*/ void changed(U32 mask); void watchItem(const LLUUID& id); - protected: virtual void done() = 0; uuid_vec_t mExist; @@ -191,18 +186,14 @@ protected: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLInventoryAddedObserver // -// This class is used as a base class for doing something when -// a new item arrives in inventory. -// It does not watch for a certain UUID, rather it acts when anything is added -// Derive a class from this class and implement the done() method to do -// something useful. +// Base class for doing something when a new item arrives in inventory. +// It does not watch for a certain UUID, rather it acts when anything is added //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - class LLInventoryAddedObserver : public LLInventoryObserver { public: LLInventoryAddedObserver() : mAdded() {} - virtual void changed(U32 mask); + /*virtual*/ void changed(U32 mask); protected: virtual void done() = 0; @@ -213,18 +204,15 @@ protected: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLInventoryTransactionObserver // -// Class which can be used as a base class for doing something when an -// inventory transaction completes. -// -// *NOTE: This class is not quite complete. Avoid using unless you fix up it's -// functionality gaps. +// Base class for doing something when an inventory transaction completes. +// NOTE: This class is not quite complete. Avoid using unless you fix up its +// functionality gaps. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - class LLInventoryTransactionObserver : public LLInventoryObserver { public: LLInventoryTransactionObserver(const LLTransactionID& transaction_id); - virtual void changed(U32 mask); + /*virtual*/ void changed(U32 mask); protected: virtual void done(const uuid_vec_t& folders, const uuid_vec_t& items) = 0; @@ -240,12 +228,11 @@ protected: // and declares a new method named done() which is called when all watched items // have complete information in the inventory model. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - class LLInventoryCompletionObserver : public LLInventoryObserver { public: LLInventoryCompletionObserver() {} - virtual void changed(U32 mask); + /*virtual*/ void changed(U32 mask); void watchItem(const LLUUID& id); diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 8f2e82914a..a67067d29c 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -235,7 +235,10 @@ bool LLGiveable::operator()(LLInventoryCategory* cat, LLInventoryItem* item) class LLCategoryFireAndForget : public LLInventoryFetchComboObserver { public: - LLCategoryFireAndForget() {} + LLCategoryFireAndForget(const uuid_vec_t& folder_ids, + const uuid_vec_t& item_ids) : + LLInventoryFetchComboObserver(folder_ids, item_ids) + {} ~LLCategoryFireAndForget() {} virtual void done() { @@ -482,8 +485,8 @@ void LLToolDragAndDrop::beginDrag(EDragAndDropType type, } if (!folder_ids.empty() || !item_ids.empty()) { - LLCategoryFireAndForget fetcher; - fetcher.startFetch(folder_ids, item_ids); + LLCategoryFireAndForget fetcher(folder_ids, item_ids); + fetcher.startFetch(); } } } @@ -552,8 +555,7 @@ void LLToolDragAndDrop::beginMultiDrag( uuid_vec_t item_ids; std::back_insert_iterator copier(folder_ids); std::copy(cat_ids.begin(), cat_ids.end(), copier); - LLCategoryFireAndForget fetcher; - fetcher.startFetch(folder_ids, item_ids); + LLCategoryFireAndForget fetcher(folder_ids, item_ids); } } } diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index e800611914..1afbca81c3 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -757,11 +757,12 @@ void start_new_inventory_observer() } } -class LLDiscardAgentOffer : public LLInventoryFetchComboObserver +class LLDiscardAgentOffer : public LLInventoryFetchItemsObserver { LOG_CLASS(LLDiscardAgentOffer); public: LLDiscardAgentOffer(const LLUUID& folder_id, const LLUUID& object_id) : + LLInventoryFetchItemsObserver(object_id), mFolderID(folder_id), mObjectID(object_id) {} virtual ~LLDiscardAgentOffer() {} @@ -1266,13 +1267,9 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& // Disabled logging to old chat floater to fix crash in group notices - EXT-4149 // LLFloaterChat::addChatHistory(chat); - uuid_vec_t folders; - uuid_vec_t items; - items.push_back(mObjectID); - LLDiscardAgentOffer* discard_agent_offer; - discard_agent_offer = new LLDiscardAgentOffer(mFolderID, mObjectID); - discard_agent_offer->startFetch(folders, items); - if(catp || (itemp && itemp->isFinished())) + LLDiscardAgentOffer* discard_agent_offer = new LLDiscardAgentOffer(mFolderID, mObjectID); + discard_agent_offer->startFetch(); + if (catp || (itemp && itemp->isFinished())) { discard_agent_offer->done(); } -- cgit v1.2.3 From 5d3de2ea03ff500690acec13fd4b403dc8a72088 Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Wed, 7 Apr 2010 13:30:21 -0400 Subject: EXT-6745 : Refactor LLFetchComboObserver to use LLFetchItems and LLFetchDescedents instead of code duplication Took out a bunch of code duplication from the FetchComboObserver and am using the LLFetchItems/DescendentsObservers instead. Also added some comments and made some minor superficial cleanup to LLInventoryObserver done(). --- indra/newview/llinventoryobserver.cpp | 135 ++++++++-------------------------- indra/newview/llinventoryobserver.h | 23 ++---- indra/newview/lltooldraganddrop.cpp | 8 +- 3 files changed, 44 insertions(+), 122 deletions(-) diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp index 35bd06125f..26fe1904fb 100644 --- a/indra/newview/llinventoryobserver.cpp +++ b/indra/newview/llinventoryobserver.cpp @@ -205,10 +205,6 @@ void LLInventoryFetchItemsObserver::changed(U32 mask) //llinfos << "LLInventoryFetchItemsObserver::changed() mIncomplete size " << mIncomplete.size() << llendl; } -void LLInventoryFetchItemsObserver::done() -{ -} - void fetch_items_from_llsd(const LLSD& items_llsd) { if (!items_llsd.size()) return; @@ -406,119 +402,50 @@ BOOL LLInventoryFetchDescendentsObserver::isCategoryComplete(const LLViewerInven } LLInventoryFetchComboObserver::LLInventoryFetchComboObserver(const uuid_vec_t& folder_ids, - const uuid_vec_t& item_ids) : - mFolderIDs(folder_ids), - mItemIDs(item_ids), - mDone(FALSE) + const uuid_vec_t& item_ids) { -} + mFetchDescendents = new LLInventoryFetchDescendentsObserver(folder_ids); -void LLInventoryFetchComboObserver::changed(U32 mask) -{ - if (!mIncompleteItems.empty()) - { - for (uuid_vec_t::iterator it = mIncompleteItems.begin(); it < mIncompleteItems.end(); ) - { - LLViewerInventoryItem* item = gInventory.getItem(*it); - if (!item) - { - it = mIncompleteItems.erase(it); - continue; - } - if (item->isFinished()) - { - mCompleteItems.push_back(*it); - it = mIncompleteItems.erase(it); - continue; - } - ++it; - } - } - if (!mIncompleteFolders.empty()) + uuid_vec_t pruned_item_ids; + for (uuid_vec_t::const_iterator item_iter = item_ids.begin(); + item_iter != item_ids.end(); + ++item_iter) { - for (uuid_vec_t::iterator it = mIncompleteFolders.begin(); it < mIncompleteFolders.end();) + const LLUUID& item_id = (*item_iter); + const LLViewerInventoryItem* item = gInventory.getItem(item_id); + if (item && std::find(folder_ids.begin(), folder_ids.end(), item->getParentUUID()) == folder_ids.end()) { - LLViewerInventoryCategory* cat = gInventory.getCategory(*it); - if (!cat) - { - it = mIncompleteFolders.erase(it); - continue; - } - if (gInventory.isCategoryComplete(*it)) - { - mCompleteFolders.push_back(*it); - it = mIncompleteFolders.erase(it); - continue; - } - ++it; + continue; } + pruned_item_ids.push_back(item_id); } - if (!mDone && mIncompleteItems.empty() && mIncompleteFolders.empty()) + + mFetchItems = new LLInventoryFetchItemsObserver(pruned_item_ids); + mFetchDescendents = new LLInventoryFetchDescendentsObserver(folder_ids); +} + +LLInventoryFetchComboObserver::~LLInventoryFetchComboObserver() +{ + mFetchItems->done(); + mFetchDescendents->done(); + delete mFetchItems; + delete mFetchDescendents; +} + +void LLInventoryFetchComboObserver::changed(U32 mask) +{ + mFetchItems->changed(mask); + mFetchDescendents->changed(mask); + if (mFetchItems->isFinished() && mFetchDescendents->isFinished()) { - mDone = TRUE; done(); } } void LLInventoryFetchComboObserver::startFetch() { - lldebugs << "LLInventoryFetchComboObserver::startFetch()" << llendl; - for (uuid_vec_t::const_iterator fit = mFolderIDs.begin(); fit != mFolderIDs.end(); ++fit) - { - LLViewerInventoryCategory* cat = gInventory.getCategory(*fit); - if (!cat) continue; - if (!gInventory.isCategoryComplete(*fit)) - { - cat->fetch(); - lldebugs << "fetching folder " << *fit <isFinished()) - { - // It's complete, so put it on the complete container. - mCompleteItems.push_back(*iit); - lldebugs << "completing item " << *iit << llendl; - continue; - } - else - { - mIncompleteItems.push_back(*iit); - owner_id = item->getPermissions().getOwner(); - } - if (std::find(mIncompleteFolders.begin(), mIncompleteFolders.end(), item->getParentUUID()) == mIncompleteFolders.end()) - { - LLSD item_entry; - item_entry["owner_id"] = owner_id; - item_entry["item_id"] = (*iit); - items_llsd.append(item_entry); - } - else - { - lldebugs << "not worrying about " << *iit << llendl; - } - } - fetch_items_from_llsd(items_llsd); + mFetchItems->startFetch(); + mFetchDescendents->startFetch(); } void LLInventoryExistenceObserver::watchItem(const LLUUID& id) diff --git a/indra/newview/llinventoryobserver.h b/indra/newview/llinventoryobserver.h index e4ae9097bd..7b4d3dfe7b 100644 --- a/indra/newview/llinventoryobserver.h +++ b/indra/newview/llinventoryobserver.h @@ -45,7 +45,6 @@ class LLViewerInventoryCategory; // A simple abstract base class that can relay messages when the inventory // changes. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - class LLInventoryObserver { public: @@ -60,7 +59,7 @@ public: ADD = 4, // Something added REMOVE = 8, // Something deleted STRUCTURE = 16, // Structural change (e.g. item or folder moved) - CALLING_CARD = 32, // Calling card change (e.g. online, grant status, cancel) + CALLING_CARD = 32, // Calling card change (e.g. online, grant status, cancel) GESTURE = 64, REBUILD = 128, // Item UI changed (e.g. item type different) SORT = 256, // Folder needs to be resorted. @@ -88,9 +87,8 @@ public: BOOL isFinished() const; virtual void startFetch() = 0; - virtual void done() = 0; virtual void changed(U32 mask) = 0; - + virtual void done() {}; protected: uuid_vec_t mComplete; uuid_vec_t mIncomplete; @@ -112,8 +110,6 @@ public: /*virtual*/ void startFetch(); /*virtual*/ void changed(U32 mask); - /*virtual*/ void done(); - protected: BOOL mRetryIfMissing; }; @@ -140,28 +136,23 @@ protected: // Class LLInventoryFetchComboObserver // // Does an appropriate combination of fetch descendents and -// item fetches based on completion of categories and items. Much like -// the fetch and fetch descendents, this will call done() when everything -// has arrived. +// item fetches based on completion of categories and items. This is optimized +// to not fetch item_ids that are descendents of any of the folder_ids. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class LLInventoryFetchComboObserver : public LLInventoryObserver { public: LLInventoryFetchComboObserver(const uuid_vec_t& folder_ids, const uuid_vec_t& item_ids); + ~LLInventoryFetchComboObserver(); /*virtual*/ void changed(U32 mask); void startFetch(); virtual void done() = 0; protected: BOOL mDone; - uuid_vec_t mCompleteFolders; - uuid_vec_t mIncompleteFolders; - uuid_vec_t mCompleteItems; - uuid_vec_t mIncompleteItems; - - uuid_vec_t mItemIDs; - uuid_vec_t mFolderIDs; + LLInventoryFetchItemsObserver *mFetchItems; + LLInventoryFetchDescendentsObserver *mFetchDescendents; }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index a67067d29c..774626f19d 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -232,6 +232,9 @@ bool LLGiveable::operator()(LLInventoryCategory* cat, LLInventoryItem* item) return allowed; } +// Starts a fetch on folders and items. This is really not used +// as an observer in the traditional sense; we're just using it to +// request a fetch and we don't care about when/if the response arrives. class LLCategoryFireAndForget : public LLInventoryFetchComboObserver { public: @@ -485,8 +488,9 @@ void LLToolDragAndDrop::beginDrag(EDragAndDropType type, } if (!folder_ids.empty() || !item_ids.empty()) { - LLCategoryFireAndForget fetcher(folder_ids, item_ids); - fetcher.startFetch(); + LLCategoryFireAndForget *fetcher = new LLCategoryFireAndForget(folder_ids, item_ids); + fetcher->startFetch(); + delete fetcher; } } } -- cgit v1.2.3 From 516ec63f52245a777725d29efe3c35e4e4e72936 Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Wed, 7 Apr 2010 14:40:36 -0400 Subject: EXT-6749 : Have all observers persist/retry when items are missing after notifications Added mNumTries and took out mRetryIfMissing --- indra/newview/llagentwearablesfetch.cpp | 2 +- indra/newview/llgesturemgr.cpp | 1 - indra/newview/llinventoryobserver.cpp | 51 ++++++++++++++++++--------------- indra/newview/llinventoryobserver.h | 10 +++---- 4 files changed, 33 insertions(+), 31 deletions(-) diff --git a/indra/newview/llagentwearablesfetch.cpp b/indra/newview/llagentwearablesfetch.cpp index aafbb0d22c..08d8ccfd23 100644 --- a/indra/newview/llagentwearablesfetch.cpp +++ b/indra/newview/llagentwearablesfetch.cpp @@ -91,7 +91,7 @@ class LLFetchAndLinkObserver: public LLInventoryFetchItemsObserver { public: LLFetchAndLinkObserver(uuid_vec_t& ids): - LLInventoryFetchItemsObserver(ids, true) // retry for missing items + LLInventoryFetchItemsObserver(ids) { } ~LLFetchAndLinkObserver() diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp index 3d38ff3730..0996d09e25 100644 --- a/indra/newview/llgesturemgr.cpp +++ b/indra/newview/llgesturemgr.cpp @@ -73,7 +73,6 @@ LLGestureMgr::LLGestureMgr() mActive(), mLoadingCount(0) { - mRetryIfMissing = true; gInventory.addObserver(this); } diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp index 26fe1904fb..fb2ef01c8f 100644 --- a/indra/newview/llinventoryobserver.cpp +++ b/indra/newview/llinventoryobserver.cpp @@ -62,6 +62,14 @@ #include "llsdutil.h" #include +// If the viewer gets a notification, your observer assumes +// that that notification is for itself and then tries to process +// the results. The notification could be for something else (e.g. +// 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; + LLInventoryObserver::LLInventoryObserver() { } @@ -138,66 +146,63 @@ void LLInventoryCompletionObserver::watchItem(const LLUUID& id) } } -/* -LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(BOOL retry_if_missing) : - mRetryIfMissing(retry_if_missing) -{ -} -*/ - -LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(const LLUUID& item_id, - BOOL retry_if_missing) : +LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(const LLUUID& item_id) : LLInventoryFetchObserver(item_id), - mRetryIfMissing(retry_if_missing) + mNumTries(MAX_NUM_NOTIFICATIONS_TO_PROCESS) { mIDs.clear(); mIDs.push_back(item_id); } -LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(const uuid_vec_t& item_ids, - BOOL retry_if_missing) : - LLInventoryFetchObserver(item_ids), - mRetryIfMissing(retry_if_missing) +LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(const uuid_vec_t& item_ids) : + LLInventoryFetchObserver(item_ids) { } void LLInventoryFetchItemsObserver::changed(U32 mask) { + BOOL any_items_missing = FALSE; + // scan through the incomplete items and move or erase them as // appropriate. if (!mIncomplete.empty()) { for (uuid_vec_t::iterator it = mIncomplete.begin(); it < mIncomplete.end(); ) { - LLViewerInventoryItem* item = gInventory.getItem(*it); + const LLUUID& item_id = (*it); + LLViewerInventoryItem* item = gInventory.getItem(item_id); if (!item) { - if (mRetryIfMissing) + any_items_missing = TRUE; + if (mNumTries > 0) { - // BAP changed to skip these items, so we should keep retrying until they arrive. - // Did not make this the default behavior because of uncertainty about impact - - // could cause some observers that currently complete to wait forever. + // Keep trying. ++it; } else { - // BUG: This can cause done() to get called prematurely below. - // This happens with the LLGestureInventoryFetchObserver that - // loads gestures at startup. JC + // Just concede that this item hasn't arrived in reasonable time and continue on. + llwarns << "Fetcher timed out when fetching inventory item assetID:" << item_id << llendl; it = mIncomplete.erase(it); } continue; } if (item->isFinished()) { - mComplete.push_back(*it); + mComplete.push_back(item_id); it = mIncomplete.erase(it); continue; } ++it; } + if (any_items_missing) + { + mNumTries--; + } + if (mIncomplete.empty()) { + mNumTries = MAX_NUM_NOTIFICATIONS_TO_PROCESS; done(); } } diff --git a/indra/newview/llinventoryobserver.h b/indra/newview/llinventoryobserver.h index 7b4d3dfe7b..ac2eca3477 100644 --- a/indra/newview/llinventoryobserver.h +++ b/indra/newview/llinventoryobserver.h @@ -103,15 +103,13 @@ protected: class LLInventoryFetchItemsObserver : public LLInventoryFetchObserver { public: - LLInventoryFetchItemsObserver(const LLUUID& item_id = LLUUID::null, - BOOL retry_if_missing = FALSE); - LLInventoryFetchItemsObserver(const uuid_vec_t& item_ids, - BOOL retry_if_missing = FALSE); + LLInventoryFetchItemsObserver(const LLUUID& item_id = LLUUID::null); + LLInventoryFetchItemsObserver(const uuid_vec_t& item_ids); /*virtual*/ void startFetch(); /*virtual*/ void changed(U32 mask); -protected: - BOOL mRetryIfMissing; +private: + S8 mNumTries; // Number of times changed() was called without success }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- cgit v1.2.3 From dbe288bf8f14447f7bda5413c7886f539fec2a20 Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Wed, 7 Apr 2010 16:33:44 -0400 Subject: fixes from automated merge --- indra/newview/llpaneloutfitedit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp index dc039486e1..c3def73753 100644 --- a/indra/newview/llpaneloutfitedit.cpp +++ b/indra/newview/llpaneloutfitedit.cpp @@ -376,14 +376,14 @@ void LLPanelOutfitEdit::onEditWearableClicked(void) if(wearable_to_edit) { bool can_modify = false; - bool is_complete = item_to_edit->isComplete(); + bool is_complete = item_to_edit->isFinished(); // if item_to_edit is a link, its properties are not appropriate, // lets get original item with actual properties LLViewerInventoryItem* original_item = gInventory.getItem(wearable_to_edit->getItemID()); if(original_item) { can_modify = original_item->getPermissions().allowModifyBy(gAgentID); - is_complete = original_item->isComplete(); + is_complete = original_item->isFinished(); } if (can_modify && is_complete) -- cgit v1.2.3 From 00462c243116e2720acf51ee1f777e69e8189f33 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Thu, 8 Apr 2010 12:07:58 +0300 Subject: Fixed normal bug EXT-4347 (Moving object contents to inventory opens files, changes menu) Implementation details: * Added new LLViewerInventoryMoveFromWorldObserver to watch moved items via their Asses UUIDs. It is instantiated only once due to drop events are sent separately for each item while multi-dragging. * Existent LLOpenTaskOffer observer uses it to exclude watched by LLViewerInventoryMoveFromWorldObserver items from own processing. * Removed dependancy on LLPanelPlaces in open_inventory_offer(). Openning of offered LM via group notice moved into an appropriate section (processed by LLOpenTaskGroupOffer) Known Issues: * If Script item is among the dragged items from object to inventory it will be the only selected item in the inventory panel. Reason: it does not have its own Asset UUID and processed via LLOpenTaskOffer when should not. Reviewed by Leyla and Richard at https://codereview.productengine.com/secondlife/r/116/ --HG-- branch : product-engine --- indra/newview/llinventorybridge.cpp | 3 + indra/newview/llinventoryobserver.cpp | 63 ++++++++++ indra/newview/llinventoryobserver.h | 30 +++++ indra/newview/llviewermessage.cpp | 212 ++++++++++++++++++++++++++++++---- indra/newview/llviewermessage.h | 2 + 5 files changed, 285 insertions(+), 25 deletions(-) diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index b552b5ac07..943a851c13 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -3167,6 +3167,9 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item, } else { + // store dad inventory item to select added one later. See EXT-4347 + set_dad_inventory_item(inv_item, mUUID); + LLNotification::Params params("MoveInventoryFromObject"); params.functor.function(boost::bind(move_task_inventory_callback, _1, _2, move_inv)); LLNotifications::instance().forceResponse(params, 0); diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp index 83e1bbd5a0..922fcc16c0 100644 --- a/indra/newview/llinventoryobserver.cpp +++ b/indra/newview/llinventoryobserver.cpp @@ -495,6 +495,69 @@ void LLInventoryExistenceObserver::changed(U32 mask) } } +void LLInventoryMoveFromWorldObserver::changed(U32 mask) +{ + if(!(mask & LLInventoryObserver::ADD)) + { + return; + } + + // nothing is watched + if (mWatchedAssets.size() == 0) + { + return; + } + + LLPointer item = new LLViewerInventoryItem; + LLMessageSystem* msg = gMessageSystem; + S32 num_blocks = msg->getNumberOfBlocksFast(_PREHASH_InventoryData); + for(S32 i = 0; i < num_blocks; ++i) + { + item->unpackMessage(msg, _PREHASH_InventoryData, i); + const LLUUID& asset_uuid = item->getAssetUUID(); + if (item->getUUID().notNull() && asset_uuid.notNull()) + { + if (isAssetWatched(asset_uuid)) + { + LL_DEBUGS("Inventory_Move") << "Found asset UUID: " << asset_uuid << LL_ENDL; + mAddedItems.push_back(item->getUUID()); + } + } + } + + if (mAddedItems.size() == mWatchedAssets.size()) + { + done(); + LL_DEBUGS("Inventory_Move") << "All watched items are added & processed." << LL_ENDL; + mAddedItems.clear(); + + // Unable to clean watched items here due to somebody can require to check them in current frame. + // set dirty state to clean them while next watch cycle. + mIsDirty = true; + } +} + +void LLInventoryMoveFromWorldObserver::watchAsset(const LLUUID& asset_id) +{ + if(asset_id.notNull()) + { + if (mIsDirty) + { + LL_DEBUGS("Inventory_Move") << "Watched items are dirty. Clean them." << LL_ENDL; + mWatchedAssets.clear(); + mIsDirty = false; + } + + mWatchedAssets.push_back(asset_id); + onAssetAdded(asset_id); + } +} + +bool LLInventoryMoveFromWorldObserver::isAssetWatched( const LLUUID& asset_id ) +{ + return std::find(mWatchedAssets.begin(), mWatchedAssets.end(), asset_id) != mWatchedAssets.end(); +} + void LLInventoryAddedObserver::changed(U32 mask) { if(!(mask & LLInventoryObserver::ADD)) diff --git a/indra/newview/llinventoryobserver.h b/indra/newview/llinventoryobserver.h index ba70552ebc..b710a9d326 100644 --- a/indra/newview/llinventoryobserver.h +++ b/indra/newview/llinventoryobserver.h @@ -193,6 +193,36 @@ protected: uuid_vec_t mMIA; }; +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Class LLInventoryMovedObserver +// +// This class is used as a base class for doing something when all the +// item for observed asset ids were added into the inventory. +// Derive a class from this class and implement the done() method to do +// something useful. +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +class LLInventoryMoveFromWorldObserver : public LLInventoryObserver +{ +public: + LLInventoryMoveFromWorldObserver() : mIsDirty(false) {} + virtual void changed(U32 mask); + + void watchAsset(const LLUUID& asset_id); + bool isAssetWatched(const LLUUID& asset_id); + +protected: + virtual void onAssetAdded(const LLUUID& asset_id) {} + virtual void done() = 0; + + typedef std::vector item_ref_t; + item_ref_t mAddedItems; + item_ref_t mWatchedAssets; + +private: + bool mIsDirty; +}; + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLInventoryAddedObserver // diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index c542459cdb..2b41a83ba5 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -71,7 +71,6 @@ #include "llnotifications.h" #include "llnotificationsutil.h" #include "llpanelgrouplandmoney.h" -#include "llpanelplaces.h" #include "llrecentpeople.h" #include "llscriptfloater.h" #include "llselectmgr.h" @@ -692,6 +691,52 @@ bool join_group_response(const LLSD& notification, const LLSD& response) return false; } + +static void highlight_inventory_items_in_panel(const std::vector& items, LLInventoryPanel *inventory_panel) +{ + if (NULL == inventory_panel) return; + + for (std::vector::const_iterator item_iter = items.begin(); + item_iter != items.end(); + ++item_iter) + { + const LLUUID& item_id = (*item_iter); + if(!highlight_offered_item(item_id)) + { + continue; + } + + LLInventoryItem* item = gInventory.getItem(item_id); + llassert(item); + if (!item) { + continue; + } + + LL_DEBUGS("Inventory_Move") << "Highlighting inventory item: " << item->getName() << ", " << item_id << LL_ENDL; + LLFolderView* fv = inventory_panel->getRootFolder(); + if (fv) + { + LLFolderViewItem* fv_item = fv->getItemByID(item_id); + if (fv_item) + { + LLFolderViewItem* fv_folder = fv_item->getParentFolder(); + if (fv_folder) + { + // Parent folders can be different in case of 2 consecutive drag and drop + // operations when the second one is started before the first one completes. + LL_DEBUGS("Inventory_Move") << "Open folder: " << fv_folder->getName() << LL_ENDL; + fv_folder->setOpen(TRUE); + if (fv_folder->isSelected()) + { + fv->changeSelection(fv_folder, FALSE); + } + } + fv->changeSelection(fv_item, TRUE); + } + } + } +} + static LLNotificationFunctorRegistration jgr_1("JoinGroup", join_group_response); static LLNotificationFunctorRegistration jgr_2("JoinedTooManyGroupsMember", join_group_response); static LLNotificationFunctorRegistration jgr_3("JoinGroupCanAfford", join_group_response); @@ -714,6 +759,108 @@ private: std::string mFromName; }; +/** + * Class to observe adding of new items moved from the world to user's inventory to select them in inventory. + * + * We can't create it each time items are moved because "drop" event is sent separately for each + * element even while multi-dragging. We have to have the only instance of the observer. See EXT-4347. + */ +class LLViewerInventoryMoveFromWorldObserver : public LLInventoryMoveFromWorldObserver +{ +public: + LLViewerInventoryMoveFromWorldObserver() + : LLInventoryMoveFromWorldObserver() + , mActivePanel(NULL) + { + + } + + void setMoveIntoFolderID(const LLUUID& into_folder_uuid) {mMoveIntoFolderID = into_folder_uuid; } + +private: + /*virtual */void onAssetAdded(const LLUUID& asset_id) + { + // Store active Inventory panel. + mActivePanel = LLInventoryPanel::getActiveInventoryPanel(); + + // Store selected items (without destination folder) + mSelectedItems.clear(); + mActivePanel->getRootFolder()->getSelectionList(mSelectedItems); + mSelectedItems.erase(mMoveIntoFolderID); + } + + /** + * Selects added inventory items watched by their Asset UUIDs if selection was not changed since + * all items were started to watch (dropped into a folder). + */ + void done() + { + // if selection is not changed since watch started lets hightlight new items. + if (mActivePanel && !isSelectionChanged()) + { + LL_DEBUGS("Inventory_Move") << "Selecting new items..." << LL_ENDL; + mActivePanel->clearSelection(); + highlight_inventory_items_in_panel(mAddedItems, mActivePanel); + } + } + + /** + * Returns true if selected inventory items were changed since moved inventory items were started to watch. + */ + bool isSelectionChanged() + { + const LLInventoryPanel * const current_active_panel = LLInventoryPanel::getActiveInventoryPanel(); + + if (NULL == mActivePanel || current_active_panel != mActivePanel) + { + return true; + } + + // get selected items (without destination folder) + selected_items_t selected_items; + mActivePanel->getRootFolder()->getSelectionList(selected_items); + selected_items.erase(mMoveIntoFolderID); + + // compare stored & current sets of selected items + selected_items_t different_items; + std::set_symmetric_difference(mSelectedItems.begin(), mSelectedItems.end(), + selected_items.begin(), selected_items.end(), std::inserter(different_items, different_items.begin())); + + LL_DEBUGS("Inventory_Move") << "Selected firstly: " << mSelectedItems.size() + << ", now: " << selected_items.size() << ", difference: " << different_items.size() << LL_ENDL; + + return different_items.size() > 0; + } + + LLInventoryPanel *mActivePanel; + typedef std::set selected_items_t; + selected_items_t mSelectedItems; + + /** + * UUID of FolderViewFolder into which watched items are moved. + * + * Destination FolderViewFolder becomes selected while mouse hovering (when dragged items are dropped). + * + * If mouse is moved out it set unselected and number of selected items is changed + * even if selected items in Inventory stay the same. + * So, it is used to update stored selection list. + * + * @see onAssetAdded() + * @see isSelectionChanged() + */ + LLUUID mMoveIntoFolderID; +}; + +LLViewerInventoryMoveFromWorldObserver* gInventoryMoveObserver = NULL; + +void set_dad_inventory_item(LLInventoryItem* inv_item, const LLUUID& into_folder_uuid) +{ + start_new_inventory_observer(); + + gInventoryMoveObserver->setMoveIntoFolderID(into_folder_uuid); + gInventoryMoveObserver->watchAsset(inv_item->getAssetUUID()); +} + //unlike the FetchObserver for AgentOffer, we only make one //instance of the AddedObserver for TaskOffers //and it never dies. We do this because we don't know the UUID of @@ -724,6 +871,33 @@ class LLOpenTaskOffer : public LLInventoryAddedObserver protected: /*virtual*/ void done() { + for (uuid_vec_t::iterator it = mAdded.begin(); it != mAdded.end();) + { + const LLUUID& item_uuid = *it; + bool was_moved = false; + LLInventoryObject* added_object = gInventory.getObject(item_uuid); + if (added_object) + { + // cast to item to get Asset UUID + LLInventoryItem* added_item = dynamic_cast(added_object); + if (added_item) + { + const LLUUID& asset_uuid = added_item->getAssetUUID(); + if (gInventoryMoveObserver->isAssetWatched(asset_uuid)) + { + LL_DEBUGS("Inventory_Move") << "Found asset UUID: " << asset_uuid << LL_ENDL; + was_moved = true; + } + } + } + + if (was_moved) + { + it = mAdded.erase(it); + } + else ++it; + } + open_inventory_offer(mAdded, ""); mAdded.clear(); } @@ -752,6 +926,13 @@ void start_new_inventory_observer() gNewInventoryObserver = new LLOpenTaskOffer; gInventory.addObserver(gNewInventoryObserver); } + + if (!gInventoryMoveObserver) //inventory move from the world observer + { + // Observer is deleted by gInventory + gInventoryMoveObserver = new LLViewerInventoryMoveFromWorldObserver; + gInventory.addObserver(gInventoryMoveObserver); + } } class LLDiscardAgentOffer : public LLInventoryFetchComboObserver @@ -916,9 +1097,12 @@ void open_inventory_offer(const uuid_vec_t& items, const std::string& from_name) } else if("group_offer" == from_name) { - // do not open inventory when we open group notice attachment because - // we already opened landmark info panel // "group_offer" is passed by LLOpenTaskGroupOffer + // Notification about added landmark will be generated under the "from_name.empty()" called from LLOpenTaskOffer::done(). + LLSD args; + args["type"] = "landmark"; + args["id"] = item_id; + LLSideTray::getInstance()->showPanel("panel_places", args); continue; } @@ -929,28 +1113,6 @@ void open_inventory_offer(const uuid_vec_t& items, const std::string& from_name) args["LANDMARK_NAME"] = item->getName(); args["FOLDER_NAME"] = std::string(parent_folder ? parent_folder->getName() : "unknown"); LLNotificationsUtil::add("LandmarkCreated", args); - // Created landmark is passed to Places panel to allow its editing. In fact panel should be already displayed. - // If the panel is closed we don't reopen it until created landmark is loaded. - //TODO*:: dserduk(7/12/09) remove LLPanelPlaces dependency from here - LLPanelPlaces *places_panel = dynamic_cast(LLSideTray::getInstance()->getPanel("panel_places")); - if (places_panel) - { - // Landmark creation handling is moved to LLPanelPlaces::showAddedLandmarkInfo() - // TODO* LLPanelPlaces dependency is going to be removed. See EXT-4347. - //if("create_landmark" == places_panel->getPlaceInfoType() && !places_panel->getItem()) - //{ - // places_panel->setItem(item); - //} - //else - // we are opening a group notice attachment - if("create_landmark" != places_panel->getPlaceInfoType()) - { - LLSD args; - args["type"] = "landmark"; - args["id"] = item_id; - LLSideTray::getInstance()->showPanel("panel_places", args); - } - } } } break; diff --git a/indra/newview/llviewermessage.h b/indra/newview/llviewermessage.h index 4015cca77b..7c021dc05f 100644 --- a/indra/newview/llviewermessage.h +++ b/indra/newview/llviewermessage.h @@ -208,6 +208,8 @@ void open_inventory_offer(const uuid_vec_t& items, const std::string& from_name) // Returns false if item is not found. bool highlight_offered_item(const LLUUID& item_id); +void set_dad_inventory_item(LLInventoryItem* inv_item, const LLUUID& into_folder_uuid); + struct LLOfferInfo { LLOfferInfo() -- cgit v1.2.3 From 5c1563e2cbee162de52cee321edb8148016865ba Mon Sep 17 00:00:00 2001 From: Dmitry Zaporozhan Date: Thu, 8 Apr 2010 11:46:40 +0300 Subject: (final part) EXT-6564(major) - Fix wearable editing panels Updated Parameter panel: - removed hard coded values - improved panel layout Reviewed by Mike Antipov, Neal Orman - https://codereview.productengine.com/secondlife/r/157/ --HG-- branch : product-engine --- indra/newview/llscrollingpanelparam.cpp | 30 ++++++------- indra/newview/llscrollingpanelparam.h | 5 --- .../skins/default/xui/en/panel_scrolling_param.xml | 51 +++++++++++----------- 3 files changed, 41 insertions(+), 45 deletions(-) diff --git a/indra/newview/llscrollingpanelparam.cpp b/indra/newview/llscrollingpanelparam.cpp index 7980fe1945..a5518d87d4 100644 --- a/indra/newview/llscrollingpanelparam.cpp +++ b/indra/newview/llscrollingpanelparam.cpp @@ -42,17 +42,14 @@ #include "llbutton.h" #include "llsliderctrl.h" #include "llagent.h" +#include "llviewborder.h" #include "llvoavatarself.h" // Constants for LLPanelVisualParam const F32 LLScrollingPanelParam::PARAM_STEP_TIME_THRESHOLD = 0.25f; -const S32 LLScrollingPanelParam::BTN_BORDER = 2; const S32 LLScrollingPanelParam::PARAM_HINT_WIDTH = 128; const S32 LLScrollingPanelParam::PARAM_HINT_HEIGHT = 128; -const S32 LLScrollingPanelParam::PARAM_HINT_LABEL_HEIGHT = 16; -const S32 LLScrollingPanelParam::PARAM_PANEL_WIDTH = 2 * (3* BTN_BORDER + PARAM_HINT_WIDTH + LLPANEL_BORDER_WIDTH); -const S32 LLScrollingPanelParam::PARAM_PANEL_HEIGHT = 2 * BTN_BORDER + PARAM_HINT_HEIGHT + PARAM_HINT_LABEL_HEIGHT + 4 * LLPANEL_BORDER_WIDTH; // LLScrollingPanelParam //static @@ -67,14 +64,17 @@ LLScrollingPanelParam::LLScrollingPanelParam( const LLPanel::Params& panel_param { LLUICtrlFactory::getInstance()->buildPanel(this, "panel_scrolling_param.xml"); + // *HACK To avoid hard coding texture position, lets use border's position for texture. + LLViewBorder* left_border = getChild("left_border"); + static LLUICachedControl slider_ctrl_height ("UISliderctrlHeight", 0); - S32 pos_x = 2 * LLPANEL_BORDER_WIDTH; - S32 pos_y = 3 * LLPANEL_BORDER_WIDTH + slider_ctrl_height; + S32 pos_x = left_border->getRect().mLeft + left_border->getBorderWidth(); + S32 pos_y = left_border->getRect().mBottom + left_border->getBorderWidth(); F32 min_weight = param->getMinWeight(); F32 max_weight = param->getMaxWeight(); mHintMin = new LLVisualParamHint( pos_x, pos_y, PARAM_HINT_WIDTH, PARAM_HINT_HEIGHT, mesh, (LLViewerVisualParam*) wearable->getVisualParam(param->getID()), min_weight); - pos_x += PARAM_HINT_WIDTH + 3 * BTN_BORDER; + pos_x = getChild("right_border")->getRect().mLeft + left_border->getBorderWidth(); mHintMax = new LLVisualParamHint( pos_x, pos_y, PARAM_HINT_WIDTH, PARAM_HINT_HEIGHT, mesh, (LLViewerVisualParam*) wearable->getVisualParam(param->getID()), max_weight ); mHintMin->setAllowsUpdates( FALSE ); @@ -162,6 +162,10 @@ void LLScrollingPanelParam::draw() childSetVisible("less", mHintMin->getVisible()); childSetVisible("more", mHintMax->getVisible()); + // hide borders if texture has been loaded + childSetVisible("left_border", !mHintMin->getVisible()); + childSetVisible("right_border", !mHintMax->getVisible()); + // Draw all the children except for the labels childSetVisible( "min param text", FALSE ); childSetVisible( "max param text", FALSE ); @@ -171,9 +175,7 @@ void LLScrollingPanelParam::draw() gGL.pushUIMatrix(); { const LLRect& r = mHintMin->getRect(); - F32 left = (F32)(r.mLeft + BTN_BORDER); - F32 bot = (F32)(r.mBottom + BTN_BORDER); - gGL.translateUI(left, bot, 0.f); + gGL.translateUI((F32)r.mLeft, (F32)r.mBottom, 0.f); mHintMin->draw(); } gGL.popUIMatrix(); @@ -181,9 +183,7 @@ void LLScrollingPanelParam::draw() gGL.pushUIMatrix(); { const LLRect& r = mHintMax->getRect(); - F32 left = (F32)(r.mLeft + BTN_BORDER); - F32 bot = (F32)(r.mBottom + BTN_BORDER); - gGL.translateUI(left, bot, 0.f); + gGL.translateUI((F32)r.mLeft, (F32)r.mBottom, 0.f); mHintMax->draw(); } gGL.popUIMatrix(); @@ -191,10 +191,10 @@ void LLScrollingPanelParam::draw() // Draw labels on top of the buttons childSetVisible( "min param text", TRUE ); - drawChild(getChild("min param text"), BTN_BORDER, BTN_BORDER); + drawChild(getChild("min param text")); childSetVisible( "max param text", TRUE ); - drawChild(getChild("max param text"), BTN_BORDER, BTN_BORDER); + drawChild(getChild("max param text")); } // static diff --git a/indra/newview/llscrollingpanelparam.h b/indra/newview/llscrollingpanelparam.h index 8c5db64816..fe4ce07166 100644 --- a/indra/newview/llscrollingpanelparam.h +++ b/indra/newview/llscrollingpanelparam.h @@ -75,13 +75,8 @@ public: // Constants for LLPanelVisualParam const static F32 PARAM_STEP_TIME_THRESHOLD; - const static S32 BTN_BORDER; const static S32 PARAM_HINT_WIDTH; const static S32 PARAM_HINT_HEIGHT; - const static S32 PARAM_HINT_LABEL_HEIGHT; - const static S32 PARAM_PANEL_WIDTH; - const static S32 PARAM_PANEL_HEIGHT; - public: LLViewerVisualParam* mParam; diff --git a/indra/newview/skins/default/xui/en/panel_scrolling_param.xml b/indra/newview/skins/default/xui/en/panel_scrolling_param.xml index f9c86fc75b..8042563900 100644 --- a/indra/newview/skins/default/xui/en/panel_scrolling_param.xml +++ b/indra/newview/skins/default/xui/en/panel_scrolling_param.xml @@ -1,6 +1,6 @@ + top="120" + width="120" /> + width="120" /> @@ -40,7 +40,7 @@ follows="left|top" height="16" layout="topleft" - left_pad="6" + left="155" name="Loading...2" top_delta="0" width="128"> @@ -49,30 +49,30 @@ @@ -84,10 +84,10 @@ image_selected="PushButton_Selected" image_unselected="PushButton_Off" layout="topleft" - left="2" + left="7" name="less" tab_stop="false" - top="0" + top="5" width="132" /> diff --git a/indra/newview/skins/default/xui/ja/panel_prim_media_controls.xml b/indra/newview/skins/default/xui/ja/panel_prim_media_controls.xml index 1fe6ad25ed..a9897c7ae4 100644 --- a/indra/newview/skins/default/xui/ja/panel_prim_media_controls.xml +++ b/indra/newview/skins/default/xui/ja/panel_prim_media_controls.xml @@ -13,10 +13,10 @@ -