[devel] Reverted changes to call png_longjmp in contrib/gregbook

where it is not appropriate.  If mainprog->jmpbuf is used by setjmp,
then png_longjmp cannot be used.
Reversed patch to remove error handler when the jmp_buf is stored in the
main program structure, not the png_struct.
The error handler is needed because the default handler in libpng will
always use the jmp_buf in the library control structure; this is never
set.  The gregbook code is a useful example because, even though it
uses setjmp/longjmp, it shows how error handling can be implemented
using control mechanisms not directly supported by libpng.  The
technique will work correctly with mechanisms such as Microsoft
Structure Exceptions or C++ exceptions (compiler willing - note that gcc
does not by default support interworking of C and C++ error handling.)
This commit is contained in:
Glenn Randers-Pehrson
2010-06-28 20:17:48 -05:00
parent 6cac43c974
commit 73e28ef13d
9 changed files with 122 additions and 21 deletions

View File

@@ -41,8 +41,6 @@
unexpected-EOF and file-read-error cases; fixed Trace() cut-and-
paste bugs
- 2.03: deleted runtime MMX-enabling/disabling and obsolete -mmx* options
removed special error-handling which is no longer needed
because of the new libpng png_longjmp() feature in libpng-1.5.0.
---------------------------------------------------------------------------
@@ -786,8 +784,9 @@ static void rpng2_x_init(void)
if (rpng2_x_create_window()) {
/* GRR TEMPORARY HACK: this is fundamentally no different from cases
* above; libpng should longjmp() back to us when png_ptr goes away.
* If we/it segfault instead, seems like a libpng bug... */
* above; libpng should call our error handler to longjmp() back to us
* when png_ptr goes away. If we/it segfault instead, seems like a
* libpng bug... */
/* we're here via libpng callback, so if window fails, clean and bail */
readpng2_cleanup(&rpng2_info);