From a6b0d8471b63bd6485ace1593736e50e434e64fe Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 20 Feb 2008 19:10:02 +0000 Subject: [PATCH] stuff --- TODO | 5 +++++ libsrc/conversion/im_tiff2vips.c | 26 ++++++++++++++------------ libsrc/conversion/im_vips2tiff.c | 15 +++++++-------- libsrc/iofuncs/error.c | 6 ++++++ 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/TODO b/TODO index ab03382b..85060b95 100644 --- a/TODO +++ b/TODO @@ -8,6 +8,11 @@ maybe just link with g++ instead of gcc? how can we do this? put a dummy.cpp into libsrc? + or do we only need to link the cimg convenience library with g++? libtool + should copy the libs up, shouldn't it? + + add a --without-cimg option too + - test maxpos_avg, quite a few changes WONTFIX diff --git a/libsrc/conversion/im_tiff2vips.c b/libsrc/conversion/im_tiff2vips.c index f99a903d..9e0b546a 100644 --- a/libsrc/conversion/im_tiff2vips.c +++ b/libsrc/conversion/im_tiff2vips.c @@ -43,7 +43,7 @@ * - ooops, else missing for subsample stuff above * 2/10/99 JC * - tiled 16-bit greyscale read was broken - * - added mutex for TIFF*() calls + * - added mutex for TIFFReadTile() calls * 11/5/00 JC * - removed TIFFmalloc/TIFFfree usage * 23/4/01 JC @@ -225,16 +225,18 @@ typedef struct { void *table; } YCbCrParams; -/* Handle TIFF errors here. +/* Handle TIFF errors here. Shared with im_vips2tiff. These can be called from + * more than one thread, but im_error and im_warn have mutexes in, so that's + * OK. */ -static void -thandler_error( char *module, char *fmt, va_list ap ) +void +im__thandler_error( char *module, char *fmt, va_list ap ) { im_verror( module, fmt, ap ); } -static void -thandler_warning( char *module, char *fmt, va_list ap ) +void +im__thandler_warning( char *module, char *fmt, va_list ap ) { char buf[256]; @@ -1426,8 +1428,8 @@ im_istiffpyramid( const char *name ) { TIFF *tif; - TIFFSetErrorHandler( (TIFFErrorHandler) thandler_error ); - TIFFSetWarningHandler( (TIFFErrorHandler) thandler_warning ); + TIFFSetErrorHandler( (TIFFErrorHandler) im__thandler_error ); + TIFFSetWarningHandler( (TIFFErrorHandler) im__thandler_warning ); if( (tif = get_directory( name, 2 )) ) { /* We can see page 2 ... assume it is. @@ -1448,8 +1450,8 @@ im_tiff2vips( const char *filename, IMAGE *out ) printf( "im_tiff2vips: libtiff version is \"%s\"\n", TIFFGetVersion() ); #endif /*DEBUG*/ - TIFFSetErrorHandler( (TIFFErrorHandler) thandler_error ); - TIFFSetWarningHandler( (TIFFErrorHandler) thandler_warning ); + TIFFSetErrorHandler( (TIFFErrorHandler) im__thandler_error ); + TIFFSetWarningHandler( (TIFFErrorHandler) im__thandler_warning ); if( !(rtiff = readtiff_new( filename, out )) ) return( -1 ); @@ -1479,8 +1481,8 @@ im_tiff2vips_header( const char *filename, IMAGE *out ) { ReadTiff *rtiff; - TIFFSetErrorHandler( (TIFFErrorHandler) thandler_error ); - TIFFSetWarningHandler( (TIFFErrorHandler) thandler_warning ); + TIFFSetErrorHandler( (TIFFErrorHandler) im__thandler_error ); + TIFFSetWarningHandler( (TIFFErrorHandler) im__thandler_warning ); if( !(rtiff = readtiff_new( filename, out )) ) return( -1 ); diff --git a/libsrc/conversion/im_vips2tiff.c b/libsrc/conversion/im_vips2tiff.c index 20a98683..6fb82d83 100644 --- a/libsrc/conversion/im_vips2tiff.c +++ b/libsrc/conversion/im_vips2tiff.c @@ -96,6 +96,8 @@ * 15/2/08 * - set TIFFTAG_JPEGQUALITY explicitly when we copy TIFF files, since * libtiff doesn't keep this in the header (thanks Joe) + * 20/2/08 + * - use tiff error handler from im_tiff2vips.c */ /* @@ -237,14 +239,10 @@ typedef struct tiff_write { char *icc_profile; /* Profile to embed */ } TiffWrite; -/* Handle TIFF errors here. +/* Use these from im_tiff2vips(). */ -static void -vhandle( char *module, char *fmt, va_list ap ) -{ - im_error( "im_vips2tiff", _( "TIFF error in \"%s\": " ), module ); - im_verror( "im_vips2tiff", fmt, ap ); -} +void im__thandler_error( char *module, char *fmt, va_list ap ); +void im__thandler_warning( char *module, char *fmt, va_list ap ); /* Open TIFF for output. */ @@ -1527,7 +1525,8 @@ im_vips2tiff( IMAGE *im, const char *filename ) /* Override the default TIFF error handler. */ - TIFFSetErrorHandler( (TIFFErrorHandler) vhandle ); + TIFFSetErrorHandler( (TIFFErrorHandler) im__thandler_error ); + TIFFSetWarningHandler( (TIFFErrorHandler) im__thandler_warning ); /* Check input image. */ diff --git a/libsrc/iofuncs/error.c b/libsrc/iofuncs/error.c index 7da6b2b4..be7fe09d 100644 --- a/libsrc/iofuncs/error.c +++ b/libsrc/iofuncs/error.c @@ -12,6 +12,8 @@ * - i18n added, domain now separate arg * 14/2/07 * - lock around error buffer changes + * 20/2/08 + * - lock around warnings and diagnostics too, why not */ /* @@ -160,10 +162,12 @@ void im_vdiag( const char *domain, const char *fmt, va_list ap ) { if( !g_getenv( IM_DIAGNOSTICS ) ) { + g_mutex_lock( im__global_lock ); (void) fprintf( stderr, _( "%s: " ), _( "vips diagnostic" ) ); (void) fprintf( stderr, _( "%s: " ), domain ); (void) vfprintf( stderr, fmt, ap ); (void) fprintf( stderr, "\n" ); + g_mutex_unlock( im__global_lock ); } } @@ -181,10 +185,12 @@ void im_vwarn( const char *domain, const char *fmt, va_list ap ) { if( !g_getenv( IM_WARNING ) ) { + g_mutex_lock( im__global_lock ); (void) fprintf( stderr, _( "%s: " ), _( "vips warning" ) ); (void) fprintf( stderr, _( "%s: " ), domain ); (void) vfprintf( stderr, fmt, ap ); (void) fprintf( stderr, "\n" ); + g_mutex_unlock( im__global_lock ); } }