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/llinventoryobserver.cpp | 43 +++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'indra/newview/llinventoryobserver.cpp') 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) { } -- 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/llinventoryobserver.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'indra/newview/llinventoryobserver.cpp') 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 -- 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/llinventoryobserver.cpp | 95 ++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 36 deletions(-) (limited to 'indra/newview/llinventoryobserver.cpp') 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); -- 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 ++++++++++++++++++---------------- 1 file changed, 65 insertions(+), 58 deletions(-) (limited to 'indra/newview/llinventoryobserver.cpp') 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); } -- 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 ++++++++-------------------------- 1 file changed, 31 insertions(+), 104 deletions(-) (limited to 'indra/newview/llinventoryobserver.cpp') 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) -- 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/llinventoryobserver.cpp | 51 +++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 23 deletions(-) (limited to 'indra/newview/llinventoryobserver.cpp') 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(); } } -- 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/llinventoryobserver.cpp | 63 +++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'indra/newview/llinventoryobserver.cpp') 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)) -- cgit v1.2.3