diff options
Diffstat (limited to 'indra/newview/llfavoritesbar.cpp')
-rw-r--r--[-rwxr-xr-x] | indra/newview/llfavoritesbar.cpp | 52 |
1 files changed, 40 insertions, 12 deletions
diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp index 8f3eaaa207..d614d612ff 100755..100644 --- a/indra/newview/llfavoritesbar.cpp +++ b/indra/newview/llfavoritesbar.cpp @@ -655,11 +655,12 @@ void LLFavoritesBarCtrl::changed(U32 mask) LLInventoryModel::cat_array_t cats; LLIsType is_type(LLAssetType::AT_LANDMARK); gInventory.collectDescendentsIf(mFavoriteFolderId, cats, items, LLInventoryModel::EXCLUDE_TRASH, is_type); - + for (LLInventoryModel::item_array_t::iterator i = items.begin(); i != items.end(); ++i) { LLFavoritesOrderStorage::instance().getSLURL((*i)->getAssetUUID()); } + updateButtons(); if (!mItemsChangedTimer.getStarted()) { @@ -751,7 +752,11 @@ void LLFavoritesBarCtrl::updateButtons() if(mGetPrevItems) { - LLFavoritesOrderStorage::instance().mPrevFavorites = mItems; + for (LLInventoryModel::item_array_t::iterator it = mItems.begin(); it != mItems.end(); it++) + { + LLFavoritesOrderStorage::instance().mFavoriteNames[(*it)->getUUID()]= (*it)->getName(); + } + LLFavoritesOrderStorage::instance().mPrevFavorites = mItems; mGetPrevItems = false; } @@ -778,7 +783,7 @@ void LLFavoritesBarCtrl::updateButtons() const LLViewerInventoryItem *item = mItems[first_changed_item_index].get(); if (item) { - // an child's order and mItems should be same + // an child's order and mItems should be same if (button->getLandmarkId() != item->getUUID() // sort order has been changed || button->getLabelSelected() != item->getName() // favorite's name has been changed || button->getRect().mRight < rightest_point) // favbar's width has been changed @@ -964,6 +969,7 @@ BOOL LLFavoritesBarCtrl::collectFavoriteItems(LLInventoryModel::item_array_t &it { LLFavoritesOrderStorage::instance().setSortIndex((*i), ++sortField); } + LLFavoritesOrderStorage::instance().mSaveOnExit = true; } return TRUE; @@ -1525,10 +1531,10 @@ void LLFavoritesOrderStorage::destroyClass() { file.close(); LLFile::remove(filename); - if(mSaveOnExit) - { - LLFavoritesOrderStorage::instance().saveFavoritesRecord(true); - } + } + if(mSaveOnExit) + { + LLFavoritesOrderStorage::instance().saveFavoritesRecord(true); } } @@ -1617,7 +1623,7 @@ void LLFavoritesOrderStorage::removeFavoritesRecordOfUser() { LLSD user_llsd = fav_llsd[av_name.getUserName()]; - if (user_llsd.beginArray()->has("id")) + if ((user_llsd.beginArray()!= user_llsd.endArray()) && user_llsd.beginArray()->has("id")) { for (LLSD::array_iterator iter = user_llsd.beginArray();iter != user_llsd.endArray(); ++iter) { @@ -1783,10 +1789,30 @@ BOOL LLFavoritesOrderStorage::saveFavoritesRecord(bool pref_changed) gInventory.collectDescendentsIf(favorite_folder, cats, items, LLInventoryModel::EXCLUDE_TRASH, is_type); std::sort(items.begin(), items.end(), LLFavoritesSort()); + bool name_changed = false; + + for (LLInventoryModel::item_array_t::iterator it = items.begin(); it != items.end(); it++) + { + if(mFavoriteNames[(*it)->getUUID()] != ((*it)->getName())) + { + mFavoriteNames[(*it)->getUUID()] = (*it)->getName(); + name_changed = true; + } + } - if((items != mPrevFavorites) || pref_changed) + for (std::set<LLUUID>::iterator it = mMissingSLURLs.begin(); it != mMissingSLURLs.end(); it++) { - std::string filename = getStoredFavoritesFilename(); + slurls_map_t::iterator slurl_iter = mSLURLs.find(*it); + if (slurl_iter != mSLURLs.end()) + { + pref_changed = true; + break; + } + } + + if((items != mPrevFavorites) || name_changed || pref_changed) + { + std::string filename = getStoredFavoritesFilename(); if (!filename.empty()) { llifstream in_file; @@ -1804,6 +1830,7 @@ BOOL LLFavoritesOrderStorage::saveFavoritesRecord(bool pref_changed) LLSD user_llsd; S32 fav_iter = 0; + mMissingSLURLs.clear(); for (LLInventoryModel::item_array_t::iterator it = items.begin(); it != items.end(); it++) { LLSD value; @@ -1821,8 +1848,10 @@ BOOL LLFavoritesOrderStorage::saveFavoritesRecord(bool pref_changed) else { getSLURL((*it)->getAssetUUID()); + value["slurl"] = ""; + user_llsd[fav_iter] = value; mUpdateRequired = true; - return FALSE; + mMissingSLURLs.insert((*it)->getAssetUUID()); } } else @@ -1853,7 +1882,6 @@ BOOL LLFavoritesOrderStorage::saveFavoritesRecord(bool pref_changed) << "' at '" << filename << "' " << LL_ENDL; } } - mPrevFavorites = items; } |