From 16b1af72b2c5f723a84f37b9278ff3f2bdc17e7d Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Fri, 22 Jan 2010 20:02:10 +0200
Subject: Fixed (EXT-4589) 'About Land' floater loose information after user
 quit Place Profile - Fixed Places panel not to remove parcel selection when
 it is used by "About Land" floater.

--HG--
branch : product-engine
---
 indra/newview/llpanelplaceinfo.cpp    |  19 -----
 indra/newview/llpanelplaceinfo.h      |   1 -
 indra/newview/llpanelplaceprofile.cpp |  19 +++++
 indra/newview/llpanelplaceprofile.h   |   2 +
 indra/newview/llpanelplaces.cpp       | 154 ++++++++++++++++++++--------------
 indra/newview/llpanelplaces.h         |   2 +
 6 files changed, 114 insertions(+), 83 deletions(-)

diff --git a/indra/newview/llpanelplaceinfo.cpp b/indra/newview/llpanelplaceinfo.cpp
index b80eb9db38..3121aca05f 100644
--- a/indra/newview/llpanelplaceinfo.cpp
+++ b/indra/newview/llpanelplaceinfo.cpp
@@ -265,25 +265,6 @@ void LLPanelPlaceInfo::reshape(S32 width, S32 height, BOOL called_from_parent)
 	}
 }
 
-// virtual
-void LLPanelPlaceInfo::handleVisibilityChange(BOOL new_visibility)
-{
-	LLPanel::handleVisibilityChange(new_visibility);
-
-	LLViewerParcelMgr* parcel_mgr = LLViewerParcelMgr::getInstance();
-	if (!parcel_mgr)
-		return;
-
-	// Remove land selection when panel hides.
-	if (!new_visibility)
-	{
-		if (!parcel_mgr->selectionEmpty())
-		{
-			parcel_mgr->deselectLand();
-		}
-	}
-}
-
 void LLPanelPlaceInfo::createPick(const LLVector3d& pos_global, LLPanelPickEdit* pick_panel)
 {
 	std::string region_name = mRegionName->getText();
diff --git a/indra/newview/llpanelplaceinfo.h b/indra/newview/llpanelplaceinfo.h
index 7dfc7b2444..3091f7ed24 100644
--- a/indra/newview/llpanelplaceinfo.h
+++ b/indra/newview/llpanelplaceinfo.h
@@ -94,7 +94,6 @@ public:
 	/*virtual*/ void processParcelInfo(const LLParcelData& parcel_data);
 
 	/*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
-	/*virtual*/ void handleVisibilityChange (BOOL new_visibility);
 
 	// Create a pick for the location specified
 	// by global_pos.
diff --git a/indra/newview/llpanelplaceprofile.cpp b/indra/newview/llpanelplaceprofile.cpp
index 402d50ba9c..d892e2885b 100644
--- a/indra/newview/llpanelplaceprofile.cpp
+++ b/indra/newview/llpanelplaceprofile.cpp
@@ -257,6 +257,25 @@ void LLPanelPlaceProfile::processParcelInfo(const LLParcelData& parcel_data)
 	}
 }
 
+// virtual
+void LLPanelPlaceProfile::handleVisibilityChange(BOOL new_visibility)
+{
+	LLPanel::handleVisibilityChange(new_visibility);
+
+	LLViewerParcelMgr* parcel_mgr = LLViewerParcelMgr::getInstance();
+	if (!parcel_mgr)
+		return;
+
+	// Remove land selection when panel hides.
+	if (!new_visibility)
+	{
+		if (!parcel_mgr->selectionEmpty())
+		{
+			parcel_mgr->deselectUnused();
+		}
+	}
+}
+
 void LLPanelPlaceProfile::displaySelectedParcelInfo(LLParcel* parcel,
 													LLViewerRegion* region,
 													const LLVector3d& pos_global,
diff --git a/indra/newview/llpanelplaceprofile.h b/indra/newview/llpanelplaceprofile.h
index 8c30ca92fb..8ca9526875 100644
--- a/indra/newview/llpanelplaceprofile.h
+++ b/indra/newview/llpanelplaceprofile.h
@@ -52,6 +52,8 @@ public:
 
 	/*virtual*/ void processParcelInfo(const LLParcelData& parcel_data);
 
+	/*virtual*/ void handleVisibilityChange(BOOL new_visibility);
+
 	// Displays information about the currently selected parcel
 	// without sending a request to the server.
 	// If is_current_parcel true shows "You Are Here" banner.
diff --git a/indra/newview/llpanelplaces.cpp b/indra/newview/llpanelplaces.cpp
index b037674c37..306e08e7ec 100644
--- a/indra/newview/llpanelplaces.cpp
+++ b/indra/newview/llpanelplaces.cpp
@@ -289,89 +289,92 @@ BOOL LLPanelPlaces::postBuild()
 
 void LLPanelPlaces::onOpen(const LLSD& key)
 {
-	if(!mPlaceProfile || !mLandmarkInfo || key.size() == 0)
+	if (!mPlaceProfile || !mLandmarkInfo)
 		return;
 
-	mFilterEditor->clear();
-	onFilterEdit("", false);
-
-	mPlaceInfoType = key["type"].asString();
-	mPosGlobal.setZero();
-	mItem = NULL;
-	isLandmarkEditModeOn = false;
-	togglePlaceInfoPanel(TRUE);
-
-	if (mPlaceInfoType == AGENT_INFO_TYPE)
-	{
-		mPlaceProfile->setInfoType(LLPanelPlaceInfo::AGENT);
-	}
-	else if (mPlaceInfoType == CREATE_LANDMARK_INFO_TYPE)
+	if (key.size() != 0)
 	{
-		mLandmarkInfo->setInfoType(LLPanelPlaceInfo::CREATE_LANDMARK);
+		mFilterEditor->clear();
+		onFilterEdit("", false);
 
-		if (key.has("x") && key.has("y") && key.has("z"))
+		mPlaceInfoType = key["type"].asString();
+		mPosGlobal.setZero();
+		mItem = NULL;
+		isLandmarkEditModeOn = false;
+		togglePlaceInfoPanel(TRUE);
+
+		if (mPlaceInfoType == AGENT_INFO_TYPE)
 		{
-			mPosGlobal = LLVector3d(key["x"].asReal(),
-									key["y"].asReal(),
-									key["z"].asReal());
+			mPlaceProfile->setInfoType(LLPanelPlaceInfo::AGENT);
 		}
-		else
+		else if (mPlaceInfoType == CREATE_LANDMARK_INFO_TYPE)
 		{
-			mPosGlobal = gAgent.getPositionGlobal();
-		}
-
-		mLandmarkInfo->displayParcelInfo(LLUUID(), mPosGlobal);
+			mLandmarkInfo->setInfoType(LLPanelPlaceInfo::CREATE_LANDMARK);
 
-		// Disable Save button because there is no item to save yet.
-		// The button will be enabled in onLandmarkLoaded callback.
-		mSaveBtn->setEnabled(FALSE);
-	}
-	else if (mPlaceInfoType == LANDMARK_INFO_TYPE)
-	{
-		mLandmarkInfo->setInfoType(LLPanelPlaceInfo::LANDMARK);
+			if (key.has("x") && key.has("y") && key.has("z"))
+			{
+				mPosGlobal = LLVector3d(key["x"].asReal(),
+										key["y"].asReal(),
+										key["z"].asReal());
+			}
+			else
+			{
+				mPosGlobal = gAgent.getPositionGlobal();
+			}
 
-		LLInventoryItem* item = gInventory.getItem(key["id"].asUUID());
-		if (!item)
-			return;
+			mLandmarkInfo->displayParcelInfo(LLUUID(), mPosGlobal);
 
-		setItem(item);
-	}
-	else if (mPlaceInfoType == REMOTE_PLACE_INFO_TYPE)
-	{
-		if (key.has("id"))
+			// Disable Save button because there is no item to save yet.
+			// The button will be enabled in onLandmarkLoaded callback.
+			mSaveBtn->setEnabled(FALSE);
+		}
+		else if (mPlaceInfoType == LANDMARK_INFO_TYPE)
 		{
-			LLUUID parcel_id = key["id"].asUUID();
-			mPlaceProfile->setParcelID(parcel_id);
+			mLandmarkInfo->setInfoType(LLPanelPlaceInfo::LANDMARK);
 
-			// query the server to get the global 3D position of this
-			// parcel - we need this for teleport/mapping functions.
-			mRemoteParcelObserver->setParcelID(parcel_id);
+			LLInventoryItem* item = gInventory.getItem(key["id"].asUUID());
+			if (!item)
+				return;
+
+			setItem(item);
 		}
-		else
+		else if (mPlaceInfoType == REMOTE_PLACE_INFO_TYPE)
 		{
-			mPosGlobal = LLVector3d(key["x"].asReal(),
-									key["y"].asReal(),
-									key["z"].asReal());
-			mPlaceProfile->displayParcelInfo(LLUUID(), mPosGlobal);
+			if (key.has("id"))
+			{
+				LLUUID parcel_id = key["id"].asUUID();
+				mPlaceProfile->setParcelID(parcel_id);
+
+				// query the server to get the global 3D position of this
+				// parcel - we need this for teleport/mapping functions.
+				mRemoteParcelObserver->setParcelID(parcel_id);
+			}
+			else
+			{
+				mPosGlobal = LLVector3d(key["x"].asReal(),
+										key["y"].asReal(),
+										key["z"].asReal());
+				mPlaceProfile->displayParcelInfo(LLUUID(), mPosGlobal);
+			}
+
+			mPlaceProfile->setInfoType(LLPanelPlaceInfo::PLACE);
 		}
+		else if (mPlaceInfoType == TELEPORT_HISTORY_INFO_TYPE)
+		{
+			S32 index = key["id"].asInteger();
 
-		mPlaceProfile->setInfoType(LLPanelPlaceInfo::PLACE);
-	}
-	else if (mPlaceInfoType == TELEPORT_HISTORY_INFO_TYPE)
-	{
-		S32 index = key["id"].asInteger();
+			const LLTeleportHistoryStorage::slurl_list_t& hist_items =
+						LLTeleportHistoryStorage::getInstance()->getItems();
 
-		const LLTeleportHistoryStorage::slurl_list_t& hist_items =
-					LLTeleportHistoryStorage::getInstance()->getItems();
+			mPosGlobal = hist_items[index].mGlobalPos;
 
-		mPosGlobal = hist_items[index].mGlobalPos;
+			mPlaceProfile->setInfoType(LLPanelPlaceInfo::TELEPORT_HISTORY);
+			mPlaceProfile->displayParcelInfo(LLUUID(), mPosGlobal);
+		}
 
-		mPlaceProfile->setInfoType(LLPanelPlaceInfo::TELEPORT_HISTORY);
-		mPlaceProfile->displayParcelInfo(LLUUID(), mPosGlobal);
+		updateVerbs();
 	}
 
-	updateVerbs();
-
 	LLViewerParcelMgr* parcel_mgr = LLViewerParcelMgr::getInstance();
 	if (!parcel_mgr)
 		return;
@@ -388,9 +391,12 @@ void LLPanelPlaces::onOpen(const LLSD& key)
 	{
 		parcel_mgr->removeObserver(mParcelObserver);
 
+		// Clear the reference to selection to allow its removal in deselectUnused().
+		mParcel.clear();
+
 		if (!parcel_mgr->selectionEmpty())
 		{
-			parcel_mgr->deselectLand();
+			parcel_mgr->deselectUnused();
 		}
 	}
 }
@@ -826,6 +832,14 @@ void LLPanelPlaces::togglePlaceInfoPanel(BOOL visible)
 
 			mLandmarkInfo->setVisible(FALSE);
 		}
+		else if (mPlaceInfoType == AGENT_INFO_TYPE)
+		{
+			LLViewerParcelMgr::getInstance()->removeObserver(mParcelObserver);
+
+			// Clear reference to parcel selection when closing place profile panel.
+			// LLViewerParcelMgr removes the selection if it has 1 reference to it.
+			mParcel.clear();
+		}
 	}
 	else if (mPlaceInfoType == CREATE_LANDMARK_INFO_TYPE ||
 			 mPlaceInfoType == LANDMARK_INFO_TYPE)
@@ -858,6 +872,20 @@ void LLPanelPlaces::togglePlaceInfoPanel(BOOL visible)
 	}
 }
 
+// virtual
+void LLPanelPlaces::handleVisibilityChange(BOOL new_visibility)
+{
+	LLPanel::handleVisibilityChange(new_visibility);
+
+	if (!new_visibility && mPlaceInfoType == AGENT_INFO_TYPE)
+	{
+		LLViewerParcelMgr::getInstance()->removeObserver(mParcelObserver);
+
+		// Clear reference to parcel selection when closing places panel.
+		mParcel.clear();
+	}
+}
+
 void LLPanelPlaces::changedParcelSelection()
 {
 	if (!mPlaceProfile)
diff --git a/indra/newview/llpanelplaces.h b/indra/newview/llpanelplaces.h
index 27b5911ebb..0eba7f3afc 100644
--- a/indra/newview/llpanelplaces.h
+++ b/indra/newview/llpanelplaces.h
@@ -97,6 +97,8 @@ private:
 	void togglePickPanel(BOOL visible);
 	void togglePlaceInfoPanel(BOOL visible);
 
+	/*virtual*/ void handleVisibilityChange(BOOL new_visibility);
+
 	void updateVerbs();
 
 	LLPanelPlaceInfo* getCurrentInfoPanel();
-- 
cgit v1.2.3