fix up suffs on all savers
we were not checking that suffs was always defined
This commit is contained in:
parent
c5c0690588
commit
b0f3f687f2
@ -61,7 +61,7 @@ typedef struct _VipsForeignSaveCsv {
|
||||
|
||||
typedef VipsForeignSaveClass VipsForeignSaveCsvClass;
|
||||
|
||||
G_DEFINE_TYPE( VipsForeignSaveCsv, vips_foreign_save_csv,
|
||||
G_DEFINE_ABSTRACT_TYPE( VipsForeignSaveCsv, vips_foreign_save_csv,
|
||||
VIPS_TYPE_FOREIGN_SAVE );
|
||||
|
||||
static void
|
||||
@ -182,11 +182,17 @@ vips_foreign_save_csv_build( VipsObject *object )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
static const char *vips_foreign_save_csv_suffs[] = {
|
||||
".csv",
|
||||
NULL
|
||||
};
|
||||
|
||||
static void
|
||||
vips_foreign_save_csv_class_init( VipsForeignSaveCsvClass *class )
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
||||
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
||||
VipsForeignClass *foreign_class = (VipsForeignClass *) class;
|
||||
VipsForeignSaveClass *save_class = (VipsForeignSaveClass *) class;
|
||||
|
||||
gobject_class->dispose = vips_foreign_save_csv_dispose;
|
||||
@ -197,6 +203,8 @@ vips_foreign_save_csv_class_init( VipsForeignSaveCsvClass *class )
|
||||
object_class->description = _( "save image to csv" );
|
||||
object_class->build = vips_foreign_save_csv_build;
|
||||
|
||||
foreign_class->suffs = vips_foreign_save_csv_suffs;
|
||||
|
||||
save_class->saveable = VIPS_SAVEABLE_MONO;
|
||||
|
||||
VIPS_ARG_STRING( class, "separator", 13,
|
||||
@ -238,17 +246,11 @@ vips_foreign_save_csv_file_build( VipsObject *object )
|
||||
build( object ) );
|
||||
}
|
||||
|
||||
static const char *vips_foreign_save_csv_file_suffs[] = {
|
||||
".csv",
|
||||
NULL
|
||||
};
|
||||
|
||||
static void
|
||||
vips_foreign_save_csv_file_class_init( VipsForeignSaveCsvFileClass *class )
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
||||
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
||||
VipsForeignClass *foreign_class = (VipsForeignClass *) class;
|
||||
|
||||
gobject_class->set_property = vips_object_set_property;
|
||||
gobject_class->get_property = vips_object_get_property;
|
||||
@ -256,8 +258,6 @@ vips_foreign_save_csv_file_class_init( VipsForeignSaveCsvFileClass *class )
|
||||
object_class->nickname = "csvsave";
|
||||
object_class->build = vips_foreign_save_csv_file_build;
|
||||
|
||||
foreign_class->suffs = vips_foreign_save_csv_file_suffs;
|
||||
|
||||
VIPS_ARG_STRING( class, "filename", 1,
|
||||
_( "Filename" ),
|
||||
_( "Filename to save to" ),
|
||||
@ -303,7 +303,6 @@ vips_foreign_save_csv_target_class_init( VipsForeignSaveCsvTargetClass *class )
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
||||
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
||||
VipsForeignClass *foreign_class = (VipsForeignClass *) class;
|
||||
|
||||
gobject_class->set_property = vips_object_set_property;
|
||||
gobject_class->get_property = vips_object_get_property;
|
||||
@ -311,8 +310,6 @@ vips_foreign_save_csv_target_class_init( VipsForeignSaveCsvTargetClass *class )
|
||||
object_class->nickname = "csvsave_target";
|
||||
object_class->build = vips_foreign_save_csv_target_build;
|
||||
|
||||
foreign_class->suffs = vips_foreign_save_csv_file_suffs;
|
||||
|
||||
VIPS_ARG_OBJECT( class, "target", 1,
|
||||
_( "Target" ),
|
||||
_( "Target to save to" ),
|
||||
|
@ -1768,16 +1768,17 @@ vips_foreign_find_save_sub( VipsForeignSaveClass *save_class,
|
||||
VipsObjectClass *object_class = VIPS_OBJECT_CLASS( save_class );
|
||||
VipsForeignClass *class = VIPS_FOREIGN_CLASS( save_class );
|
||||
|
||||
/* The suffs might be defined on an abstract base class, make sure we
|
||||
* don't pick that.
|
||||
*
|
||||
* Suffs can be defined on buffer and target writers too. Make sure
|
||||
* it's not one of those.
|
||||
/* All concrete savers needs suffs, since we use the suff to pick the
|
||||
* saver.
|
||||
*/
|
||||
if( !G_TYPE_IS_ABSTRACT( G_TYPE_FROM_CLASS( class ) ) &&
|
||||
!class->suffs )
|
||||
g_warning( "no suffix defined for %s", object_class->nickname );
|
||||
|
||||
if( !G_TYPE_IS_ABSTRACT( G_TYPE_FROM_CLASS( class ) ) &&
|
||||
class->suffs &&
|
||||
!vips_ispostfix( object_class->nickname, "_buffer" ) &&
|
||||
!vips_ispostfix( object_class->nickname, "_target" ) &&
|
||||
class->suffs &&
|
||||
vips_filename_suffix_match( filename, class->suffs ) )
|
||||
return( save_class );
|
||||
|
||||
@ -1923,7 +1924,15 @@ vips_foreign_find_save_target_sub( VipsForeignSaveClass *save_class,
|
||||
VipsObjectClass *object_class = VIPS_OBJECT_CLASS( save_class );
|
||||
VipsForeignClass *class = VIPS_FOREIGN_CLASS( save_class );
|
||||
|
||||
if( class->suffs &&
|
||||
/* All concrete savers needs suffs, since we use the suff to pick the
|
||||
* saver.
|
||||
*/
|
||||
if( !G_TYPE_IS_ABSTRACT( G_TYPE_FROM_CLASS( class ) ) &&
|
||||
!class->suffs )
|
||||
g_warning( "no suffix defined for %s", object_class->nickname );
|
||||
|
||||
if( !G_TYPE_IS_ABSTRACT( G_TYPE_FROM_CLASS( class ) ) &&
|
||||
class->suffs &&
|
||||
vips_ispostfix( object_class->nickname, "_target" ) &&
|
||||
vips_filename_suffix_match( suffix, class->suffs ) )
|
||||
return( save_class );
|
||||
@ -1973,7 +1982,15 @@ vips_foreign_find_save_buffer_sub( VipsForeignSaveClass *save_class,
|
||||
VipsObjectClass *object_class = VIPS_OBJECT_CLASS( save_class );
|
||||
VipsForeignClass *class = VIPS_FOREIGN_CLASS( save_class );
|
||||
|
||||
if( class->suffs &&
|
||||
/* All concrete savers needs suffs, since we use the suff to pick the
|
||||
* saver.
|
||||
*/
|
||||
if( !G_TYPE_IS_ABSTRACT( G_TYPE_FROM_CLASS( class ) ) &&
|
||||
!class->suffs )
|
||||
g_warning( "no suffix defined for %s", object_class->nickname );
|
||||
|
||||
if( !G_TYPE_IS_ABSTRACT( G_TYPE_FROM_CLASS( class ) ) &&
|
||||
class->suffs &&
|
||||
vips_ispostfix( object_class->nickname, "_buffer" ) &&
|
||||
vips_filename_suffix_match( suffix, class->suffs ) )
|
||||
return( save_class );
|
||||
|
@ -157,11 +157,17 @@ static int bandfmt_matrix[10] = {
|
||||
D, D, D, D, D, D, D, D, D, D
|
||||
};
|
||||
|
||||
static const char *vips_foreign_save_matrix_suffs[] = {
|
||||
".mat",
|
||||
NULL
|
||||
};
|
||||
|
||||
static void
|
||||
vips_foreign_save_matrix_class_init( VipsForeignSaveMatrixClass *class )
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
||||
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
||||
VipsForeignClass *foreign_class = (VipsForeignClass *) class;
|
||||
VipsForeignSaveClass *save_class = (VipsForeignSaveClass *) class;
|
||||
|
||||
gobject_class->dispose = vips_foreign_save_matrix_dispose;
|
||||
@ -170,6 +176,8 @@ vips_foreign_save_matrix_class_init( VipsForeignSaveMatrixClass *class )
|
||||
object_class->description = _( "save image to matrix" );
|
||||
object_class->build = vips_foreign_save_matrix_build;
|
||||
|
||||
foreign_class->suffs = vips_foreign_save_matrix_suffs;
|
||||
|
||||
save_class->saveable = VIPS_SAVEABLE_MONO;
|
||||
save_class->format_table = bandfmt_matrix;
|
||||
|
||||
@ -205,17 +213,12 @@ vips_foreign_save_matrix_file_build( VipsObject *object )
|
||||
vips_foreign_save_matrix_file_parent_class )->build( object ) );
|
||||
}
|
||||
|
||||
static const char *vips_foreign_save_matrix_file_suffs[] = {
|
||||
".mat",
|
||||
NULL
|
||||
};
|
||||
|
||||
static void
|
||||
vips_foreign_save_matrix_file_class_init( VipsForeignSaveMatrixFileClass *class )
|
||||
vips_foreign_save_matrix_file_class_init(
|
||||
VipsForeignSaveMatrixFileClass *class )
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
||||
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
||||
VipsForeignClass *foreign_class = (VipsForeignClass *) class;
|
||||
|
||||
gobject_class->set_property = vips_object_set_property;
|
||||
gobject_class->get_property = vips_object_get_property;
|
||||
@ -223,8 +226,6 @@ vips_foreign_save_matrix_file_class_init( VipsForeignSaveMatrixFileClass *class
|
||||
object_class->nickname = "matrixsave";
|
||||
object_class->build = vips_foreign_save_matrix_file_build;
|
||||
|
||||
foreign_class->suffs = vips_foreign_save_matrix_file_suffs;
|
||||
|
||||
VIPS_ARG_STRING( class, "filename", 1,
|
||||
_( "Filename" ),
|
||||
_( "Filename to save to" ),
|
||||
|
@ -126,11 +126,17 @@ vips_foreign_save_raw_build( VipsObject *object )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
static const char *vips_foreign_save_raw_suffs[] = {
|
||||
".raw",
|
||||
NULL
|
||||
};
|
||||
|
||||
static void
|
||||
vips_foreign_save_raw_class_init( VipsForeignSaveRawClass *class )
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
||||
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
||||
VipsForeignClass *foreign_class = (VipsForeignClass *) class;
|
||||
VipsForeignSaveClass *save_class = (VipsForeignSaveClass *) class;
|
||||
|
||||
gobject_class->dispose = vips_foreign_save_raw_dispose;
|
||||
@ -141,6 +147,8 @@ vips_foreign_save_raw_class_init( VipsForeignSaveRawClass *class )
|
||||
object_class->description = _( "save image to raw file" );
|
||||
object_class->build = vips_foreign_save_raw_build;
|
||||
|
||||
foreign_class->suffs = vips_foreign_save_raw_suffs;
|
||||
|
||||
save_class->saveable = VIPS_SAVEABLE_ANY;
|
||||
|
||||
VIPS_ARG_STRING( class, "filename", 1,
|
||||
@ -238,6 +246,7 @@ vips_foreign_save_raw_fd_class_init( VipsForeignSaveRawFdClass *class )
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
||||
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
||||
VipsForeignClass *foreign_class = (VipsForeignClass *) class;
|
||||
VipsForeignSaveClass *save_class = (VipsForeignSaveClass *) class;
|
||||
|
||||
gobject_class->set_property = vips_object_set_property;
|
||||
@ -247,6 +256,8 @@ vips_foreign_save_raw_fd_class_init( VipsForeignSaveRawFdClass *class )
|
||||
object_class->description = _( "write raw image to file descriptor" );
|
||||
object_class->build = vips_foreign_save_raw_fd_build;
|
||||
|
||||
foreign_class->suffs = vips_foreign_save_raw_suffs;
|
||||
|
||||
save_class->saveable = VIPS_SAVEABLE_ANY;
|
||||
|
||||
VIPS_ARG_INT( class, "fd", 1,
|
||||
|
Loading…
Reference in New Issue
Block a user