fix progress for nip2

progress feedback works again, and cancel too
This commit is contained in:
John Cupitt 2011-03-24 14:08:35 +00:00
parent b79fa7387e
commit 5da71c8336
3 changed files with 38 additions and 6 deletions

View File

@ -209,6 +209,8 @@ typedef int (*im_callback_fn)( void *a, void *b );
int im_add_callback( VipsImage *im,
const char *callback, im_callback_fn fn, void *a, void *b );
int im_add_callback1( VipsImage *im,
const char *callback, im_callback_fn fn, void *a, void *b );
#define im_add_close_callback( IM, FN, A, B ) \
im_add_callback( IM, "close", FN, A, B )
#define im_add_postclose_callback( IM, FN, A, B ) \
@ -216,11 +218,12 @@ int im_add_callback( VipsImage *im,
#define im_add_preclose_callback( IM, FN, A, B ) \
im_add_callback( IM, "preclose", FN, A, B )
#define im_add_evalstart_callback( IM, FN, A, B ) \
im_add_callback( IM, "preeval", FN, A, B )
im_add_callback1( IM, "preeval", FN, A, B )
#define im_add_evalend_callback( IM, FN, A, B ) \
im_add_callback( IM, "posteval", FN, A, B )
im_add_callback1( IM, "posteval", FN, A, B )
#define im_add_eval_callback( IM, FN, A, B ) \
im_add_callback( IM, "eval", FN, A, B )
(vips_image_set_progress( IM, TRUE ), \
im_add_callback1( IM, "eval", FN, A, B ))
#define im_add_invalidate_callback( IM, FN, A, B ) \
im_add_callback( IM, "invalidate", FN, A, B )

View File

@ -1335,7 +1335,8 @@ vips_image_preeval( VipsImage *image )
(void) vips_progress_add( image->progress_signal );
g_signal_emit( image->progress_signal,
vips_image_signals[SIG_PREEVAL], 0, image->time );
vips_image_signals[SIG_PREEVAL], 0,
image->progress_signal->time );
}
}
@ -1345,11 +1346,12 @@ void
vips_image_eval( VipsImage *image, int w, int h )
{
if( image->progress_signal ) {
VipsProgress *progress = image->time;
VipsProgress *progress = image->progress_signal->time;
float prop;
VIPS_DEBUG_MSG( "vips_image_eval: %p\n", image );
g_assert( progress );
g_assert( vips_object_sanity(
VIPS_OBJECT( image->progress_signal ) ) );
@ -1370,13 +1372,16 @@ void
vips_image_posteval( VipsImage *image )
{
if( image->progress_signal ) {
VipsProgress *progress = image->progress_signal->time;
VIPS_DEBUG_MSG( "vips_image_posteval: %p\n", image );
g_assert( progress );
g_assert( vips_object_sanity(
VIPS_OBJECT( image->progress_signal ) ) );
g_signal_emit( image->progress_signal,
vips_image_signals[SIG_POSTEVAL], 0, image->time );
vips_image_signals[SIG_POSTEVAL], 0, progress );
}
}

View File

@ -112,6 +112,30 @@ im_add_callback( VipsImage *im,
return( 0 );
}
static void
im_add_callback_cb1( VipsImage *im, void *x, Callback *callback )
{
if( callback->fn( callback->a, callback->b ) )
vips_image_set_kill( im, TRUE );
}
int
im_add_callback1( VipsImage *im,
const char *name, im_callback_fn fn, void *a, void *b )
{
Callback *callback;
if( !(callback = VIPS_NEW( im, Callback )) )
return( -1 );
callback->fn = fn;
callback->a = a;
callback->b = b;
g_signal_connect( im, name,
G_CALLBACK( im_add_callback_cb1 ), callback );
return( 0 );
}
/* Make something local to an image descriptor ... pass in a constructor
* and a destructor, plus three args.
*/