better termination handling

setting and detecting ->kill is now treated more like a message ... you
can now cancel calculation in nip2 without breaking calculation
This commit is contained in:
John Cupitt 2011-08-15 16:24:46 +01:00
parent 1e21963f83
commit 1cfa33e4fb
3 changed files with 27 additions and 4 deletions

View File

@ -1,6 +1,7 @@
10/8/11 started 7.26.3 10/8/11 started 7.26.3
- don't use G_VALUE_COLLECT_INIT(), many platforms do not have a glib this - don't use G_VALUE_COLLECT_INIT(), many platforms do not have a glib this
recent recent
- don't leave image->kill set when we detect termination
10/8/11 started 7.26.2 10/8/11 started 7.26.2
- oops, im_benchmark.c had some stuff turned off - oops, im_benchmark.c had some stuff turned off

View File

@ -1348,20 +1348,33 @@ vips_image_set_progress( VipsImage *image, gboolean progress )
gboolean gboolean
vips_image_get_kill( VipsImage *image ) vips_image_get_kill( VipsImage *image )
{ {
gboolean kill;
kill = image->kill;
/* Has kill been set for this image? If yes, abort evaluation. /* Has kill been set for this image? If yes, abort evaluation.
*/ */
if( image->kill ) if( image->kill ) {
VIPS_DEBUG_MSG( "vips_image_get_kill: %s (%p) killed\n",
image->filename, image );
vips_error( "VipsImage", vips_error( "VipsImage",
_( "killed for image \"%s\"" ), image->filename ); _( "killed for image \"%s\"" ), image->filename );
return( image->kill ); /* We've picked up the kill message, it's now our caller's
* responsibility to pass the message up the chain.
*/
vips_image_set_kill( image, FALSE );
}
return( kill );
} }
void void
vips_image_set_kill( VipsImage *image, gboolean kill ) vips_image_set_kill( VipsImage *image, gboolean kill )
{ {
if( !image->kill ) if( image->kill != kill )
VIPS_DEBUG_MSG( "vips_image_set_kill: %s\n", image->filename ); VIPS_DEBUG_MSG( "vips_image_set_kill: %s (%p) %d\n",
image->filename, image, kill );
image->kill = kill; image->kill = kill;
} }
@ -1880,6 +1893,10 @@ vips_image_write_line( VipsImage *image, int ypos, PEL *linebuffer )
/* Is this the start of eval? /* Is this the start of eval?
*/ */
if( ypos == 0 ) { if( ypos == 0 ) {
/* Always clear kill before we start looping. See the
* call to vips_image_get_kill() below.
*/
vips_image_set_kill( image, FALSE );
vips__image_write_prepare( image ); vips__image_write_prepare( image );
vips_image_preeval( image ); vips_image_preeval( image );
} }

View File

@ -203,6 +203,11 @@ sink_free( Sink *sink )
void void
vips_sink_base_init( SinkBase *sink_base, VipsImage *image ) vips_sink_base_init( SinkBase *sink_base, VipsImage *image )
{ {
/* Always clear kill before we start looping. See the
* call to vips_image_get_kill() below.
*/
vips_image_set_kill( image, FALSE );
sink_base->im = image; sink_base->im = image;
sink_base->x = 0; sink_base->x = 0;
sink_base->y = 0; sink_base->y = 0;