diff options
author | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2013-11-01 11:02:51 -0400 |
---|---|---|
committer | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2013-11-01 11:02:51 -0400 |
commit | e26268add0d10cb7609afd9070f00d0331b78c4e (patch) | |
tree | d442909903109b8389113ffbdb6511d43c92ea52 | |
parent | 914ae700d211923c80df7de9a072b5692f164515 (diff) |
SH-4595 WIP - reworked descendents of LLInventoryAddedObserver to use gInventory.getAddedIDs(). LLInventoryAddedObserver isn't really needed anymore, but leaving it in as a debugging point at least for now.
-rwxr-xr-x | indra/llcommon/lluuid.h | 13 | ||||
-rwxr-xr-x | indra/newview/llinventorymodel.cpp | 18 | ||||
-rwxr-xr-x | indra/newview/llinventorymodel.h | 5 | ||||
-rwxr-xr-x | indra/newview/llinventoryobserver.cpp | 33 | ||||
-rwxr-xr-x | indra/newview/llinventoryobserver.h | 4 | ||||
-rwxr-xr-x | indra/newview/lllocationinputctrl.cpp | 6 | ||||
-rwxr-xr-x | indra/newview/llpanelplaces.cpp | 7 | ||||
-rwxr-xr-x | indra/newview/llpanelplaces.h | 2 | ||||
-rwxr-xr-x | indra/newview/llviewermessage.cpp | 20 |
9 files changed, 48 insertions, 60 deletions
diff --git a/indra/llcommon/lluuid.h b/indra/llcommon/lluuid.h index 7889828c85..82afc7225f 100755 --- a/indra/llcommon/lluuid.h +++ b/indra/llcommon/lluuid.h @@ -131,10 +131,14 @@ public: }; typedef std::vector<LLUUID> uuid_vec_t; - - -// Helper structure for ordering lluuids in stl containers. -// eg: std::map<LLUUID, LLWidget*, lluuid_less> widget_map; +typedef std::set<LLUUID> uuid_set_t; + +// Helper structure for ordering lluuids in stl containers. eg: +// std::map<LLUUID, LLWidget*, lluuid_less> widget_map; +// +// (isn't this the default behavior anyway? I think we could +// everywhere replace these with uuid_set_t, but someone should +// verify.) struct lluuid_less { bool operator()(const LLUUID& lhs, const LLUUID& rhs) const @@ -144,7 +148,6 @@ struct lluuid_less }; typedef std::set<LLUUID, lluuid_less> uuid_list_t; - /* * Sub-classes for keeping transaction IDs and asset IDs * straight. diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index be1a396fff..e9bbf3a7cd 100755 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -1454,6 +1454,7 @@ void LLInventoryModel::notifyObservers() mModifyMask = LLInventoryObserver::NONE; mChangedItemIDs.clear(); + mAddedItemIDs.clear(); mIsNotifyObservers = FALSE; } @@ -1473,13 +1474,18 @@ void LLInventoryModel::addChangedMask(U32 mask, const LLUUID& referent) if (referent.notNull()) { mChangedItemIDs.insert(referent); - } + + if (mask & LLInventoryObserver::ADD) + { + mAddedItemIDs.insert(referent); + } - // Update all linked items. Starting with just LABEL because I'm - // not sure what else might need to be accounted for this. - if (mModifyMask & LLInventoryObserver::LABEL) - { - addChangedMaskForLinks(referent, LLInventoryObserver::LABEL); + // Update all linked items. Starting with just LABEL because I'm + // not sure what else might need to be accounted for this. + if (mask & LLInventoryObserver::LABEL) + { + addChangedMaskForLinks(referent, LLInventoryObserver::LABEL); + } } } diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h index 7afe1dea35..339740870d 100755 --- a/indra/newview/llinventorymodel.h +++ b/indra/newview/llinventorymodel.h @@ -73,7 +73,6 @@ public: typedef LLDynamicArray<LLPointer<LLViewerInventoryCategory> > cat_array_t; typedef LLDynamicArray<LLPointer<LLViewerInventoryItem> > item_array_t; - typedef std::set<LLUUID> changed_items_t; class fetchInventoryResponder : public LLHTTPClient::Responder { @@ -472,7 +471,9 @@ public: // been changed 'under the hood', but outside the control of the // inventory. The next notify will include that notification. void addChangedMask(U32 mask, const LLUUID& referent); + typedef uuid_set_t changed_items_t; const changed_items_t& getChangedIDs() const { return mChangedItemIDs; } + const changed_items_t& getAddedIDs() const { return mAddedItemIDs; } protected: // Updates all linked items pointing to this id. void addChangedMaskForLinks(const LLUUID& object_id, U32 mask); @@ -483,6 +484,8 @@ private: // Variables used to track what has changed since the last notify. U32 mModifyMask; changed_items_t mChangedItemIDs; + changed_items_t mAddedItemIDs; + //-------------------------------------------------------------------- // Observers diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp index 6042ab996d..6181474e5b 100755 --- a/indra/newview/llinventoryobserver.cpp +++ b/indra/newview/llinventoryobserver.cpp @@ -541,34 +541,7 @@ void LLInventoryAddedObserver::changed(U32 mask) return; } - // *HACK: If this was in response to a packet off - // the network, figure out which item was updated. - LLMessageSystem* msg = gMessageSystem; - - std::string msg_name = msg->getMessageName(); - if (msg_name.empty()) - { - return; - } - - // We only want newly created inventory items. JC - if ( msg_name != "UpdateCreateInventoryItem") - { - return; - } - - LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem; - S32 num_blocks = msg->getNumberOfBlocksFast(_PREHASH_InventoryData); - for (S32 i = 0; i < num_blocks; ++i) - { - titem->unpackMessage(msg, _PREHASH_InventoryData, i); - if (!(titem->getUUID().isNull())) - { - //we don't do anything with null keys - mAdded.push_back(titem->getUUID()); - } - } - if (!mAdded.empty()) + if (!gInventory.getAddedIDs().empty()) { done(); } @@ -581,9 +554,9 @@ void LLInventoryCategoryAddedObserver::changed(U32 mask) return; } - const LLInventoryModel::changed_items_t& changed_ids = gInventory.getChangedIDs(); + const LLInventoryModel::changed_items_t& added_ids = gInventory.getAddedIDs(); - for (LLInventoryModel::changed_items_t::const_iterator cit = changed_ids.begin(); cit != changed_ids.end(); ++cit) + for (LLInventoryModel::changed_items_t::const_iterator cit = added_ids.begin(); cit != added_ids.end(); ++cit) { LLViewerInventoryCategory* cat = gInventory.getCategory(*cit); diff --git a/indra/newview/llinventoryobserver.h b/indra/newview/llinventoryobserver.h index 73288242eb..c3cd0d761e 100755 --- a/indra/newview/llinventoryobserver.h +++ b/indra/newview/llinventoryobserver.h @@ -190,13 +190,11 @@ private: class LLInventoryAddedObserver : public LLInventoryObserver { public: - LLInventoryAddedObserver() : mAdded() {} + LLInventoryAddedObserver() {} /*virtual*/ void changed(U32 mask); protected: virtual void done() = 0; - - uuid_vec_t mAdded; }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp index 5022dba934..0d5ecc4059 100755 --- a/indra/newview/lllocationinputctrl.cpp +++ b/indra/newview/lllocationinputctrl.cpp @@ -107,8 +107,8 @@ public: private: /*virtual*/ void done() { - uuid_vec_t::const_iterator it = mAdded.begin(), end = mAdded.end(); - for(; it != end; ++it) + const uuid_set_t& added = gInventory.getAddedIDs(); + for (uuid_set_t::const_iterator it = added.begin(); it != added.end(); ++it) { LLInventoryItem* item = gInventory.getItem(*it); if (!item || item->getType() != LLAssetType::AT_LANDMARK) @@ -124,8 +124,6 @@ private: mInput->onLandmarkLoaded(lm); } } - - mAdded.clear(); } LLLocationInputCtrl* mInput; diff --git a/indra/newview/llpanelplaces.cpp b/indra/newview/llpanelplaces.cpp index 730df2ea23..8cd54204e8 100755 --- a/indra/newview/llpanelplaces.cpp +++ b/indra/newview/llpanelplaces.cpp @@ -168,8 +168,7 @@ public: protected: /*virtual*/ void done() { - mPlaces->showAddedLandmarkInfo(mAdded); - mAdded.clear(); + mPlaces->showAddedLandmarkInfo(gInventory.getAddedIDs()); } private: @@ -1100,9 +1099,9 @@ void LLPanelPlaces::changedGlobalPos(const LLVector3d &global_pos) updateVerbs(); } -void LLPanelPlaces::showAddedLandmarkInfo(const uuid_vec_t& items) +void LLPanelPlaces::showAddedLandmarkInfo(const uuid_set_t& items) { - for (uuid_vec_t::const_iterator item_iter = items.begin(); + for (uuid_set_t::const_iterator item_iter = items.begin(); item_iter != items.end(); ++item_iter) { diff --git a/indra/newview/llpanelplaces.h b/indra/newview/llpanelplaces.h index 85bdc2c4e1..b3bc248bd9 100755 --- a/indra/newview/llpanelplaces.h +++ b/indra/newview/llpanelplaces.h @@ -69,7 +69,7 @@ public: void changedGlobalPos(const LLVector3d &global_pos); // Opens landmark info panel when agent creates or receives landmark. - void showAddedLandmarkInfo(const uuid_vec_t& items); + void showAddedLandmarkInfo(const uuid_set_t& items); void setItem(LLInventoryItem* item); diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 167c33f3ff..64cbc82578 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -1001,7 +1001,12 @@ class LLOpenTaskOffer : public LLInventoryAddedObserver protected: /*virtual*/ void done() { - for (uuid_vec_t::iterator it = mAdded.begin(); it != mAdded.end();) + uuid_vec_t added; + for(uuid_set_t::const_iterator it = gInventory.getAddedIDs().begin(); it != gInventory.getAddedIDs().end(); ++it) + { + added.push_back(*it); + } + for (uuid_vec_t::iterator it = added.begin(); it != added.end();) { const LLUUID& item_uuid = *it; bool was_moved = false; @@ -1023,13 +1028,12 @@ protected: if (was_moved) { - it = mAdded.erase(it); + it = added.erase(it); } else ++it; } - open_inventory_offer(mAdded, ""); - mAdded.clear(); + open_inventory_offer(added, ""); } }; @@ -1038,8 +1042,12 @@ class LLOpenTaskGroupOffer : public LLInventoryAddedObserver protected: /*virtual*/ void done() { - open_inventory_offer(mAdded, "group_offer"); - mAdded.clear(); + uuid_vec_t added; + for(uuid_set_t::const_iterator it = gInventory.getAddedIDs().begin(); it != gInventory.getAddedIDs().end(); ++it) + { + added.push_back(*it); + } + open_inventory_offer(added, "group_offer"); gInventory.removeObserver(this); delete this; } |