From 0b6c9c50c3049eb75a0305376d067bf8982e184d Mon Sep 17 00:00:00 2001
From: Maxim Nikolenko <maximnproductengine@lindenlab.com>
Date: Mon, 21 Aug 2023 23:55:00 +0300
Subject: SL-20173 show warning notification when trying to add invalid files
 as local texture

---
 indra/llimage/llimagedimensionsinfo.cpp              |  3 +++
 indra/llimage/llimagedimensionsinfo.h                |  7 +++++++
 indra/newview/lllocalbitmaps.cpp                     |  3 +++
 indra/newview/skins/default/xui/en/notifications.xml | 10 +++++++++-
 4 files changed, 22 insertions(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/llimage/llimagedimensionsinfo.cpp b/indra/llimage/llimagedimensionsinfo.cpp
index 97b543f3b6..5756ddb32b 100644
--- a/indra/llimage/llimagedimensionsinfo.cpp
+++ b/indra/llimage/llimagedimensionsinfo.cpp
@@ -90,6 +90,7 @@ bool LLImageDimensionsInfo::getImageDimensionsBmp()
 	if (signature[0] != 'B' || signature[1] != 'M')
 	{
 		LL_WARNS() << "Not a BMP" << LL_ENDL;
+        mWarning = "IncorrectFormat";
 		return false;
 	}
 
@@ -140,6 +141,7 @@ bool LLImageDimensionsInfo::getImageDimensionsPng()
 	if (memcmp(signature, png_magic, PNG_MAGIC_SIZE) != 0)
 	{
 		LL_WARNS() << "Not a PNG" << LL_ENDL;
+        mWarning = "IncorrectFormat";
 		return false;
 	}
 
@@ -183,6 +185,7 @@ bool LLImageDimensionsInfo::getImageDimensionsJpeg()
 	if (memcmp(signature, jpeg_magic, JPEG_MAGIC_SIZE) != 0)
 	{
 		LL_WARNS() << "Not a JPEG" << LL_ENDL;
+        mWarning = "IncorrectFormat";
 		return false;
 	}
 	fseek(fp, 0, SEEK_SET); // go back to start of the file
diff --git a/indra/llimage/llimagedimensionsinfo.h b/indra/llimage/llimagedimensionsinfo.h
index 8f716c5d02..ade283bb85 100644
--- a/indra/llimage/llimagedimensionsinfo.h
+++ b/indra/llimage/llimagedimensionsinfo.h
@@ -55,6 +55,12 @@ public:
 	{
 		return mLastError;
 	}
+
+    const std::string& getWarningName()
+    {
+        return mWarning;
+    }
+
 protected:
 
 	void clean()
@@ -129,6 +135,7 @@ protected:
 	std::string mSrcFilename;
 
 	std::string mLastError;
+    std::string mWarning;
 
 	U8* mData;
 
diff --git a/indra/newview/lllocalbitmaps.cpp b/indra/newview/lllocalbitmaps.cpp
index de8db69e19..72ef365a6d 100644
--- a/indra/newview/lllocalbitmaps.cpp
+++ b/indra/newview/lllocalbitmaps.cpp
@@ -982,6 +982,9 @@ bool LLLocalBitmapMgr::checkTextureDimensions(std::string filename)
 	LLImageDimensionsInfo image_info;
 	if (!image_info.load(filename,codec))
 	{
+        LLSD args;
+        args["NAME"] = gDirUtilp->getBaseFileName(filename);
+        LLNotificationsUtil::add(image_info.getWarningName(), args);
 		return false;
 	}
 
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index a216ef7c0d..a4b73879b8 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -11986,5 +11986,13 @@ Would you like to save them first?
        notext="No"
        yestext="Yes"/>
   </notification>
-    
+
+  <notification
+   icon="notifytip.tga"
+   name="IncorrectFormat"
+   priority="high"
+   type="notifytip">
+Unable to upload &apos;[NAME]&apos; due to the following reason: incorrect image format.
+  </notification>
+
 </notifications>
-- 
cgit v1.2.3