From 9515c5cb064ebe0b19b77e9eebccaf78e0e4c566 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 23 May 2011 18:19:20 +0100 Subject: [PATCH] more fixes for im_add still getting some dangling region refs though argh --- TODO | 5 ++++- libvips/iofuncs/image.c | 2 +- libvips/iofuncs/object.c | 2 +- libvips/iofuncs/operation.c | 38 ++++++++++++++++++++++++++++--------- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index 7bd9506d..7577537e 100644 --- a/TODO +++ b/TODO @@ -2,7 +2,10 @@ $ vips im_add k2.v babe.v out.v - egV + VIPS:ERROR:image.c:300:vips_image_finalize: assertion failed: + (!image->regions) + + diff --git a/libvips/iofuncs/image.c b/libvips/iofuncs/image.c index fe52282a..d27028f6 100644 --- a/libvips/iofuncs/image.c +++ b/libvips/iofuncs/image.c @@ -31,8 +31,8 @@ */ /* -#define VIPS_DEBUG */ +#define VIPS_DEBUG #ifdef HAVE_CONFIG_H #include diff --git a/libvips/iofuncs/object.c b/libvips/iofuncs/object.c index 134d165e..28cca6c9 100644 --- a/libvips/iofuncs/object.c +++ b/libvips/iofuncs/object.c @@ -30,10 +30,10 @@ */ /* + */ #define DEBUG #define VIPS_DEBUG #define DEBUG_REF - */ #ifdef HAVE_CONFIG_H #include diff --git a/libvips/iofuncs/operation.c b/libvips/iofuncs/operation.c index e22ea4af..ca5e2b50 100644 --- a/libvips/iofuncs/operation.c +++ b/libvips/iofuncs/operation.c @@ -28,8 +28,8 @@ */ /* -#define VIPS_DEBUG */ +#define VIPS_DEBUG #ifdef HAVE_CONFIG_H #include @@ -294,24 +294,44 @@ vips_operation_get_valist( VipsOperation *operation, va_list ap ) VIPS_ARGUMENT_FOR_ALL( operation, pspec, argument_class, argument_instance ) { if( (argument_class->flags & VIPS_ARGUMENT_REQUIRED) && - (argument_class->flags & VIPS_ARGUMENT_OUTPUT) ) { - void *arg; + (argument_class->flags & VIPS_ARGUMENT_INPUT) ) { + GValue value = { 0 }; + char *msg = NULL; - arg = va_arg( ap, void * ); + /* Collect the arg from valist to eat it up, but don't + * do anything with it. + */ + G_VALUE_COLLECT_INIT( &value, + G_PARAM_SPEC_VALUE_TYPE( pspec ), ap, 0, &msg ); + g_value_unset( &value ); + } + else if( (argument_class->flags & VIPS_ARGUMENT_REQUIRED) && + (argument_class->flags & VIPS_ARGUMENT_OUTPUT) ) { + void **arg; + + arg = va_arg( ap, void ** ); if( !argument_instance->assigned ) continue; - g_object_get( G_OBJECT( operation ), - g_param_spec_get_name( pspec ), arg, NULL ); - #ifdef VIPS_DEBUG - printf( "\twriting arg %s to %p\n", + printf( "\twriting %s to %p\n", g_param_spec_get_name( pspec ), arg ); #endif /*VIPS_DEBUG */ - /* TODO ... actually do the write. + g_object_get( G_OBJECT( operation ), + g_param_spec_get_name( pspec ), arg, NULL ); + + /* If the pspec is an object, that will up the ref + * count. We want to hand over the ref, so we have to + * knock it down again. */ + if( G_IS_PARAM_SPEC_OBJECT( pspec ) ) { + GObject *object; + + object = *((GObject **) arg); + g_object_unref( object ); + } } } VIPS_ARGUMENT_FOR_ALL_END }