redirect OpenSlide error logging to vips_error()

OpenSlide uses g_critical() and g_warning() for unexpected conditions,
so if these are configured as fatal errors in glib (e.g. libvips or
nip2 is built with --enable-debug=yes) the program will crash instead.
This commit is contained in:
Benjamin Gilbert 2011-12-07 23:59:42 -05:00
parent 04096821aa
commit 0fd2ecf84c
1 changed files with 13 additions and 0 deletions

View File

@ -15,6 +15,8 @@
* - use VIPS_ARRAY()
* - add helper to copy a line of pixels
* - support reading associated images
* 7/12/11
* - redirect OpenSlide error logging to vips_error()
*/
/*
@ -366,6 +368,13 @@ slide_flags( const char *filename )
}
}
static void
error_handler( const char *domain, GLogLevelFlags level, const char *message,
void *data )
{
vips_error( "im_openslide2vips", "%s", message );
}
/* openslide format adds no new members.
*/
typedef VipsFormat VipsFormatOpenslide;
@ -400,6 +409,10 @@ vips_format_openslide_class_init( VipsFormatOpenslideClass *class )
* doesn't understand, so this should be safe.
*/
format_class->priority = 100;
g_log_set_handler( "Openslide",
G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,
error_handler, NULL );
}
static void