@@ -470,33 +470,29 @@ static void
470
470
imageinfo_finalize ( GObject * gobject )
471
471
{
472
472
Imageinfo * imageinfo = IMAGEINFO ( gobject );
473
- gboolean isfile = imageinfo -> im ? im_isfile ( imageinfo -> im ) : FALSE;
474
- char name [FILENAME_MAX ];
473
+ gboolean isfile = imageinfo -> im && im_isfile ( imageinfo -> im );
475
474
476
475
#ifdef DEBUG_MAKE
477
476
printf ( "imageinfo_finalize:" );
478
477
imageinfo_print ( imageinfo );
479
478
#endif /*DEBUG_MAKE*/
480
479
481
- if ( imageinfo -> dfile && isfile ) {
482
- /* We must close before we delete ... save the filename.
483
- */
484
- im_strncpy ( name , imageinfo -> im -> filename , FILENAME_MAX - 5 );
480
+ IM_FREEF ( im_close , imageinfo -> im );
481
+ IM_FREEF ( im_close , imageinfo -> mapped_im );
482
+ IM_FREEF ( im_close , imageinfo -> identity_lut );
485
483
484
+ if ( imageinfo -> dfile &&
485
+ imageinfo -> delete_filename &&
486
+ isfile ) {
486
487
#ifdef DEBUG_OPEN
487
488
printf ( "imageinfo_destroy: unlinking \"%s\"\n" , name );
488
489
#endif /*DEBUG_OPEN*/
489
- }
490
-
491
- IM_FREEF ( im_close , imageinfo -> im );
492
- IM_FREEF ( im_close , imageinfo -> mapped_im );
493
- IM_FREEF ( im_close , imageinfo -> identity_lut );
494
490
495
- if ( imageinfo -> dfile && isfile ) {
496
- unlinkf ( "%s" , name );
491
+ unlinkf ( "%s" , imageinfo -> delete_filename );
497
492
iobject_changed ( IOBJECT ( main_imageinfogroup ) );
498
493
}
499
494
495
+ VIPS_FREE ( imageinfo -> delete_filename );
500
496
MANAGED_UNREF ( imageinfo -> underlying );
501
497
502
498
imageinfo_undo_free ( imageinfo );
@@ -626,6 +622,7 @@ imageinfo_init( Imageinfo *imageinfo )
626
622
imageinfo -> proxy = NULL ;
627
623
628
624
imageinfo -> dfile = FALSE;
625
+ imageinfo -> delete_filename = NULL ;
629
626
imageinfo -> from_file = FALSE;
630
627
imageinfo -> mtime = 0 ;
631
628
imageinfo -> exprs = NULL ;
@@ -812,6 +809,7 @@ imageinfo_new_temp( Imageinfogroup *imageinfogroup,
812
809
return ( NULL );
813
810
}
814
811
imageinfo -> dfile = TRUE;
812
+ VIPS_SETSTR ( imageinfo -> delete_filename , tname );
815
813
816
814
return ( imageinfo );
817
815
}
0 commit comments