add --vips-fatal flag

--vips-fatal causes an abort() on the first warning or error, handy for
debugging
This commit is contained in:
John Cupitt 2012-07-21 17:01:17 +01:00
parent 133ee84794
commit 3033fea933
4 changed files with 40 additions and 1 deletions

View File

@ -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

View File

@ -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;

View File

@ -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 );
}
/**

View File

@ -80,6 +80,10 @@
#include <vips/internal.h>
#include <vips/vector.h>
/* 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" },