small bugfixes

various bugfixes ... nip2 runs reliably again now
This commit is contained in:
John Cupitt 2011-06-02 15:34:57 +01:00
parent d28a7059cf
commit 35a7515e3f
10 changed files with 82 additions and 41 deletions

7
TODO
View File

@ -1,3 +1,10 @@
- try
$ vips add babe.jpg babe2.jpg out.v
VIPS:ERROR:object.c:815:vips_object_real_build: assertion failed:
(!object->constructed)
- also VipsFormat ... could this replace vips_image_new_from_string()? or - also VipsFormat ... could this replace vips_image_new_from_string()? or

View File

@ -114,7 +114,7 @@ static int
im_copy_set_all( IMAGE *in, IMAGE *out, im_copy_set_all( IMAGE *in, IMAGE *out,
VipsType type, float xres, float yres, int xoffset, int yoffset, VipsType type, float xres, float yres, int xoffset, int yoffset,
int bands, VipsBandFmt bandfmt, VipsCoding coding ) int bands, VipsBandFmt bandfmt, VipsCoding coding )
{ {
/* Check args. /* Check args.
*/ */
if( im_check_coding_known( "im_copy", in ) || if( im_check_coding_known( "im_copy", in ) ||
@ -162,25 +162,6 @@ im_copy_set_all( IMAGE *in, IMAGE *out,
return( 0 ); return( 0 );
} }
/**
* im_copy:
* @in: input image
* @out: output image
*
* Copy an image. VIPS copies images by copying pointers, so this operation is
* fast, even for very large images.
*
* See also: im_copy(), im_copy_set(), im_copy_morph().
*
* Returns: 0 on success, -1 on error.
*/
int
im_copy( IMAGE *in, IMAGE *out )
{
return( im_copy_set( in, out,
in->Type, in->Xres, in->Yres, 0, 0 ) );
}
/** /**
* im_copy_set: * im_copy_set:
* @in: input image * @in: input image
@ -234,6 +215,25 @@ im_copy_morph( IMAGE *in, IMAGE *out,
bands, bandfmt, coding ) ); bands, bandfmt, coding ) );
} }
/**
* im_copy:
* @in: input image
* @out: output image
*
* Copy an image. VIPS copies images by copying pointers, so this operation is
* fast, even for very large images.
*
* See also: im_copy(), im_copy_set(), im_copy_morph().
*
* Returns: 0 on success, -1 on error.
*/
int
im_copy( IMAGE *in, IMAGE *out )
{
return( im_copy_set( in, out,
in->Type, in->Xres, in->Yres, 0, 0 ) );
}
/** /**
* im_copy_set_meta: * im_copy_set_meta:
* @in: input image * @in: input image

View File

@ -974,14 +974,6 @@ build_args( im_function *fn, im_object *vargv, int argc, char **argv )
return( 0 ); return( 0 );
} }
/* Free a region, but return 0 so we can be used as a close callback.
*/
static void
region_local_image_cb( VipsImage *main, VipsRegion *reg )
{
g_object_unref( reg );
}
/* Make a region on sub, closed by callback on main. /* Make a region on sub, closed by callback on main.
*/ */
static int static int
@ -991,8 +983,7 @@ region_local_image( IMAGE *main, IMAGE *sub )
if( !(reg = vips_region_new( sub )) ) if( !(reg = vips_region_new( sub )) )
return( -1 ); return( -1 );
g_signal_connect( main, "close", vips_object_local( main, reg );
G_CALLBACK( region_local_image_cb ), reg );
return( 0 ); return( 0 );
} }

View File

@ -815,7 +815,13 @@ im_add( IMAGE *in1, IMAGE *in2, IMAGE *out )
g_object_unref( x ); g_object_unref( x );
return( -1 ); return( -1 );
} }
g_object_unref( x );
/* When im_copy() is vips8'd it'll make a ref to in which will be
* junked when the copy shuts down and we can unref x directly.
*
* Until then, we have to use the "close" signal to delay the unref.
*/
vips_object_local( out, x );
return( 0 ); return( 0 );
} }

View File

@ -146,6 +146,12 @@ vips_fits_close( VipsFits *fits )
VIPS_FREE( fits->buffer ); VIPS_FREE( fits->buffer );
} }
static void
vips_fits_close_cb( VipsImage *image, VipsFits *fits )
{
vips_fits_close( fits );
}
static VipsFits * static VipsFits *
vips_fits_new_read( const char *filename, VipsImage *out, int band_select ) vips_fits_new_read( const char *filename, VipsImage *out, int band_select )
{ {
@ -162,7 +168,7 @@ vips_fits_new_read( const char *filename, VipsImage *out, int band_select )
fits->band_select = band_select; fits->band_select = band_select;
fits->buffer = NULL; fits->buffer = NULL;
g_signal_connect( out, "close", g_signal_connect( out, "close",
G_CALLBACK( vips_fits_close ), fits ); G_CALLBACK( vips_fits_close_cb ), fits );
status = 0; status = 0;
if( fits_open_file( &fits->fptr, filename, READONLY, &status ) ) { if( fits_open_file( &fits->fptr, filename, READONLY, &status ) ) {
@ -444,7 +450,7 @@ fits2vips( const char *filename, VipsImage *out, int band_select )
return( -1 ); return( -1 );
} }
/* Don't vips_fits_close(), we need it to stcik around for the /* Don't vips_fits_close(), we need it to stick around for the
* generate. * generate.
*/ */
@ -605,7 +611,7 @@ vips_fits_new_write( VipsImage *in, const char *filename )
fits->band_select = -1; fits->band_select = -1;
fits->buffer = NULL; fits->buffer = NULL;
g_signal_connect( in, "close", g_signal_connect( in, "close",
G_CALLBACK( vips_fits_close ), fits ); G_CALLBACK( vips_fits_close_cb ), fits );
if( !(fits->filename = im_strdup( NULL, filename )) ) if( !(fits->filename = im_strdup( NULL, filename )) )
return( NULL ); return( NULL );

View File

@ -79,7 +79,7 @@
*/ */
/* /*
#define DEBUG_IO #define VIPS_DEBUG
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
@ -605,6 +605,7 @@ vips_image_generate( VipsImage *image,
VIPS_DEBUG_MSG( "vips_image_generate: %p\n", image ); VIPS_DEBUG_MSG( "vips_image_generate: %p\n", image );
g_assert( generate );
g_assert( vips_object_sanity( VIPS_OBJECT( image ) ) ); g_assert( vips_object_sanity( VIPS_OBJECT( image ) ) );
if( !image->hint_set ) { if( !image->hint_set ) {

View File

@ -1226,6 +1226,8 @@ vips_image_class_init( VipsImageClass *class )
static void static void
vips_image_init( VipsImage *image ) vips_image_init( VipsImage *image )
{ {
VIPS_DEBUG_MSG( "vips_image_init: %p\n", image );
/* Default to native order. /* Default to native order.
*/ */
image->magic = vips_amiMSBfirst() ? VIPS_MAGIC_SPARC : VIPS_MAGIC_INTEL; image->magic = vips_amiMSBfirst() ? VIPS_MAGIC_SPARC : VIPS_MAGIC_INTEL;
@ -1412,8 +1414,8 @@ void
vips_image_set_progress( VipsImage *image, gboolean progress ) vips_image_set_progress( VipsImage *image, gboolean progress )
{ {
if( progress && !image->progress_signal ) { if( progress && !image->progress_signal ) {
VIPS_DEBUG_MSG( "vips_image_set_progress: %s\n", VIPS_DEBUG_MSG( "vips_image_set_progress: %p %s\n",
image->filename ); image, image->filename );
image->progress_signal = image; image->progress_signal = image;
} }
else else

View File

@ -179,6 +179,8 @@ vips_object_sanity( VipsObject *object )
printf( "sanity failure: " ); printf( "sanity failure: " );
vips_object_print_name( object ); vips_object_print_name( object );
printf( " %s\n", vips_buf_all( &buf ) ); printf( " %s\n", vips_buf_all( &buf ) );
return( FALSE );
} }
return( TRUE ); return( TRUE );

View File

@ -205,8 +205,6 @@ vips__region_start( VipsRegion *region )
{ {
VipsImage *image = region->im; VipsImage *image = region->im;
/* Have we a sequence running on this region? Start one if not.
*/
if( !region->seq && image->start ) { if( !region->seq && image->start ) {
g_mutex_lock( image->sslock ); g_mutex_lock( image->sslock );
region->seq = region->seq =
@ -231,8 +229,6 @@ vips__region_stop( VipsRegion *region )
{ {
IMAGE *image = region->im; IMAGE *image = region->im;
/* Stop any running sequence.
*/
if( region->seq && image->stop ) { if( region->seq && image->stop ) {
int result; int result;
@ -318,6 +314,28 @@ vips_region_print( VipsObject *object, VipsBuf *buf )
VIPS_OBJECT_CLASS( vips_region_parent_class )->print( object, buf ); VIPS_OBJECT_CLASS( vips_region_parent_class )->print( object, buf );
} }
static void
vips_region_sanity( VipsObject *object, VipsBuf *buf )
{
VipsRegion *region = VIPS_REGION( object );
vips_object_sanity( VIPS_OBJECT( region->im ) );
switch( region->im->dtype ) {
case VIPS_IMAGE_PARTIAL:
/* Start and stop can be NULL, but not generate.
*/
if( !region->im->generate )
vips_buf_appends( buf, "generate NULL in partial\n" );
break;
default:
break;
}
VIPS_OBJECT_CLASS( vips_region_parent_class )->sanity( object, buf );
}
/* If a region is being created in one thread (eg. the main thread) and then /* If a region is being created in one thread (eg. the main thread) and then
* used in another (eg. a worker thread), the new thread needs to tell VIPS * used in another (eg. a worker thread), the new thread needs to tell VIPS
* to stop sanity g_assert() fails. The previous owner needs to * to stop sanity g_assert() fails. The previous owner needs to
@ -407,6 +425,7 @@ vips_region_class_init( VipsRegionClass *class )
gobject_class->dispose = vips_region_dispose; gobject_class->dispose = vips_region_dispose;
vobject_class->print = vips_region_print; vobject_class->print = vips_region_print;
vobject_class->print = vips_region_sanity;
vobject_class->build = vips_region_build; vobject_class->build = vips_region_build;
} }
@ -442,6 +461,11 @@ vips_region_new( VipsImage *image )
return( NULL ); return( NULL );
} }
#ifdef DEBUG
#endif /*DEBUG*/
g_assert( vips_object_sanity( VIPS_OBJECT( image ) ) );
g_assert( vips_object_sanity( VIPS_OBJECT( region ) ) );
return( region ); return( region );
} }

View File

@ -218,6 +218,8 @@ sink_init( Sink *sink,
VipsStartFn start, VipsGenerateFn generate, VipsStopFn stop, VipsStartFn start, VipsGenerateFn generate, VipsStopFn stop,
void *a, void *b ) void *a, void *b )
{ {
g_assert( generate );
vips_sink_base_init( &sink->sink_base, image ); vips_sink_base_init( &sink->sink_base, image );
sink->t = NULL; sink->t = NULL;