diff --git a/libvips/include/vips/object.h b/libvips/include/vips/object.h index 6db0b470..6180e03f 100644 --- a/libvips/include/vips/object.h +++ b/libvips/include/vips/object.h @@ -275,7 +275,8 @@ void *vips_class_map_concrete_all( GType base, VipsClassMap fn, void *a ); VipsObjectClass *vips_class_find( const char *basename, const char *nickname ); GType vips_type_find( const char *basename, const char *nickname ); -// void vips_object_local( VipsObject *vobject, GObject *gobject ); +int vips_object_unref( VipsObject *obj ); + void vips_object_local_cb( VipsObject *vobject, GObject *gobject ); #define vips_object_local( V, G ) \ g_signal_connect( V, "close", \ diff --git a/libvips/iofuncs/dispatch_types.c b/libvips/iofuncs/dispatch_types.c index 7c3784ef..b841297c 100644 --- a/libvips/iofuncs/dispatch_types.c +++ b/libvips/iofuncs/dispatch_types.c @@ -70,12 +70,12 @@ input_display_init( im_object *obj, char *str ) if( !scr ) { int i; - im_error( "input_display", + vips_error( "input_display", _( "unknown display type \"%s\"" ), str ); - im_error( "input_display", - "%s", _( "display should be one of:\n" ) ); + vips_error( "input_display", "%s", + _( "display should be one of:\n" ) ); for( i = 0; (scr = im_col_displays( i )); i++ ) - im_error( "input_display", + vips_error( "input_display", " '%s'\n", scr->d_name ); return( -1 ); @@ -113,7 +113,7 @@ input_image_init( im_object *obj, char *str ) { IMAGE **im = (IMAGE **) obj; - return( !(*im = im_open( str, "rd" )) ); + return( !(*im = vips_open( str, "rd" )) ); } /* Input image type. @@ -123,7 +123,7 @@ im_type_desc im__input_image = { 0, /* No storage needed */ IM_TYPE_ARG, /* It requires a command-line arg */ (im_init_obj_fn) input_image_init,/* Init function */ - (im_dest_obj_fn) im_close /* Destroy function */ + (im_dest_obj_fn) vips_object_unref/* Destroy function */ }; /* Init function for output images. @@ -133,7 +133,7 @@ output_image_init( im_object *obj, char *str ) { IMAGE **im = (IMAGE **) obj; - return( !(*im = im_open( str, "w" )) ); + return( !(*im = vips_open( str, "w" )) ); } /* Output image type. @@ -143,7 +143,7 @@ im_type_desc im__output_image = { 0, /* No storage to be allocated */ IM_TYPE_OUTPUT | IM_TYPE_ARG, /* Flags! */ (im_init_obj_fn) output_image_init,/* Init function */ - (im_dest_obj_fn) im_close /* Destroy function */ + (im_dest_obj_fn) vips_object_unref/* Destroy function */ }; /* Init function for RW images. @@ -153,7 +153,7 @@ rw_image_init( im_object *obj, char *str ) { IMAGE **im = (IMAGE **) obj; - return( !(*im = im_open( str, "rw" )) ); + return( !(*im = vips_open( str, "rw" )) ); } /* RW image type. @@ -163,7 +163,7 @@ im_type_desc im__rw_image = { 0, /* No storage to be allocated */ IM_TYPE_ARG | IM_TYPE_RW, /* Read-write object, needs an arg */ (im_init_obj_fn) rw_image_init, /* Init function */ - (im_dest_obj_fn) im_close /* Destroy function */ + (im_dest_obj_fn) vips_object_unref/* Destroy function */ }; /* im_imagevec_object destroy function. @@ -178,7 +178,7 @@ imagevec_dest( im_object obj ) for( i = 0; i < iv->n; i++ ) if( iv->vec[i] ) { - im_close( iv->vec[i] ); + g_object_unref( iv->vec[i] ); iv->vec[i] = NULL; } @@ -203,7 +203,7 @@ input_imagevec_init( im_object *obj, char *str ) strv = g_strsplit( str, VEC_SEPS, -1 ); nargs = g_strv_length( strv ); - if( !(iv->vec = IM_ARRAY( NULL, nargs, IMAGE * )) ) { + if( !(iv->vec = VIPS_ARRAY( NULL, nargs, IMAGE * )) ) { g_strfreev( strv ); return( -1 ); } @@ -215,7 +215,7 @@ input_imagevec_init( im_object *obj, char *str ) iv->vec[i] = NULL; for( i = 0; i < nargs; i++ ) - if( !(iv->vec[i] = im_open( strv[i], "rd" )) ) { + if( !(iv->vec[i] = vips_open( strv[i], "rd" )) ) { g_strfreev( strv ); return( -1 ); } @@ -445,7 +445,7 @@ input_doublevec_init( im_object *obj, char *str ) strv = g_strsplit( str, VEC_SEPS, -1 ); nargs = g_strv_length( strv ); - if( !(dv->vec = IM_ARRAY( NULL, nargs, double )) ) { + if( !(dv->vec = VIPS_ARRAY( NULL, nargs, double )) ) { g_strfreev( strv ); return( -1 ); } @@ -454,7 +454,7 @@ input_doublevec_init( im_object *obj, char *str ) for( i = 0; i < nargs; i++ ) { dv->vec[i] = g_ascii_strtod( strv[i], NULL ); if( errno ) { - im_error_system( errno, "input_doublevec_init", + vips_error_system( errno, "input_doublevec_init", _( "bad double \"%s\"" ), strv[i] ); g_strfreev( strv ); return( -1 ); @@ -530,7 +530,7 @@ input_intvec_init( im_object *obj, char *str ) strv = g_strsplit( str, VEC_SEPS, -1 ); nargs = g_strv_length( strv ); - if( !(iv->vec = IM_ARRAY( NULL, nargs, int )) ) { + if( !(iv->vec = VIPS_ARRAY( NULL, nargs, int )) ) { g_strfreev( strv ); return( -1 ); } @@ -546,7 +546,7 @@ input_intvec_init( im_object *obj, char *str ) return( -1 ); } if( INT_MAX < val || INT_MIN > val ) { - im_error( "input_intvec_init", + vips_error( "input_intvec_init", "%ld overflows integer type", val ); } iv->vec[i] = (int) val; @@ -600,8 +600,7 @@ input_int_init( im_object *obj, char *str ) int *i = (int *) *obj; if( sscanf( str, "%d", i ) != 1 ) { - im_error( "input_int", - "%s", _( "bad format" ) ); + vips_error( "input_int", "%s", _( "bad format" ) ); return( -1 ); } diff --git a/libvips/iofuncs/object.c b/libvips/iofuncs/object.c index f74c6dcf..51324aed 100644 --- a/libvips/iofuncs/object.c +++ b/libvips/iofuncs/object.c @@ -1179,3 +1179,11 @@ vips_object_local_cb( VipsObject *vobject, GObject *gobject ) { g_object_unref( gobject ); } + +int +vips_object_unref( VipsObject *obj ) +{ + g_object_unref( obj ); + + return( 0 ); +}