SL-20173 show warning notification when trying to add invalid files as local texture

master
Maxim Nikolenko 2023-08-21 23:55:00 +03:00 committed by GitHub
parent b07a9cfec3
commit 0b6c9c50c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 1 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;
}

View File

@ -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>