diff options
author | Steven Bennetts <steve@lindenlab.com> | 2008-08-12 17:29:50 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2008-08-12 17:29:50 +0000 |
commit | 80be4c1d2d73982ea2df6dd7ef3fc3465416c882 (patch) | |
tree | 9c5958572368be494b6302db8b03967a2c67b7ad /indra/llimage/llimagejpeg.cpp | |
parent | a09f7d41efdb945755efaeb07f7418c1f6e2a78b (diff) |
QAR-767 Combined maint-render-7 and maint-viewer-9 merge
merge release@93398 viewer-merge-1@94007 -> release
dataserver-is-deprecated
Diffstat (limited to 'indra/llimage/llimagejpeg.cpp')
-rw-r--r-- | indra/llimage/llimagejpeg.cpp | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/indra/llimage/llimagejpeg.cpp b/indra/llimage/llimagejpeg.cpp index 1bddd7a051..aab19aa261 100644 --- a/indra/llimage/llimagejpeg.cpp +++ b/indra/llimage/llimagejpeg.cpp @@ -35,6 +35,7 @@ #include "llerror.h" +jmp_buf LLImageJPEG::sSetjmpBuffer ; LLImageJPEG::LLImageJPEG(S32 quality) : LLImageFormatted(IMG_CODEC_JPEG), @@ -42,8 +43,6 @@ LLImageJPEG::LLImageJPEG(S32 quality) mOutputBufferSize( 0 ), mEncodeQuality( quality ) // on a scale from 1 to 100 { - // Including in initializer list above generates warning on VC2005 - memset(mSetjmpBuffer, 0, sizeof(mSetjmpBuffer)); } LLImageJPEG::~LLImageJPEG() @@ -78,7 +77,16 @@ BOOL LLImageJPEG::updateData() jerr.error_exit = &LLImageJPEG::errorExit; // Error exit handler: does not return to caller jerr.emit_message = &LLImageJPEG::errorEmitMessage; // Conditionally emit a trace or warning message jerr.output_message = &LLImageJPEG::errorOutputMessage; // Routine that actually outputs a trace or error message - + + // + //try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error + //so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao + // + if(setjmp(sSetjmpBuffer)) + { + jpeg_destroy_decompress(&cinfo); + return FALSE; + } try { // Now we can initialize the JPEG decompression object. @@ -210,7 +218,15 @@ BOOL LLImageJPEG::decode(LLImageRaw* raw_image, F32 decode_time) jerr.emit_message = &LLImageJPEG::errorEmitMessage; // Conditionally emit a trace or warning message jerr.output_message = &LLImageJPEG::errorOutputMessage; // Routine that actually outputs a trace or error message - + // + //try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error + //so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao + // + if(setjmp(sSetjmpBuffer)) + { + jpeg_destroy_decompress(&cinfo); + return FALSE; + } try { // Now we can initialize the JPEG decompression object. @@ -404,7 +420,7 @@ void LLImageJPEG::errorExit( j_common_ptr cinfo ) jpeg_destroy(cinfo); // Return control to the setjmp point - throw 1; + longjmp(sSetjmpBuffer, 1) ; } // Decide whether to emit a trace or warning message. @@ -502,8 +518,11 @@ BOOL LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time ) jerr.emit_message = &LLImageJPEG::errorEmitMessage; // Conditionally emit a trace or warning message jerr.output_message = &LLImageJPEG::errorOutputMessage; // Routine that actually outputs a trace or error message - // Establish the setjmp return context mSetjmpBuffer. Used by library to abort. - if( setjmp(mSetjmpBuffer) ) + // + //try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error + //so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao + // + if( setjmp(sSetjmpBuffer) ) { // If we get here, the JPEG code has signaled an error. // We need to clean up the JPEG object, close the input file, and return. |