Changeset 117 for trunk/Lucide


Ignore:
Timestamp:
Sep 3, 2006, 6:34:01 PM (15 years ago)
Author:
Eugene Romanenko
Message:

Added custom libjpeg error handler into ljjpeg plugin (closes #80)

Location:
trunk/Lucide
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Lucide/SOURCE/plugins/lujpeg/lujpeg.cpp

    r94 r117  
    5959#include <stdio.h>
    6060#include <string.h>
     61#include <setjmp.h>
    6162#include <jpeglib.h>
    6263
     
    9697};
    9798
     99struct lujpeg_error_mgr
     100{
     101    struct jpeg_error_mgr jem;
     102    jmp_buf setjmp_buffer;
     103};
     104
     105METHODDEF(void) lujpeg_error_exit( j_common_ptr cinfo )
     106{
     107    lujpeg_error_mgr *err = (lujpeg_error_mgr *)cinfo->err;
     108    char buffer[ JMSG_LENGTH_MAX ];
     109    (*cinfo->err->format_message)( cinfo, buffer );
     110    fprintf( stderr, "JPEG decoding error:\n%s\n", buffer );
     111    longjmp( err->setjmp_buffer, 1 );
     112}
     113
    98114
    99115SOM_Scope boolean  SOMLINK loadFile(LuJpegDocument *somSelf,
     
    111127    short bpp = getBpp( somSelf, ev );
    112128    jpeg_decompress_struct cinfo;
    113     jpeg_error_mgr jerr;
    114     cinfo.err = jpeg_std_error( &jerr );
     129    lujpeg_error_mgr ljerr;
     130    cinfo.err = jpeg_std_error( &ljerr.jem );
     131    ljerr.jem.error_exit = lujpeg_error_exit;
     132    if ( setjmp( ljerr.setjmp_buffer ) ) {
     133        // If we get here, the JPEG code has signaled an error.
     134        jpeg_destroy_decompress( &cinfo );
     135        fclose( infile );
     136        return FALSE;
     137    }
     138
    115139    jpeg_create_decompress( &cinfo );
    116140    jpeg_stdio_src( &cinfo, infile );
  • trunk/Lucide/changelog

    r116 r117  
    55  - Added 'Traditional Chinese (Taiwan)' NLS-file, updated German and
    66    Swedish NLS-files.
     7  - Fixed crash on PDF load during fonts enumeration on font files which
     8    FreeType doesn't understand (closed ticket #83)
     9  - Prevent Lucide from close on broken JPEGs (closed ticket #80)
    710
    811
Note: See TracChangeset for help on using the changeset viewer.