From f78816e00f670e48267bf7266fa1e191c10dbc7d Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 23 Jul 2008 15:59:04 +0000 Subject: [PATCH] more fixes --- ChangeLog | 1 + TODO | 8 ++++++++ include/vips/region.h | 2 ++ libsrc/iofuncs/buffer.c | 2 +- libsrc/iofuncs/im_close.c | 25 ++++++++++++++----------- libsrc/iofuncs/region.c | 22 ++++++++++++++++++++++ 6 files changed, 48 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 279c3fa4..92d05a0f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -33,6 +33,7 @@ - added "-rotate" option to vips2dj - added man page for im_resize_linear - better jpeg-in-tiff YCbCr read (thanks Ole) +- oops, invalidatefns were not being freed on im__close() 25/1/08 started 7.14.0 - bump all version numbers for new stable diff --git a/TODO b/TODO index 0e7d19c8..f7050a65 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,11 @@ +- im__close() has + + g_assert( !im->regions ); + while( im->regions ) + im_region_free( (REGION *) im->regions->data ); + + remove the while() loop? + - wrap meta() stuff in C++, we need it in py as well - try diff --git a/include/vips/region.h b/include/vips/region.h index 80a9efeb..3082782b 100644 --- a/include/vips/region.h +++ b/include/vips/region.h @@ -141,6 +141,8 @@ int im_region_position( REGION *reg1, int x, int y ); typedef int (*im_region_fill_fn)( REGION *, void * ); int im_region_fill( REGION *reg, Rect *r, im_region_fill_fn fn, void *a ); +void im_region_print( REGION *region ); + /* IMAGE functions which use regions. */ typedef void *(*im_start_fn)( IMAGE *, void *, void * ); diff --git a/libsrc/iofuncs/buffer.c b/libsrc/iofuncs/buffer.c index 31b15d4a..c2b292bc 100644 --- a/libsrc/iofuncs/buffer.c +++ b/libsrc/iofuncs/buffer.c @@ -538,7 +538,7 @@ im__link_mapp( IMAGE *im, VSListMap2Fn fn, int *serial, void *a, void *b ) (VSListMap4Fn) im__link_mapp, fn, serial, a, b ) ); } -/* Apply a function to an image and all it's parents, direct and indirect. +/* Apply a function to an image and all it's parents, direct and indirect. */ void * im__link_map( IMAGE *im, VSListMap2Fn fn, void *a, void *b ) diff --git a/libsrc/iofuncs/im_close.c b/libsrc/iofuncs/im_close.c index 8e7b0109..f6030899 100644 --- a/libsrc/iofuncs/im_close.c +++ b/libsrc/iofuncs/im_close.c @@ -54,6 +54,8 @@ * - free history_list * 7/11/07 * - added preclose, removed evalend triggers + * 23/7/08 + * - im__close() will no longer free regions */ /* @@ -142,16 +144,17 @@ im__close( IMAGE *im ) result |= im__trigger_callbacks( im->preclosefns ); IM_FREEF( im_slist_free_all, im->preclosefns ); - /* Free any regions defined on this image. This will, in turn, call - * all stop functions still running, freeing all regions we have on - * other images, etc. + /* Should be no regions defined on the image. im_close() ought to put + * us into a zombie state if there are, im__close() should not be + * called on images with running regions. */ -#ifdef DEBUG_IO - printf( "im__close: freeing %d regions ..\n", - g_slist_length( (List *) im->regions ) ); -#endif /*DEBUG_IO*/ - while( im->regions ) - im_region_free( (REGION *) im->regions->data ); + if( im->regions ) { + GSList *p; + + printf( "** im__close: leaked regions!\n" ); + for( p = im->regions; p; p = p->next ) + im_region_print( (REGION *) p->data ); + } /* That should mean we have no windows. */ @@ -163,12 +166,12 @@ im__close( IMAGE *im ) im_window_print( (im_window_t *) p->data ); } - /* Make sure all evalend functions have been called, perform all close - * callbacks, and free eval callbacks. + /* Junk all callbacks, perform close callbacks. */ IM_FREEF( im_slist_free_all, im->evalstartfns ); IM_FREEF( im_slist_free_all, im->evalfns ); IM_FREEF( im_slist_free_all, im->evalendfns ); + IM_FREEF( im_slist_free_all, im->invalidatefns ); result |= im__trigger_callbacks( im->closefns ); IM_FREEF( im_slist_free_all, im->closefns ); diff --git a/libsrc/iofuncs/region.c b/libsrc/iofuncs/region.c index 75acc036..7b2868de 100644 --- a/libsrc/iofuncs/region.c +++ b/libsrc/iofuncs/region.c @@ -33,6 +33,8 @@ * - im_region_image() only sets r, not whole image * 1'2'07 * - gah, im_region_image() could still break (thanks Mikkel) + * 23/7/08 + * - added im_region_print() */ /* @@ -601,3 +603,23 @@ im_region_fill( REGION *reg, Rect *r, im_region_fill_fn fn, void *a ) return( 0 ); } + +/* Handy for debug. + */ +void +im_region_print( REGION *region ) +{ + printf( "REGION: %p, ", region ); + printf( "im = %p, ", region->im ); + printf( "valid.left = %d, ", region->valid.left ); + printf( "valid.top = %d, ", region->valid.top ); + printf( "valid.width = %d, ", region->valid.width ); + printf( "valid.height = %d, ", region->valid.height ); + printf( "type = %d, ", region->type ); + printf( "data = %p, ", region->data ); + printf( "bpl = %d, ", region->bpl ); + printf( "seq = %p, ", region->seq ); + printf( "thread = %p, ", region->thread ); + printf( "window = %p, ", region->window ); + printf( "buffer = %p\n", region->buffer ); +}