fix a warning from magicksave on some platforms

we were leaving delay_gvalue as {0} then unsetting it, which will
produce a warning with some versions of glib.

Thanks chregu.

See https://github.com/libvips/libvips/issues/1524
This commit is contained in:
John Cupitt 2020-01-13 16:23:58 +00:00
parent 34fcd1fe69
commit 8c1c8b6c9f
3 changed files with 23 additions and 10 deletions

View File

@ -2,6 +2,7 @@
- don't use the new source loaders for new_from_file or new_from_buffer, it - don't use the new source loaders for new_from_file or new_from_buffer, it
will break the loader priority system will break the loader priority system
- fix thumbnail autorot [janko] - fix thumbnail autorot [janko]
- fix a warning with magicksave with no delay array [chregu]
20/6/19 started 8.9.0 20/6/19 started 8.9.0
- add vips_image_get/set_array_int() - add vips_image_get/set_array_int()

View File

@ -214,13 +214,14 @@ magick_optimize_image_layers( Image **images, ExceptionInfo *exception )
{ {
Image *tmp; Image *tmp;
tmp = OptimizePlusImageLayers(*images, exception ); tmp = OptimizePlusImageLayers( *images, exception );
if ( exception->severity != UndefinedException ) if( exception->severity != UndefinedException ) {
VIPS_FREEF( DestroyImageList, tmp );
return MagickFalse; return MagickFalse;
}
VIPS_FREEF( DestroyImageList, *images ); VIPS_FREEF( DestroyImageList, *images );
*images = tmp; *images = tmp;
return MagickTrue; return MagickTrue;
@ -230,8 +231,9 @@ int
magick_optimize_image_transparency( const Image *images, magick_optimize_image_transparency( const Image *images,
ExceptionInfo *exception ) ExceptionInfo *exception )
{ {
OptimizeImageTransparency(images, exception); OptimizeImageTransparency( images, exception );
return ( exception->severity == UndefinedException );
return( exception->severity == UndefinedException );
} }
/* Does a few bytes look like a file IM can handle? /* Does a few bytes look like a file IM can handle?

View File

@ -367,6 +367,7 @@ vips_foreign_save_magick_build( VipsObject *object )
* need it. * need it.
*/ */
if( vips_image_get_typeof( im, "delay" ) ) { if( vips_image_get_typeof( im, "delay" ) ) {
g_value_unset( &magick->delay_gvalue );
if( vips_image_get( im, "delay", &magick->delay_gvalue ) ) if( vips_image_get( im, "delay", &magick->delay_gvalue ) )
return( -1 ); return( -1 );
magick->delays = vips_value_get_array_int( magick->delays = vips_value_get_array_int(
@ -378,8 +379,10 @@ vips_foreign_save_magick_build( VipsObject *object )
return( -1 ); return( -1 );
if( magick->optimize_gif_frames ) { if( magick->optimize_gif_frames ) {
if( !magick_optimize_image_layers(&magick->images, magick->exception ) ) { if( !magick_optimize_image_layers( &magick->images,
magick_inherit_exception( magick->exception, magick->images ); magick->exception ) ) {
magick_inherit_exception( magick->exception,
magick->images );
magick_vips_error( class->nickname, magick->exception ); magick_vips_error( class->nickname, magick->exception );
return( -1 ); return( -1 );
@ -387,8 +390,10 @@ vips_foreign_save_magick_build( VipsObject *object )
} }
if( magick->optimize_gif_transparency ) { if( magick->optimize_gif_transparency ) {
if( !magick_optimize_image_transparency(magick->images, magick->exception) ) { if( !magick_optimize_image_transparency( magick->images,
magick_inherit_exception( magick->exception, magick->images ); magick->exception ) ) {
magick_inherit_exception( magick->exception,
magick->images );
magick_vips_error( class->nickname, magick->exception ); magick_vips_error( class->nickname, magick->exception );
return( -1 ); return( -1 );
@ -470,13 +475,18 @@ vips_foreign_save_magick_class_init( VipsForeignSaveMagickClass *class )
_( "Optimize_gif_transparency" ), _( "Optimize_gif_transparency" ),
_( "Apply GIF transparency optimization" ), _( "Apply GIF transparency optimization" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignSaveMagick, optimize_gif_transparency ), G_STRUCT_OFFSET( VipsForeignSaveMagick,
optimize_gif_transparency ),
FALSE ); FALSE );
} }
static void static void
vips_foreign_save_magick_init( VipsForeignSaveMagick *magick ) vips_foreign_save_magick_init( VipsForeignSaveMagick *magick )
{ {
/* Init to an int just to have something there. It is swapped for an
* int array later.
*/
g_value_init( &magick->delay_gvalue, G_TYPE_INT );
} }
typedef struct _VipsForeignSaveMagickFile { typedef struct _VipsForeignSaveMagickFile {