From 97a0108125ee3944ff3cde0f1ba4aeb21db4b2a9 Mon Sep 17 00:00:00 2001
From: Denis Serdjuk <dserduk@productengine.com>
Date: Thu, 29 Oct 2009 14:09:31 +0200
Subject: [PATCH] fixed bug EXT-1768	 Unable to store landmark attached to
 notecard into Landmarks

--HG--
branch : product-engine
---
 indra/newview/llviewertexteditor.cpp | 56 +++++++++++++++++++++++-----
 1 file changed, 47 insertions(+), 9 deletions(-)

diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp
index 65994dfb30..5c40f2a540 100644
--- a/indra/newview/llviewertexteditor.cpp
+++ b/indra/newview/llviewertexteditor.cpp
@@ -44,6 +44,9 @@
 #include "llinventory.h"
 #include "llinventorybridge.h"
 #include "llinventorymodel.h"
+#include "lllandmark.h"
+#include "lllandmarkactions.h"
+#include "lllandmarklist.h"
 #include "llmemorystream.h"
 #include "llmenugl.h"
 #include "llnotecard.h"
@@ -64,10 +67,47 @@
 #include "llviewertexturelist.h"
 #include "llviewerwindow.h"
 
-#include "llappviewer.h" // for gPacificDaylightTime
-
 static LLDefaultChildRegistry::Register<LLViewerTextEditor> r("text_editor");
 
+///-----------------------------------------------------------------------
+///  Class LLEmbeddedLandmarkCopied
+///-----------------------------------------------------------------------
+class LLEmbeddedLandmarkCopied: public LLInventoryCallback
+{
+public:
+
+	LLEmbeddedLandmarkCopied(){}
+	void fire(const LLUUID& inv_item)
+	{
+		showInfo(inv_item);
+	}
+	static void showInfo(const LLUUID& landmark_inv_id)
+	{
+		LLSD key;
+		key["type"] = "landmark";
+		key["id"] = landmark_inv_id;
+		LLSideTray::getInstance()->showPanel("panel_places", key);
+	}
+	static void processForeignLandmark(LLLandmark* landmark,
+			const LLUUID& object_id, const LLUUID& notecard_inventory_id,
+			LLInventoryItem* item)
+	{
+		LLVector3d global_pos;
+		landmark->getGlobalPos(global_pos);
+		LLViewerInventoryItem* agent_lanmark =
+				LLLandmarkActions::findLandmarkForGlobalPos(global_pos);
+
+		if (agent_lanmark)
+		{
+			showInfo(agent_lanmark->getUUID());
+		}
+		else
+		{
+			LLPointer<LLEmbeddedLandmarkCopied> cb = new LLEmbeddedLandmarkCopied();
+			copy_inventory_from_notecard(object_id, notecard_inventory_id, item, gInventoryCallbacks.registerCB(cb));
+		}
+	}
+};
 ///----------------------------------------------------------------------------
 /// Class LLEmbeddedNotecardOpener
 ///----------------------------------------------------------------------------
@@ -1099,14 +1139,12 @@ void LLViewerTextEditor::openEmbeddedLandmark( LLInventoryItem* item, llwchar wc
 	if (!item)
 		return;
 
-	LLSD key;
-	key["type"] = "landmark";
-	key["id"] = item->getUUID();
-
-	LLPanelPlaces *panel = dynamic_cast<LLPanelPlaces*>(LLSideTray::getInstance()->showPanel("panel_places", key));
-	if (panel)
+	LLLandmark* landmark = gLandmarkList.getAsset(item->getAssetUUID(),
+			boost::bind(&LLEmbeddedLandmarkCopied::processForeignLandmark, _1, mObjectID, mNotecardInventoryID, item));
+	if (landmark)
 	{
-		panel->setItem(item);
+		LLEmbeddedLandmarkCopied::processForeignLandmark(landmark, mObjectID,
+				mNotecardInventoryID, item);
 	}
 }
 
-- 
GitLab