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
- switch back to int-valued operations
- fix up VipsPool
- add the operation cache
- 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

7
TODO
View File

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

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

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

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().
*/
@ -1409,6 +1411,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(),
@ -1562,6 +1566,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,
@ -1616,6 +1622,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,
@ -1655,6 +1663,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,11 @@ 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.
* Fallback initialisation.
*/
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 +274,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 +287,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

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