diff --git a/ChangeLog b/ChangeLog index b34caa49..41498623 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ - support "rs" mode in vips7 - add --vips-version cmdline arg - fix --without-tiff / exr / jpeg / png / magick +- add --vips-fatal flag 19/3/12 started 7.29.0 - sanity-check PNG read geometry diff --git a/libvips/include/vips/internal.h b/libvips/include/vips/internal.h index 130481fe..00971e86 100644 --- a/libvips/include/vips/internal.h +++ b/libvips/include/vips/internal.h @@ -66,6 +66,10 @@ extern int vips__thinstrip_height; */ extern int vips__concurrency; +/* abort() on any error. + */ +extern int vips__fatal; + /* Give progress feedback. */ extern int vips__progress; diff --git a/libvips/iofuncs/error.c b/libvips/iofuncs/error.c index b6ee8530..097708f4 100644 --- a/libvips/iofuncs/error.c +++ b/libvips/iofuncs/error.c @@ -155,6 +155,9 @@ vips_verror( const char *domain, const char *fmt, va_list ap ) g_mutex_unlock( vips__global_lock ); VIPS_DEBUG_MSG( "vips_verror: %s\n", fmt ); + + if( vips__fatal ) + vips_error_exit( "vips__fatal" ); } /** @@ -363,6 +366,9 @@ vips_vwarn( const char *domain, const char *fmt, va_list ap ) (void) fprintf( stderr, "\n" ); g_mutex_unlock( vips__global_lock ); } + + if( vips__fatal ) + vips_error_exit( "vips__fatal" ); } /** @@ -421,7 +427,10 @@ vips_error_exit( const char *fmt, ... ) vips_shutdown(); - exit( 1 ); + if( vips__fatal ) + abort(); + else + exit( 1 ); } /** diff --git a/libvips/iofuncs/init.c b/libvips/iofuncs/init.c index 0a9425a2..9655a35d 100644 --- a/libvips/iofuncs/init.c +++ b/libvips/iofuncs/init.c @@ -80,6 +80,10 @@ #include #include +/* abort() on the first warning or error. + */ +int vips__fatal = 0; + /* Use in various small places where we need a mutex and it's not worth * making a private one. */ @@ -374,7 +378,28 @@ vips_lib_version_cb( const gchar *option_name, const gchar *value, exit( 0 ); } +static gboolean +vips_set_fatal_cb( const gchar *option_name, const gchar *value, + gpointer data, GError **error ) +{ + vips__fatal = 1; + + /* Set masks for debugging ... stop on any problem. + */ + g_log_set_always_fatal( + G_LOG_FLAG_RECURSION | + G_LOG_FLAG_FATAL | + G_LOG_LEVEL_ERROR | + G_LOG_LEVEL_CRITICAL | + G_LOG_LEVEL_WARNING ); + + return( TRUE ); +} + static GOptionEntry option_entries[] = { + { "vips-fatal", 'f', G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG, + G_OPTION_ARG_CALLBACK, (gpointer) &vips_set_fatal_cb, + N_( "abort on first error or warning" ), NULL }, { "vips-concurrency", 'c', 0, G_OPTION_ARG_INT, &vips__concurrency, N_( "evaluate with N concurrent threads" ), "N" },