From efcc53859a1d1693461391d7f304899d9549a483 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 14 Nov 2012 14:44:21 +0000 Subject: [PATCH] capture tiff warnings during startup We were not capturing warnings from libtiff until we used libtiff ourselves. Other libraries whcih we call, such as ImageMagick, could use libtiff and generate an uncaptured warning. On Windows these warnings each produced a popup. --- ChangeLog | 3 +++ configure.in | 6 +++--- libvips/foreign/tiff.h | 3 +-- libvips/foreign/tiff2vips.c | 28 ++++++++++++++++------------ libvips/foreign/tiffload.c | 7 +++++++ libvips/foreign/vips2tiff.c | 6 +----- 6 files changed, 31 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 80b799ec..9be0bcae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +14/11/12 started 7.30.6 +- capture tiff warnings earlier + 14/11/12 started 7.30.5 - fix libtool version mess up (thanks Benjamin) diff --git a/configure.in b/configure.in index 0400da8a..dade4754 100644 --- a/configure.in +++ b/configure.in @@ -2,7 +2,7 @@ # also update the version number in the m4 macros below -AC_INIT([vips], [7.30.5], [vipsip@jiscmail.ac.uk]) +AC_INIT([vips], [7.30.6], [vipsip@jiscmail.ac.uk]) # required for gobject-introspection AC_PREREQ(2.62) @@ -17,7 +17,7 @@ AC_CONFIG_MACRO_DIR([m4]) # user-visible library versioning m4_define([vips_major_version], [7]) m4_define([vips_minor_version], [30]) -m4_define([vips_micro_version], [5]) +m4_define([vips_micro_version], [6]) m4_define([vips_version], [vips_major_version.vips_minor_version.vips_micro_version]) @@ -37,7 +37,7 @@ VIPS_VERSION_STRING=$VIPS_VERSION-`date` # binary interface changes not backwards compatible?: reset age to 0 LIBRARY_CURRENT=33 -LIBRARY_REVISION=7 +LIBRARY_REVISION=8 LIBRARY_AGE=2 # patched into include/vips/version.h diff --git a/libvips/foreign/tiff.h b/libvips/foreign/tiff.h index d9ab22f4..009c0448 100644 --- a/libvips/foreign/tiff.h +++ b/libvips/foreign/tiff.h @@ -36,8 +36,7 @@ extern "C" { extern const char *vips__foreign_tiff_suffs[]; -void vips__thandler_error( const char *module, const char *fmt, va_list ap ); -void vips__thandler_warning( const char *module, const char *fmt, va_list ap ); +void vips__tiff_init( void ); int vips__tiff_write( VipsImage *in, const char *filename, VipsForeignTiffCompression compression, int Q, diff --git a/libvips/foreign/tiff2vips.c b/libvips/foreign/tiff2vips.c index ddfcf730..7cb8f3c9 100644 --- a/libvips/foreign/tiff2vips.c +++ b/libvips/foreign/tiff2vips.c @@ -229,13 +229,13 @@ typedef struct { * more than one thread, but vips_error and vips_warn have mutexes in, so that's * OK. */ -void +static void vips__thandler_error( const char *module, const char *fmt, va_list ap ) { vips_verror( module, fmt, ap ); } -void +static void vips__thandler_warning( const char *module, const char *fmt, va_list ap ) { char buf[256]; @@ -244,6 +244,16 @@ vips__thandler_warning( const char *module, const char *fmt, va_list ap ) vips_warn( module, "%s", buf ); } +/* Call this during startup. Other libraries may be using libtiff and we want + * to capture any messages they send as well. + */ +void +vips__tiff_init( void ) +{ + TIFFSetErrorHandler( vips__thandler_error ); + TIFFSetWarningHandler( vips__thandler_warning ); +} + /* Test for field exists. */ static int @@ -1506,8 +1516,7 @@ istiffpyramid( const char *name ) { TIFF *tif; - TIFFSetErrorHandler( vips__thandler_error ); - TIFFSetWarningHandler( vips__thandler_warning ); + vips__tiff_init(); if( (tif = get_directory( name, 2 )) ) { // We can see page 2 ... assume it is. @@ -1529,8 +1538,7 @@ vips__tiff_read( const char *filename, VipsImage *out, int page ) printf( "tiff2vips: libtiff starting for %s\n", filename ); #endif /*DEBUG*/ - TIFFSetErrorHandler( vips__thandler_error ); - TIFFSetWarningHandler( vips__thandler_warning ); + vips__tiff_init(); if( !(rtiff = readtiff_new( filename, out, page )) ) return( -1 ); @@ -1558,8 +1566,7 @@ vips__tiff_read_header( const char *filename, VipsImage *out, int page ) { ReadTiff *rtiff; - TIFFSetErrorHandler( vips__thandler_error ); - TIFFSetWarningHandler( vips__thandler_warning ); + vips__tiff_init(); if( !(rtiff = readtiff_new( filename, out, page )) ) return( -1 ); @@ -1583,10 +1590,7 @@ vips__istifftiled( const char *filename ) TIFF *tif; gboolean tiled; - /* Override the default TIFF error handler. - */ - TIFFSetErrorHandler( vips__thandler_error ); - TIFFSetWarningHandler( vips__thandler_warning ); + vips__tiff_init(); if( !(tif = TIFFOpen( filename, "rm" )) ) { vips_error_clear(); diff --git a/libvips/foreign/tiffload.c b/libvips/foreign/tiffload.c index 1c229646..267458c9 100644 --- a/libvips/foreign/tiffload.c +++ b/libvips/foreign/tiffload.c @@ -123,6 +123,13 @@ vips_foreign_load_tiff_class_init( VipsForeignLoadTiffClass *class ) VipsForeignClass *foreign_class = (VipsForeignClass *) class; VipsForeignLoadClass *load_class = (VipsForeignLoadClass *) class; + /* Other libraries may be using libtiff, we want to capture tiff + * warning and error as soon as we can. + * + * This class init will be triggered during startup. + */ + vips__tiff_init(); + gobject_class->set_property = vips_object_set_property; gobject_class->get_property = vips_object_get_property; diff --git a/libvips/foreign/vips2tiff.c b/libvips/foreign/vips2tiff.c index b673aacb..66da6955 100644 --- a/libvips/foreign/vips2tiff.c +++ b/libvips/foreign/vips2tiff.c @@ -1474,7 +1474,6 @@ gather_pyramid( TiffWrite *tw ) return( 0 ); } - int vips__tiff_write( VipsImage *in, const char *filename, VipsForeignTiffCompression compression, int Q, @@ -1493,10 +1492,7 @@ vips__tiff_write( VipsImage *in, const char *filename, printf( "tiff2vips: libtiff version is \"%s\"\n", TIFFGetVersion() ); #endif /*DEBUG*/ - /* Override the default TIFF error handler. - */ - TIFFSetErrorHandler( vips__thandler_error ); - TIFFSetWarningHandler( vips__thandler_warning ); + vips__tiff_init(); /* Check input image. */