better vips_init() fallback

the vips_init() fallback was not working well ... new, better one gets
called more often
This commit is contained in:
John Cupitt 2011-09-12 12:28:01 +01:00
parent a6255af981
commit df599f2f55
9 changed files with 35 additions and 24 deletions

View File

@ -1,3 +1,6 @@
12/9/11 started 7.26.4
- fallback vips_init()
10/8/11 started 7.26.3
- don't use G_VALUE_COLLECT_INIT(), many platforms do not have a glib this
recent

View File

@ -6,7 +6,7 @@ AC_CONFIG_MACRO_DIR(m4)
# user-visible library versioning
m4_define([vips_major_version], [7])
m4_define([vips_minor_version], [26])
m4_define([vips_micro_version], [3])
m4_define([vips_micro_version], [4])
m4_define([vips_version],
[vips_major_version.vips_minor_version.vips_micro_version])
@ -29,7 +29,7 @@ PACKAGE=vips
# interface changes not backwards compatible?: reset age to 0
LIBRARY_CURRENT=30
LIBRARY_REVISION=2
LIBRARY_REVISION=3
LIBRARY_AGE=15
AM_INIT_AUTOMAKE($PACKAGE,$VERSION)

View File

@ -149,6 +149,7 @@ extern "C" {
const char *vips_get_argv0( void );
int vips_init( const char *argv0 );
void vips_check_init( void );
GOptionGroup *vips_get_option_group( void );
const char *vips_version_string( void );

View File

@ -299,6 +299,8 @@ vips_image_new_from_file_object( const char *string )
{
VipsImage *image;
vips_check_init();
/* We mustn't _build() the object here, so we can't just call
* vips_image_new_from_file().
*/
@ -1408,6 +1410,8 @@ vips_image_new( void )
{
VipsImage *image;
vips_check_init();
image = VIPS_IMAGE( g_object_new( VIPS_TYPE_IMAGE, NULL ) );
g_object_set( image,
"filename", vips_image_temp_name(),
@ -1561,6 +1565,8 @@ vips_image_new_mode( const char *filename, const char *mode )
{
VipsImage *image;
vips_check_init();
image = VIPS_IMAGE( g_object_new( VIPS_TYPE_IMAGE, NULL ) );
g_object_set( image,
"filename", filename,
@ -1615,6 +1621,8 @@ vips_image_new_from_file_raw( const char *filename,
{
VipsImage *image;
vips_check_init();
image = VIPS_IMAGE( g_object_new( VIPS_TYPE_IMAGE, NULL ) );
g_object_set( image,
"filename", filename,
@ -1654,6 +1662,8 @@ vips_image_new_from_memory( void *buffer,
{
VipsImage *image;
vips_check_init();
image = VIPS_IMAGE( g_object_new( VIPS_TYPE_IMAGE, NULL ) );
g_object_set( image,
"filename", vips_image_temp_name(),

View File

@ -262,8 +262,10 @@ vips_init( const char *argv0 )
return( 0 );
}
const char *
vips__gettext( const char *msgid )
/* Call this before vips stuff that uses stuff we need to have inited.
*/
void
vips_check_init( void )
{
/* Pass in a nonsense name for argv0 ... this init path is only here
* for old programs which are missing an vips_init() call. We need
@ -271,6 +273,12 @@ vips__gettext( const char *msgid )
*/
if( vips_init( "giant_banana" ) )
vips_error_clear();
}
const char *
vips__gettext( const char *msgid )
{
vips_check_init();
return( dgettext( GETTEXT_PACKAGE, msgid ) );
}
@ -278,8 +286,7 @@ vips__gettext( const char *msgid )
const char *
vips__ngettext( const char *msgid, const char *plural, unsigned long int n )
{
if( vips_init( "giant_banana" ) )
vips_error_clear();
vips_check_init();
return( dngettext( GETTEXT_PACKAGE, msgid, plural, n ) );
}

View File

@ -952,6 +952,8 @@ vips_object_real_new_from_string( const char *string )
{
GType type;
vips_check_init();
/* The main arg selects the subclass.
*/
if( !(type = vips_type_find( "VipsObject", string )) )
@ -1334,6 +1336,8 @@ vips_object_new( GType type, VipsObjectSetArguments set, void *a, void *b )
{
VipsObject *object;
vips_check_init();
object = VIPS_OBJECT( g_object_new( type, NULL ) );
if( set && set( object, a, b ) ) {

View File

@ -218,6 +218,8 @@ vips_operation_new( const char *name )
GType type;
VipsOperation *operation;
vips_check_init();
if( !(type = vips_type_find( "VipsOperation", name )) )
return( NULL );
operation = VIPS_OPERATION( g_object_new( type, NULL ) );

View File

@ -167,6 +167,8 @@ vips_pool_new( const char *name )
{
VipsPool *pool;
vips_check_init();
pool = VIPS_POOL( g_object_new( VIPS_TYPE_POOL, NULL ) );
g_object_set( pool, "name", name, NULL );

View File

@ -1,18 +0,0 @@
#!/bin/sh
# shrink to a target width
# default prefix
VIPSHOME=${VIPSHOME-/home/john/vips}
name=$0
bname=`basename $0`
if [ $# != 3 ]; then
echo "${bname}: usage: $bname <in> <out> <target width>"
exit 1
fi
inwidth=`$VIPSHOME/bin/vips im_header_int Xsize $1`
factor=`(echo scale=10; echo $inwidth / $3) | bc`
$VIPSHOME/bin/vips im_shrink $1 $2 $factor $factor