don't crash when loading images with verbose==false (patch 1449823)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38513 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-04-02 01:27:36 +00:00
parent 1819a5c1ac
commit ef25e5a4c8

View File

@@ -163,12 +163,22 @@ CPP_METHODDEF(void) wx_error_exit (j_common_ptr cinfo)
/* Always display the message. */ /* Always display the message. */
/* We could postpone this until after returning, if we chose. */ /* We could postpone this until after returning, if we chose. */
if (cinfo->err->output_message) (*cinfo->err->output_message) (cinfo); (*cinfo->err->output_message) (cinfo);
/* Return control to the setjmp point */ /* Return control to the setjmp point */
longjmp(myerr->setjmp_buffer, 1); longjmp(myerr->setjmp_buffer, 1);
} }
/*
* This will replace the standard output_message method when the user
* wants us to be silent (verbose==false). We must have such method instead of
* simply using NULL for cinfo->err->output_message because it's called
* unconditionally from within libjpeg when there's "garbage input".
*/
CPP_METHODDEF(void) wx_ignore_message (j_common_ptr WXUNUSED(cinfo))
{
}
void wx_jpeg_io_src( j_decompress_ptr cinfo, wxInputStream& infile ) void wx_jpeg_io_src( j_decompress_ptr cinfo, wxInputStream& infile )
{ {
wx_src_ptr src; wx_src_ptr src;
@@ -210,7 +220,8 @@ bool wxJPEGHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbos
cinfo.err = jpeg_std_error( &jerr.pub ); cinfo.err = jpeg_std_error( &jerr.pub );
jerr.pub.error_exit = wx_error_exit; jerr.pub.error_exit = wx_error_exit;
if (!verbose) cinfo.err->output_message=NULL; if (!verbose)
cinfo.err->output_message = wx_ignore_message;
/* Establish the setjmp return context for wx_error_exit to use. */ /* Establish the setjmp return context for wx_error_exit to use. */
if (setjmp(jerr.setjmp_buffer)) { if (setjmp(jerr.setjmp_buffer)) {
@@ -323,7 +334,8 @@ bool wxJPEGHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbo
cinfo.err = jpeg_std_error(&jerr.pub); cinfo.err = jpeg_std_error(&jerr.pub);
jerr.pub.error_exit = wx_error_exit; jerr.pub.error_exit = wx_error_exit;
if (!verbose) cinfo.err->output_message=NULL; if (!verbose)
cinfo.err->output_message = wx_ignore_message;
/* Establish the setjmp return context for wx_error_exit to use. */ /* Establish the setjmp return context for wx_error_exit to use. */
if (setjmp(jerr.setjmp_buffer)) if (setjmp(jerr.setjmp_buffer))