summaryrefslogtreecommitdiff
path: root/indra/llimage/llimagepng.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llimage/llimagepng.cpp')
-rw-r--r--indra/llimage/llimagepng.cpp46
1 files changed, 31 insertions, 15 deletions
diff --git a/indra/llimage/llimagepng.cpp b/indra/llimage/llimagepng.cpp
index 29a86f77f6..4d081ce169 100644
--- a/indra/llimage/llimagepng.cpp
+++ b/indra/llimage/llimagepng.cpp
@@ -27,6 +27,7 @@
#include "linden_common.h"
#include "stdtypes.h"
#include "llerror.h"
+#include "llexception.h"
#include "llimage.h"
#include "llpngwrapper.h"
@@ -51,30 +52,45 @@ bool LLImagePNG::updateData()
{
resetLastError();
- // Check to make sure that this instance has been initialized with data
- if (!getData() || (0 == getDataSize()))
+ try
{
- setLastError("Uninitialized instance of LLImagePNG");
- return false;
+ // Check to make sure that this instance has been initialized with data
+ if (!getData() || (0 == getDataSize()))
+ {
+ setLastError("Uninitialized instance of LLImagePNG");
+ return false;
+ }
+
+ // Decode the PNG data and extract sizing information
+ LLPngWrapper pngWrapper;
+ if (!pngWrapper.isValidPng(getData()))
+ {
+ setLastError("LLImagePNG data does not have a valid PNG header!");
+ return false;
+ }
+
+ LLPngWrapper::ImageInfo infop;
+ if (!pngWrapper.readPng(getData(), getDataSize(), NULL, &infop))
+ {
+ setLastError(pngWrapper.getErrorMessage());
+ return false;
+ }
+
+ setSize(infop.mWidth, infop.mHeight, infop.mComponents);
}
-
- // Decode the PNG data and extract sizing information
- LLPngWrapper pngWrapper;
- if (!pngWrapper.isValidPng(getData()))
+ catch (const LLContinueError& msg)
{
- setLastError("LLImagePNG data does not have a valid PNG header!");
+ setLastError(msg.what());
+ LOG_UNHANDLED_EXCEPTION("");
return false;
}
-
- LLPngWrapper::ImageInfo infop;
- if (! pngWrapper.readPng(getData(), getDataSize(), NULL, &infop))
+ catch (...)
{
- setLastError(pngWrapper.getErrorMessage());
+ setLastError("LLImagePNG");
+ LOG_UNHANDLED_EXCEPTION("");
return false;
}
- setSize(infop.mWidth, infop.mHeight, infop.mComponents);
-
return true;
}