From 7ea4303aa25960a3aa0971999725a0ca1bcfdec4 Mon Sep 17 00:00:00 2001
From: Mnikolenko ProductEngine <mnikolenko@productengine.com>
Date: Mon, 26 Oct 2015 12:25:21 +0200
Subject: MAINT-5760 Save favorite landmarks after renaming

---
 indra/newview/llfavoritesbar.cpp | 25 ++++++++++++++++++++-----
 indra/newview/llfavoritesbar.h   |  1 +
 2 files changed, 21 insertions(+), 5 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp
index 8f3eaaa207..d6b86cd746 100755
--- 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
@@ -1783,10 +1788,20 @@ 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)
+	if((items != mPrevFavorites) || name_changed || pref_changed)
 	{
-		std::string filename = getStoredFavoritesFilename();
+	    std::string filename = getStoredFavoritesFilename();
 		if (!filename.empty())
 		{
 			llifstream in_file;
diff --git a/indra/newview/llfavoritesbar.h b/indra/newview/llfavoritesbar.h
index 66fc8b2ae7..846d62227a 100755
--- a/indra/newview/llfavoritesbar.h
+++ b/indra/newview/llfavoritesbar.h
@@ -218,6 +218,7 @@ public:
 	const static S32 NO_INDEX;
 	static bool mSaveOnExit;
 	bool mUpdateRequired;
+	std::map<LLUUID,std::string> mFavoriteNames;
 
 private:
 	friend class LLSingleton<LLFavoritesOrderStorage>;
-- 
cgit v1.2.3