fix a few more problems with input args

a few other operators were modifying input args and messing up caching
This commit is contained in:
John Cupitt 2017-05-29 18:58:24 +01:00
parent 5a26b8fc45
commit cbd9fad040
9 changed files with 27 additions and 50 deletions

View File

@ -117,13 +117,9 @@ vips_measure_build( VipsObject *object )
/* left/top/width/height default to the size of the image.
*/
if( !vips_object_argument_isset( object, "width" ) )
g_object_set( object,
"width", vips_image_get_width( ready ),
NULL );
measure->width = vips_image_get_width( ready );
if( !vips_object_argument_isset( object, "height" ) )
g_object_set( object,
"height", vips_image_get_height( ready ),
NULL );
measure->height = vips_image_get_height( ready );
/* How large are the patches we are to measure?
*/

View File

@ -159,15 +159,15 @@ vips_arrayjoin_build( VipsObject *object )
}
if( !vips_object_argument_isset( object, "hspacing" ) )
g_object_set( object, "hspacing", hspacing, NULL );
join->hspacing = hspacing;
if( !vips_object_argument_isset( object, "vspacing" ) )
g_object_set( object, "vspacing", vspacing, NULL );
join->vspacing = vspacing;
hspacing = join->hspacing;
vspacing = join->vspacing;
if( !vips_object_argument_isset( object, "across" ) )
g_object_set( object, "across", n, NULL );
join->across = n;
/* How many images down the grid?
*/

View File

@ -306,8 +306,7 @@ vips__deprecated_open_read( const char *filename, gboolean sequential )
/* Yuk. Can't g_object_set() filename since it's after
* construct. Just zap the new filename in.
*/
VIPS_FREE( image->filename );
image->filename = g_strdup( filename );
VIPS_SETSTR( image->filename, filename );
return( image );
}

View File

@ -468,6 +468,9 @@ vips_draw_flood_build( VipsObject *object )
/* @test defaults to @image.
*/
if( !vips_object_argument_isset( object, "test" ) )
/* Setting input params like this will break caching, but we
* don't cache draw ops anyway.
*/
g_object_set( object, "test", draw->image, NULL );
if( vips_image_wio_input( drawflood->test ) ||

View File

@ -1634,6 +1634,10 @@ vips_foreign_save_dz_build( VipsObject *object )
!vips_object_argument_isset( object, "background" ) ) {
VipsArrayDouble *background;
/* Using g_object_set() to set an input param in build will
* change the hash and confuse caching, but we don't cache
* savers, so it's fine.
*/
background = vips_array_double_newv( 1, 255.0 );
g_object_set( object, "background", background, NULL );
vips_area_unref( VIPS_AREA( background ) );

View File

@ -478,12 +478,17 @@ png2vips_interlace( Read *read, VipsImage *out )
if( setjmp( png_jmpbuf( read->pPng ) ) )
return( -1 );
if( !(read->row_pointer = VIPS_ARRAY( NULL, out->Ysize, png_bytep )) )
return( -1 );
for( y = 0; y < out->Ysize; y++ )
read->row_pointer[y] = VIPS_IMAGE_ADDR( out, 0, y );
/* With some libpng you get a warning unless you call this, even though
* it's unnecessary.
*/
png_set_interlace_handling( read->pPng );
png_read_image( read->pPng, read->row_pointer );
png_read_end( read->pPng, NULL );

View File

@ -398,24 +398,11 @@ vips_affine_build( VipsObject *object )
vips_check_vector_length( class->nickname,
affine->oarea->n, 4 ) )
return( -1 );
/* We can't use vips_object_argument_isset(), since it may have been
* set to NULL, see vips_similarity().
/* Can be set explicitly to NULL to mean default setting.
*/
if( !affine->interpolate ) {
VipsInterpolate *interpolate;
interpolate = vips_interpolate_new( "bilinear" );
g_object_set( object,
"interpolate", interpolate,
NULL );
g_object_unref( interpolate );
/* coverity gets confused by this, it thinks
* affine->interpolate may still be null. Assign ourselves,
* even though we don't need to.
*/
affine->interpolate = interpolate;
}
if( !affine->interpolate )
affine->interpolate = vips_interpolate_new( "bilinear" );
in = resample->in;

View File

@ -342,25 +342,6 @@ vips_mapim_build( VipsObject *object )
return( -1 );
in = t[0];
/* We can't use vips_object_argument_isset(), since it may have been
* set to NULL, see vips_similarity().
*/
if( !mapim->interpolate ) {
VipsInterpolate *interpolate;
interpolate = vips_interpolate_new( "bilinear" );
g_object_set( object,
"interpolate", interpolate,
NULL );
g_object_unref( interpolate );
/* coverity gets confused by this, it thinks
* mapim->interpolate may still be null. Assign ourselves,
* even though we don't need to.
*/
mapim->interpolate = interpolate;
}
window_size = vips_interpolate_get_window_size( mapim->interpolate );
window_offset =
vips_interpolate_get_window_offset( mapim->interpolate );
@ -425,6 +406,7 @@ vips_mapim_class_init( VipsMapimClass *class )
static void
vips_mapim_init( VipsMapim *mapim )
{
mapim->interpolate = vips_interpolate_new( "bilinear" );
}
/**

View File

@ -1,6 +1,6 @@
#!/bin/sh
# this has now been mostly superceeded by test_foreign.py ... keep this around
# this has now been mostly superseded by test_foreign.py ... keep this around
# as a test of the command-line interface
# set -x
@ -195,7 +195,8 @@ if test_supported tiffload; then
fi
if test_supported pngload; then
test_format $image png 0
test_format $image png 0 [compression=9,interlace=1]
# sadly broken in libpng 1.6.28 and 29
# test_format $image png 0 [compression=9,interlace=1]
fi
if test_supported jpegload; then
test_format $image jpg 90