From f3a43c74f9e5aae506814af2460507b6879a9bd5 Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Fri, 24 Sep 2021 15:28:25 +0300
Subject: SL-16063 FIXED The favorite landmark does not change after editing
 from another machine

---
 indra/newview/llfavoritesbar.cpp | 32 ++++++++++++++++++++++++++++----
 indra/newview/llfavoritesbar.h   |  6 ++++--
 2 files changed, 32 insertions(+), 6 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp
index 83b5bf3f25..2879d18577 100644
--- a/indra/newview/llfavoritesbar.cpp
+++ b/indra/newview/llfavoritesbar.cpp
@@ -763,6 +763,14 @@ void LLFavoritesBarCtrl::updateButtons()
 	    }
 	    LLFavoritesOrderStorage::instance().mPrevFavorites = mItems;
 		mGetPrevItems = false;
+
+		if (LLFavoritesOrderStorage::instance().isStorageUpdateNeeded())
+		{
+			if (!mItemsChangedTimer.getStarted())
+			{
+				mItemsChangedTimer.start();
+			}
+		}
 	}
 
 	const LLButton::Params& button_params = getButtonParams();
@@ -1640,7 +1648,6 @@ void LLFavoritesOrderStorage::load()
 			llifstream in_file;
 			in_file.open(filename.c_str());
 			LLSD fav_llsd;
-			LLSD user_llsd;
 			if (in_file.is_open())
 			{
 				LLSDSerialize::fromXML(fav_llsd, in_file);
@@ -1650,12 +1657,12 @@ void LLFavoritesOrderStorage::load()
 				in_file.close();
 				if (fav_llsd.isMap() && fav_llsd.has(gAgentUsername))
 				{
-					user_llsd = fav_llsd[gAgentUsername];
+					mStorageFavorites = fav_llsd[gAgentUsername];
 
 					S32 index = 0;
 					bool needs_validation = gSavedPerAccountSettings.getBOOL("ShowFavoritesOnLogin");
-					for (LLSD::array_iterator iter = user_llsd.beginArray();
-						iter != user_llsd.endArray(); ++iter)
+					for (LLSD::array_iterator iter = mStorageFavorites.beginArray();
+						iter != mStorageFavorites.endArray(); ++iter)
 					{
 						// Validation
 						LLUUID fv_id = iter->get("id").asUUID();
@@ -2040,6 +2047,23 @@ void LLFavoritesOrderStorage::showFavoritesOnLoginChanged(BOOL show)
 	}
 }
 
+bool LLFavoritesOrderStorage::isStorageUpdateNeeded()
+{
+	if (!mRecreateFavoriteStorage)
+	{
+		for (LLSD::array_iterator iter = mStorageFavorites.beginArray();
+			iter != mStorageFavorites.endArray(); ++iter)
+		{
+			if (mFavoriteNames[iter->get("id").asUUID()] != iter->get("name").asString())
+			{
+				mRecreateFavoriteStorage = true;
+				return true;
+			}
+		}
+	}
+	return false;
+}
+
 void AddFavoriteLandmarkCallback::fire(const LLUUID& inv_item_id)
 {
 	if (mTargetLandmarkId.isNull()) return;
diff --git a/indra/newview/llfavoritesbar.h b/indra/newview/llfavoritesbar.h
index 3bb940948b..ad315b7dc7 100644
--- a/indra/newview/llfavoritesbar.h
+++ b/indra/newview/llfavoritesbar.h
@@ -226,8 +226,11 @@ public:
 	BOOL saveFavoritesRecord(bool pref_changed = false);
 	void showFavoritesOnLoginChanged(BOOL show);
 
-	LLInventoryModel::item_array_t mPrevFavorites;
+	bool isStorageUpdateNeeded();
 
+	LLInventoryModel::item_array_t mPrevFavorites;
+	LLSD mStorageFavorites;
+	bool mRecreateFavoriteStorage;
 
 	const static S32 NO_INDEX;
 	static bool mSaveOnExit;
@@ -254,7 +257,6 @@ private:
 	slurls_map_t mSLURLs;
 	std::set<LLUUID> mMissingSLURLs;
 	bool mIsDirty;
-	bool mRecreateFavoriteStorage;
 
 	struct IsNotInFavorites
 	{
-- 
cgit v1.2.3