From df599f2f55315a68948cd99dca35fcc83736ec2b Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 12 Sep 2011 12:28:01 +0100 Subject: [PATCH 1/5] 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 From 35ff0fa7c4b8cdf8fbc413b155bd6e40f979d0ec Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 11 Oct 2011 14:45:43 +0100 Subject: [PATCH 2/5] im_openout() compat was wrong The compatibility macro for im_openout() was wrong, causing ruby-vips to break. --- ChangeLog | 1 + libvips/include/vips/vips7compat.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0f46d97d..11a90b48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 12/9/11 started 7.26.4 - fallback vips_init() +- im_openout() compat stub was wrong, breaking ruby-vips 10/8/11 started 7.26.3 - don't use G_VALUE_COLLECT_INIT(), many platforms do not have a glib this diff --git a/libvips/include/vips/vips7compat.h b/libvips/include/vips/vips7compat.h index 46f5d33f..b24413bc 100644 --- a/libvips/include/vips/vips7compat.h +++ b/libvips/include/vips/vips7compat.h @@ -164,7 +164,7 @@ extern "C" { #define im_invalidate vips_image_invalidate_all #define im_isfile vips_image_isfile #define im_printdesc( I ) vips_object_print( VIPS_OBJECT( I ) ) -#define im_openout( F ) vips_image_new_from_file( F, "w" ) +#define im_openout( F ) vips_image_new_mode( F, "w" ) #define im_setbuf( F ) vips_image_new( "t" ) #define im_initdesc( image, \ From ffe44830308aa53c94904a78ff19cc931cf45737 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 11 Oct 2011 18:22:08 +0100 Subject: [PATCH 3/5] vips_class_map_concrete_all() needed a compat macro --- ChangeLog | 1 + libvips/include/vips/vips7compat.h | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 11a90b48..3a46692a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 12/9/11 started 7.26.4 - fallback vips_init() - im_openout() compat stub was wrong, breaking ruby-vips +- vips_class_map_concrete_all() needed a compat macro too 10/8/11 started 7.26.3 - don't use G_VALUE_COLLECT_INIT(), many platforms do not have a glib this diff --git a/libvips/include/vips/vips7compat.h b/libvips/include/vips/vips7compat.h index b24413bc..30a81a20 100644 --- a/libvips/include/vips/vips7compat.h +++ b/libvips/include/vips/vips7compat.h @@ -486,6 +486,10 @@ int im_wrapmany( VipsImage **in, VipsImage *out, #define im_concurrency_set vips_concurrency_set #define im_concurrency_get vips_concurrency_get +/* ruby-vips uses this + */ +#define vips_class_map_concrete_all vips_class_map_all + #ifdef __cplusplus } #endif /*__cplusplus*/ From 122c390c7bb24a8e669086944d5fce93136ed4a4 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 11 Oct 2011 21:09:39 +0100 Subject: [PATCH 4/5] vips_class_map_all() was broken --- ChangeLog | 1 + libvips/iofuncs/object.c | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a46692a..bb2890d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ - fallback vips_init() - im_openout() compat stub was wrong, breaking ruby-vips - vips_class_map_concrete_all() needed a compat macro too +- vips_class_map_all() was broken 10/8/11 started 7.26.3 - don't use G_VALUE_COLLECT_INIT(), many platforms do not have a glib this diff --git a/libvips/iofuncs/object.c b/libvips/iofuncs/object.c index 42e62764..137c3349 100644 --- a/libvips/iofuncs/object.c +++ b/libvips/iofuncs/object.c @@ -1598,14 +1598,22 @@ vips_class_map_all( GType type, VipsClassMap fn, void *a ) { void *result; - /* We never unref this ref, but we never unload classes - * anyway, so so what. + /* We can't instantiate abstract classes. */ - if( !(result = fn( VIPS_OBJECT_CLASS( g_type_class_ref( type ) ), a )) ) - result = vips_type_map( type, - (VipsTypeMap2) vips_class_map_all, fn, a ); + if( !G_TYPE_IS_ABSTRACT( type ) ) { + /* We never unref this ref, but we never unload classes + * anyway, so so what. + */ + if( (result = fn( + VIPS_OBJECT_CLASS( g_type_class_ref( type ) ), a )) ) + return( result ); + } - return( result ); + if( (result = vips_type_map( type, + (VipsTypeMap2) vips_class_map_all, fn, a )) ) + return( result ); + + return( NULL ); } /* How deeply nested is a class ... used to indent class lists. From 5e6251ac1d6adfcd0f6678b2d866bcaf4ccc1037 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 11 Oct 2011 21:21:12 +0100 Subject: [PATCH 5/5] sync --- po/vips7.pot | 110 +++++++++++++++++++++++++-------------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/po/vips7.pot b/po/vips7.pot index 7b941ffa..6912bb37 100644 --- a/po/vips7.pot +++ b/po/vips7.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-08-16 15:05+0100\n" +"POT-Creation-Date: 2011-10-11 21:17+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -479,7 +479,7 @@ msgstr "" #: libvips/conversion/im_grid.c:168 libvips/conversion/im_replicate.c:151 #: libvips/convolution/im_contrast_surface.c:144 #: libvips/format/im_tile_cache.c:408 libvips/iofuncs/sinkscreen.c:1086 -#: libvips/iofuncs/image.c:889 libvips/morphology/im_rank.c:346 +#: libvips/iofuncs/image.c:891 libvips/morphology/im_rank.c:346 msgid "bad parameters" msgstr "" @@ -556,7 +556,7 @@ msgid "bad input mask" msgstr "" #: libvips/conversion/im_embed.c:332 libvips/conversion/im_embed.c:460 -#: libvips/iofuncs/image.c:1829 +#: libvips/iofuncs/image.c:1839 msgid "bad dimensions" msgstr "" @@ -1312,7 +1312,7 @@ msgstr "" msgid "VIPS operations" msgstr "" -#: libvips/iofuncs/operation.c:603 +#: libvips/iofuncs/operation.c:605 msgid "too few arguments" msgstr "" @@ -1411,123 +1411,123 @@ msgstr "" msgid "unable to close fd" msgstr "" -#: libvips/iofuncs/image.c:368 +#: libvips/iofuncs/image.c:370 #, c-format msgid "%dx%d %s, %d band, %s" msgid_plural "%dx%d %s, %d bands, %s" msgstr[0] "" msgstr[1] "" -#: libvips/iofuncs/image.c:741 +#: libvips/iofuncs/image.c:743 #, c-format msgid "%s %s: %d threads, %d x %d tiles, groups of %d scanlines" msgstr "" -#: libvips/iofuncs/image.c:754 +#: libvips/iofuncs/image.c:756 #, c-format msgid "%s %s: %d%% complete" msgstr "" #. Spaces at end help to erase the %complete message we overwrite. #. -#: libvips/iofuncs/image.c:771 +#: libvips/iofuncs/image.c:773 #, c-format msgid "%s %s: done in %ds \n" msgstr "" -#: libvips/iofuncs/image.c:917 +#: libvips/iofuncs/image.c:919 #, c-format msgid "unable to open \"%s\", file too short" msgstr "" -#: libvips/iofuncs/image.c:927 +#: libvips/iofuncs/image.c:929 #, c-format msgid "%s is longer than expected" msgstr "" -#: libvips/iofuncs/image.c:944 +#: libvips/iofuncs/image.c:946 #, c-format msgid "bad mode \"%s\"" msgstr "" -#: libvips/iofuncs/image.c:1000 +#: libvips/iofuncs/image.c:1002 msgid "VIPS image class" msgstr "" -#: libvips/iofuncs/image.c:1015 +#: libvips/iofuncs/image.c:1017 msgid "Image width in pixels" msgstr "" -#: libvips/iofuncs/image.c:1023 +#: libvips/iofuncs/image.c:1025 msgid "Image height in pixels" msgstr "" -#: libvips/iofuncs/image.c:1031 +#: libvips/iofuncs/image.c:1033 msgid "Number of bands in image" msgstr "" -#: libvips/iofuncs/image.c:1040 +#: libvips/iofuncs/image.c:1042 msgid "Pixel format in image" msgstr "" -#: libvips/iofuncs/image.c:1049 +#: libvips/iofuncs/image.c:1051 msgid "Image filename" msgstr "" -#: libvips/iofuncs/image.c:1058 +#: libvips/iofuncs/image.c:1060 msgid "Open mode" msgstr "" -#: libvips/iofuncs/image.c:1067 +#: libvips/iofuncs/image.c:1069 msgid "Block evaluation on this image" msgstr "" -#: libvips/iofuncs/image.c:1076 +#: libvips/iofuncs/image.c:1078 msgid "Preferred demand style for this image" msgstr "" -#: libvips/iofuncs/image.c:1085 +#: libvips/iofuncs/image.c:1087 msgid "Offset in bytes from start of file" msgstr "" -#: libvips/iofuncs/image.c:1361 +#: libvips/iofuncs/image.c:1363 #, c-format msgid "killed for image \"%s\"" msgstr "" -#: libvips/iofuncs/image.c:1867 +#: libvips/iofuncs/image.c:1877 msgid "bad image descriptor" msgstr "" -#: libvips/iofuncs/image.c:1922 libvips/iofuncs/generate.c:691 +#: libvips/iofuncs/image.c:1932 libvips/iofuncs/generate.c:691 #, c-format msgid "unable to output to a %s image" msgstr "" -#: libvips/iofuncs/image.c:1966 +#: libvips/iofuncs/image.c:1976 #, c-format msgid "auto-rewind for %s failed" msgstr "" -#: libvips/iofuncs/image.c:2009 libvips/iofuncs/image.c:2220 -#: libvips/iofuncs/image.c:2237 +#: libvips/iofuncs/image.c:2019 libvips/iofuncs/image.c:2230 +#: libvips/iofuncs/image.c:2247 msgid "no image data" msgstr "" -#: libvips/iofuncs/image.c:2078 libvips/iofuncs/image.c:2260 +#: libvips/iofuncs/image.c:2088 libvips/iofuncs/image.c:2270 msgid "image not readable" msgstr "" -#: libvips/iofuncs/image.c:2110 libvips/iofuncs/image.c:2124 -#: libvips/iofuncs/image.c:2290 libvips/iofuncs/image.c:2299 +#: libvips/iofuncs/image.c:2120 libvips/iofuncs/image.c:2134 +#: libvips/iofuncs/image.c:2300 libvips/iofuncs/image.c:2309 msgid "image already written" msgstr "" -#: libvips/iofuncs/image.c:2138 libvips/iofuncs/image.c:2311 +#: libvips/iofuncs/image.c:2148 libvips/iofuncs/image.c:2321 msgid "image not writeable" msgstr "" -#: libvips/iofuncs/image.c:2184 +#: libvips/iofuncs/image.c:2194 msgid "bad file type" msgstr "" @@ -1839,43 +1839,43 @@ msgstr "" msgid "unable to mmap \"%s\" to same address" msgstr "" -#: libvips/iofuncs/init.c:289 +#: libvips/iofuncs/init.c:296 msgid "evaluate with N concurrent threads" msgstr "" -#: libvips/iofuncs/init.c:291 +#: libvips/iofuncs/init.c:298 msgid "set tile width to N (DEBUG)" msgstr "" -#: libvips/iofuncs/init.c:293 +#: libvips/iofuncs/init.c:300 msgid "set tile height to N (DEBUG)" msgstr "" -#: libvips/iofuncs/init.c:296 +#: libvips/iofuncs/init.c:303 msgid "set thinstrip height to N (DEBUG)" msgstr "" -#: libvips/iofuncs/init.c:299 +#: libvips/iofuncs/init.c:306 msgid "set fatstrip height to N (DEBUG)" msgstr "" -#: libvips/iofuncs/init.c:301 +#: libvips/iofuncs/init.c:308 msgid "show progress feedback" msgstr "" -#: libvips/iofuncs/init.c:304 +#: libvips/iofuncs/init.c:311 msgid "image size above which to decompress to disc" msgstr "" -#: libvips/iofuncs/init.c:307 +#: libvips/iofuncs/init.c:314 msgid "disable vectorised versions of operations" msgstr "" -#: libvips/iofuncs/init.c:330 +#: libvips/iofuncs/init.c:337 msgid "VIPS Options" msgstr "" -#: libvips/iofuncs/init.c:330 +#: libvips/iofuncs/init.c:337 msgid "Show VIPS options" msgstr "" @@ -1886,55 +1886,55 @@ msgstr "" msgid "parameter %s to %s not set" msgstr "" -#: libvips/iofuncs/object.c:1006 +#: libvips/iofuncs/object.c:1008 msgid "VIPS base class" msgstr "" -#: libvips/iofuncs/object.c:1022 +#: libvips/iofuncs/object.c:1024 msgid "Nickname" msgstr "" -#: libvips/iofuncs/object.c:1023 +#: libvips/iofuncs/object.c:1025 msgid "Class nickname" msgstr "" -#: libvips/iofuncs/object.c:1033 +#: libvips/iofuncs/object.c:1035 msgid "Description" msgstr "" -#: libvips/iofuncs/object.c:1034 +#: libvips/iofuncs/object.c:1036 msgid "Class description" msgstr "" -#: libvips/iofuncs/object.c:1137 libvips/iofuncs/object.c:1204 -#: libvips/iofuncs/object.c:1261 +#: libvips/iofuncs/object.c:1139 libvips/iofuncs/object.c:1206 +#: libvips/iofuncs/object.c:1263 #, c-format msgid "%s.%s does not exist" msgstr "" -#: libvips/iofuncs/object.c:1321 +#: libvips/iofuncs/object.c:1323 #, c-format msgid "no unset required arguments for %s" msgstr "" -#: libvips/iofuncs/object.c:1392 +#: libvips/iofuncs/object.c:1396 msgid "not , or ) after parameter" msgstr "" -#: libvips/iofuncs/object.c:1399 +#: libvips/iofuncs/object.c:1403 msgid "extra tokens after ')'" msgstr "" -#: libvips/iofuncs/object.c:1427 +#: libvips/iofuncs/object.c:1431 msgid "bad object arguments" msgstr "" -#: libvips/iofuncs/object.c:1648 +#: libvips/iofuncs/object.c:1660 #, c-format msgid "base class \"%s\" not found" msgstr "" -#: libvips/iofuncs/object.c:1655 +#: libvips/iofuncs/object.c:1667 #, c-format msgid "class \"%s\" not found" msgstr ""