better object rewind

added a vips_object_rewind() to allow rebuild, though it's not quite
working yet, see TODO
This commit is contained in:
John Cupitt 2011-03-10 14:44:38 +00:00
parent 834630e562
commit e180c9ec52
4 changed files with 34 additions and 5 deletions

18
TODO
View File

@ -1,8 +1,20 @@
- debug.c can go?
- rewind is not removing arg instance flags
make sanity a method on object
VIPS-WARNING **: object.c:567: VipsImage can only assign 'nickname' once
tools/others/sines.c and friends can go
VipsArgumentInstance *argument_instance =
vips__argument_get_instance( argument_class, object );
how do we find and junk these?
vips_object_dispose_argument(
runs, but perhaps does not trash instance storage? where is this released?
- tools/others/sines.c and friends can go
- why not rename VipsBandFormat as VipsFormat? cf. VipsCoding,

View File

@ -292,6 +292,8 @@ void vips_object_local_cb( VipsObject *vobject, GObject *gobject );
void vips_object_print_all( void );
void vips_object_sanity_all( void );
void vips_object_rewind( VipsObject *object );
#ifdef __cplusplus
}
#endif /*__cplusplus*/

View File

@ -235,7 +235,7 @@ im_incheck( IMAGE *im )
/* Free any resources the image holds and reset to a base
* state.
*/
g_object_run_dispose( G_OBJECT( im ) );
vips_object_rewind( VIPS_OBJECT( im ) );
/* And reopen .. recurse to get a mmaped image.
*/
@ -456,7 +456,7 @@ im_pincheck( IMAGE *im )
/* Free any resources the image holds and reset to a base
* state.
*/
g_object_run_dispose( G_OBJECT( im ) );
vips_object_rewind( VIPS_OBJECT( im ) );
g_object_set( im,
"mode", "r",

View File

@ -1244,3 +1244,18 @@ vips_object_sanity_all( void )
{
vips_object_map( (VSListMap2Fn) vips_object_sanity_all_cb, NULL, NULL );
}
/* On a rewind, we dispose the old contents of the object and
* reconstruct. This is used in things like im_pincheck() where a "w"
* image has to be rewound and become a "p" image.
*/
void
vips_object_rewind( VipsObject *object )
{
g_object_run_dispose( G_OBJECT( object ) );
object->constructed = FALSE;
object->preclose = FALSE;
object->close = FALSE;
object->postclose = FALSE;
}