From 4fcf31e20319fbbfdd76240b351753e5de726eb5 Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Fri, 15 Nov 2019 17:58:32 +0200
Subject: [PATCH] SL-12287 FIXED [Project Copy/Paste] Unable to paste texture
 from "local" storage

---
 indra/newview/lllocalbitmaps.cpp | 14 ++++++++++++++
 indra/newview/lllocalbitmaps.h   |  2 ++
 indra/newview/llpanelface.cpp    | 11 +++++++++--
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/indra/newview/lllocalbitmaps.cpp b/indra/newview/lllocalbitmaps.cpp
index b8bde39bd10..5d301748c7d 100644
--- a/indra/newview/lllocalbitmaps.cpp
+++ b/indra/newview/lllocalbitmaps.cpp
@@ -1038,6 +1038,20 @@ LLUUID LLLocalBitmapMgr::getWorldID(LLUUID tracking_id)
 	return world_id;
 }
 
+bool LLLocalBitmapMgr::isLocalBitmap(LLUUID texture_id)
+{
+    for (local_list_iter iter = mBitmapList.begin(); iter != mBitmapList.end(); iter++)
+    {
+        LLLocalBitmap* unit = *iter;
+        if (unit->getWorldID() == texture_id)
+        {
+            return true;
+        }
+    }
+
+    return false;
+}
+
 std::string LLLocalBitmapMgr::getFilename(LLUUID tracking_id)
 {
 	std::string filename = "";
diff --git a/indra/newview/lllocalbitmaps.h b/indra/newview/lllocalbitmaps.h
index f6cc1e919e0..c15ba9caa45 100644
--- a/indra/newview/lllocalbitmaps.h
+++ b/indra/newview/lllocalbitmaps.h
@@ -122,6 +122,8 @@ class LLLocalBitmapMgr : public LLSingleton<LLLocalBitmapMgr>
 	LLUUID       getWorldID(LLUUID tracking_id);
 	std::string  getFilename(LLUUID tracking_id);
 
+	bool         isLocalBitmap(LLUUID texture_id);
+
 	void         feedScrollList(LLScrollListCtrl* ctrl);
 	void         doUpdates();
 	void         setNeedsRebake();
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index e19e3f13ee4..da471b0b62d 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -2923,8 +2923,15 @@ void LLPanelFace::onCopyFaces()
                     // Doesn't support local images!
                     if (id.isNull() || !LLPanelObject::canCopyTexture(id))
                     {
-                        te_data["te"].erase("imageid");
-                        te_data["te"]["imageid"] = LLUUID(gSavedSettings.getString( "DefaultObjectTexture" ));
+                        if (LLLocalBitmapMgr::getInstance()->isLocalBitmap(id))
+                        {
+                            te_data["te"]["imageid"] = id;
+                        }
+                        else
+                        {
+                            te_data["te"].erase("imageid");
+                            te_data["te"]["imageid"] = LLUUID(gSavedSettings.getString("DefaultObjectTexture"));
+                        }
                         te_data["te"]["itemfullperm"] = true;
                     }
                     else
-- 
GitLab