fallback vips_init()

call vips_init() for the user if they forget
This commit is contained in:
John Cupitt 2011-09-09 17:14:27 +01:00
parent e7cd1147ce
commit 5d1accfc83
7 changed files with 29 additions and 11 deletions

View File

@ -10,6 +10,8 @@
- C API supports optional output args - C API supports optional output args
- switch back to int-valued operations - switch back to int-valued operations
- fix up VipsPool - fix up VipsPool
- add the operation cache
- fallback vips_init()
10/8/11 started 7.26.3 10/8/11 started 7.26.3
- don't use G_VALUE_COLLECT_INIT(), many platforms do not have a glib this - don't use G_VALUE_COLLECT_INIT(), many platforms do not have a glib this

7
TODO
View File

@ -1,9 +1,4 @@
- cache - cache work ... see notes in file
- im_init_world() fallback is not working
need to go back to multiple ifs in object.c

View File

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

View File

@ -44,8 +44,8 @@
*/ */
/* /*
*/
#define VIPS_DEBUG #define VIPS_DEBUG
*/
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>

View File

@ -299,6 +299,8 @@ vips_image_new_from_file_object( const char *string )
{ {
VipsImage *image; VipsImage *image;
vips_check_init();
/* We mustn't _build() the object here, so we can't just call /* We mustn't _build() the object here, so we can't just call
* vips_image_new_from_file(). * vips_image_new_from_file().
*/ */
@ -1409,6 +1411,8 @@ vips_image_new( void )
{ {
VipsImage *image; VipsImage *image;
vips_check_init();
image = VIPS_IMAGE( g_object_new( VIPS_TYPE_IMAGE, NULL ) ); image = VIPS_IMAGE( g_object_new( VIPS_TYPE_IMAGE, NULL ) );
g_object_set( image, g_object_set( image,
"filename", vips_image_temp_name(), "filename", vips_image_temp_name(),
@ -1562,6 +1566,8 @@ vips_image_new_mode( const char *filename, const char *mode )
{ {
VipsImage *image; VipsImage *image;
vips_check_init();
image = VIPS_IMAGE( g_object_new( VIPS_TYPE_IMAGE, NULL ) ); image = VIPS_IMAGE( g_object_new( VIPS_TYPE_IMAGE, NULL ) );
g_object_set( image, g_object_set( image,
"filename", filename, "filename", filename,
@ -1616,6 +1622,8 @@ vips_image_new_from_file_raw( const char *filename,
{ {
VipsImage *image; VipsImage *image;
vips_check_init();
image = VIPS_IMAGE( g_object_new( VIPS_TYPE_IMAGE, NULL ) ); image = VIPS_IMAGE( g_object_new( VIPS_TYPE_IMAGE, NULL ) );
g_object_set( image, g_object_set( image,
"filename", filename, "filename", filename,
@ -1655,6 +1663,8 @@ vips_image_new_from_memory( void *buffer,
{ {
VipsImage *image; VipsImage *image;
vips_check_init();
image = VIPS_IMAGE( g_object_new( VIPS_TYPE_IMAGE, NULL ) ); image = VIPS_IMAGE( g_object_new( VIPS_TYPE_IMAGE, NULL ) );
g_object_set( image, g_object_set( image,
"filename", vips_image_temp_name(), "filename", vips_image_temp_name(),

View File

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

View File

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