X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7beb59f36c016d27cf8949eb8c0d38fc63ad536a..ecd20d4a916884895dcd8873a9f1156e34f4ac89:/src/common/imagpng.cpp diff --git a/src/common/imagpng.cpp b/src/common/imagpng.cpp index f3fe5cbce8..54c3ac8819 100644 --- a/src/common/imagpng.cpp +++ b/src/common/imagpng.cpp @@ -175,28 +175,16 @@ void PNGLINKAGEMODE wx_PNG_stream_writer( png_structp png_ptr, png_bytep data, // from pngerror.c // so that the libpng doesn't send anything on stderr void -PNGLINKAGEMODE wx_png_error(png_structp png_ptr, png_const_charp message) +PNGLINKAGEMODE wx_png_error(png_structp WXUNUSED(png_ptr), png_const_charp message) { - wxPNGInfoStruct *info = WX_PNG_INFO(png_ptr); - if (info->verbose) - wxLogError( wxString::FromAscii(message) ); - -#ifdef USE_FAR_KEYWORD - { - jmp_buf jmpbuf; - png_memcpy(jmpbuf,info->jmpbuf,sizeof(jmp_buf)); - longjmp(jmpbuf, 1); - } -#else - longjmp(info->jmpbuf, 1); -#endif + wxLogFatalError( wxString::FromAscii(message) ); } void PNGLINKAGEMODE wx_png_warning(png_structp png_ptr, png_const_charp message) { - wxPNGInfoStruct *info = WX_PNG_INFO(png_ptr); - if (info->verbose) + wxPNGInfoStruct *info = png_ptr ? WX_PNG_INFO(png_ptr) : NULL; + if ( !info || info->verbose ) wxLogWarning( wxString::FromAscii(message) ); } @@ -531,15 +519,16 @@ wxPNGHandler::LoadFile(wxImage *image, image->Destroy(); - png_structp png_ptr = png_create_read_struct( PNG_LIBPNG_VER_STRING, - (voidp) NULL, - (png_error_ptr) NULL, - (png_error_ptr) NULL ); + png_structp png_ptr = png_create_read_struct + ( + PNG_LIBPNG_VER_STRING, + (voidp) NULL, + wx_png_error, + wx_png_warning + ); if (!png_ptr) goto error; - png_set_error_fn(png_ptr, (png_voidp)NULL, wx_png_error, wx_png_warning); - // NB: please see the comment near wxPNGInfoStruct declaration for // explanation why this line is mandatory png_set_read_fn( png_ptr, &wxinfo, wx_PNG_stream_reader); @@ -570,7 +559,7 @@ wxPNGHandler::LoadFile(wxImage *image, png_set_expand( png_ptr ); png_set_filler( png_ptr, 0xff, PNG_FILLER_AFTER ); - image->Create((int)width, (int)height, false /* no need to init pixels */); + image->Create((int)width, (int)height, (bool) false /* no need to init pixels */); if (!image->Ok()) goto error; @@ -640,7 +629,13 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbos wxinfo.verbose = verbose; wxinfo.stream.out = &stream; - png_structp png_ptr = png_create_write_struct( PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + png_structp png_ptr = png_create_write_struct + ( + PNG_LIBPNG_VER_STRING, + NULL, + wx_png_error, + wx_png_warning + ); if (!png_ptr) { if (verbose) @@ -648,8 +643,6 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbos return false; } - png_set_error_fn(png_ptr, (png_voidp)NULL, wx_png_error, wx_png_warning); - png_infop info_ptr = png_create_info_struct(png_ptr); if (info_ptr == NULL) {