From df599f2f55315a68948cd99dca35fcc83736ec2b Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 12 Sep 2011 12:28:01 +0100 Subject: [PATCH] better vips_init() fallback the vips_init() fallback was not working well ... new, better one gets called more often --- ChangeLog | 3 +++ configure.in | 4 ++-- libvips/include/vips/vips.h | 1 + libvips/iofuncs/image.c | 10 ++++++++++ libvips/iofuncs/init.c | 15 +++++++++++---- libvips/iofuncs/object.c | 4 ++++ libvips/iofuncs/operation.c | 2 ++ libvips/iofuncs/pool.c | 2 ++ tools/shrink_width | 18 ------------------ 9 files changed, 35 insertions(+), 24 deletions(-) delete mode 100644 tools/shrink_width diff --git a/ChangeLog b/ChangeLog index fa884834..0f46d97d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/configure.in b/configure.in index cdc29717..dfa26e69 100644 --- a/configure.in +++ b/configure.in @@ -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) diff --git a/libvips/include/vips/vips.h b/libvips/include/vips/vips.h index 9106c0a8..edb098a2 100644 --- a/libvips/include/vips/vips.h +++ b/libvips/include/vips/vips.h @@ -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 ); diff --git a/libvips/iofuncs/image.c b/libvips/iofuncs/image.c index 3a0aff70..07a69455 100644 --- a/libvips/iofuncs/image.c +++ b/libvips/iofuncs/image.c @@ -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(), diff --git a/libvips/iofuncs/init.c b/libvips/iofuncs/init.c index b35c57e1..2f9716c2 100644 --- a/libvips/iofuncs/init.c +++ b/libvips/iofuncs/init.c @@ -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 ) ); } diff --git a/libvips/iofuncs/object.c b/libvips/iofuncs/object.c index f2c02503..42e62764 100644 --- a/libvips/iofuncs/object.c +++ b/libvips/iofuncs/object.c @@ -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 ) ) { diff --git a/libvips/iofuncs/operation.c b/libvips/iofuncs/operation.c index ff63c076..537f1065 100644 --- a/libvips/iofuncs/operation.c +++ b/libvips/iofuncs/operation.c @@ -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 ) ); diff --git a/libvips/iofuncs/pool.c b/libvips/iofuncs/pool.c index c8cb8a43..ed6b6277 100644 --- a/libvips/iofuncs/pool.c +++ b/libvips/iofuncs/pool.c @@ -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 ); diff --git a/tools/shrink_width b/tools/shrink_width deleted file mode 100644 index 953ce14c..00000000 --- a/tools/shrink_width +++ /dev/null @@ -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 " - 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