add vips_argument_get_id()

We had a global we incremented to allocate property ids, but of course that
won't work with DLLs. Instead, add vips_argument_get_id() and call that to
allocate new prop ids.

See:

https://github.com/jcupitt/libvips/issues/985
This commit is contained in:
John Cupitt 2018-05-29 16:49:20 +01:00
parent 73a55e0322
commit d251b37d92
4 changed files with 42 additions and 13 deletions

View File

@ -23,6 +23,7 @@
- add vips_transpose3d() -- swap major dimensions in a volumetric image
- remove vips7 stuff from default API ... you must now #include it explicitly
- acquire an image colormap if none set [jtorresfabra]
- added vips_argument_get_id() to fix derived classes on win32 [angelmixu]
12/3/18 started 8.6.4
- better fitting of fonts with overhanging edges [Adrià]

View File

@ -100,8 +100,6 @@ VIPS_ARGUMENT_OPTIONAL_OUTPUT Eg. the x pos of the image minimum
(VIPS_ARGUMENT_OUTPUT | \
VIPS_ARGUMENT_CONSTRUCT)
extern int _vips__argument_id;
#define VIPS_ARG_IMAGE( CLASS, NAME, PRIORITY, LONG, DESC, FLAGS, OFFSET ) { \
GParamSpec *pspec; \
\
@ -109,7 +107,7 @@ extern int _vips__argument_id;
VIPS_TYPE_IMAGE, \
(GParamFlags) (G_PARAM_READWRITE) ); \
g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
_vips__argument_id++, pspec ); \
vips_argument_get_id(), pspec ); \
vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
}
@ -121,7 +119,7 @@ extern int _vips__argument_id;
VIPS_TYPE_INTERPOLATE, \
(GParamFlags) (G_PARAM_READWRITE) ); \
g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
_vips__argument_id++, pspec ); \
vips_argument_get_id(), pspec ); \
vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
}
@ -134,7 +132,7 @@ extern int _vips__argument_id;
(VALUE), \
(GParamFlags) (G_PARAM_READWRITE) ); \
g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
_vips__argument_id++, pspec ); \
vips_argument_get_id(), pspec ); \
vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
}
@ -147,7 +145,7 @@ extern int _vips__argument_id;
(MIN), (MAX), (VALUE), \
(GParamFlags) (G_PARAM_READWRITE) );\
g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
_vips__argument_id++, pspec ); \
vips_argument_get_id(), pspec ); \
vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
}
@ -160,7 +158,7 @@ extern int _vips__argument_id;
(TYPE), \
(GParamFlags) (G_PARAM_READWRITE) );\
g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
_vips__argument_id++, pspec ); \
vips_argument_get_id(), pspec ); \
vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
}
@ -173,7 +171,7 @@ extern int _vips__argument_id;
(MIN), (MAX), (VALUE), \
(GParamFlags) (G_PARAM_READWRITE) );\
g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
_vips__argument_id++, pspec ); \
vips_argument_get_id(), pspec ); \
vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
}
@ -186,7 +184,7 @@ extern int _vips__argument_id;
(MIN), (MAX), (VALUE), \
(GParamFlags) (G_PARAM_READWRITE) );\
g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
_vips__argument_id++, pspec ); \
vips_argument_get_id(), pspec ); \
vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
}
@ -199,7 +197,7 @@ extern int _vips__argument_id;
(TYPE), (VALUE), \
(GParamFlags) (G_PARAM_READWRITE) );\
g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
_vips__argument_id++, pspec ); \
vips_argument_get_id(), pspec ); \
vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
}
@ -212,7 +210,7 @@ extern int _vips__argument_id;
(TYPE), (VALUE), \
(GParamFlags) (G_PARAM_READWRITE) );\
g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
_vips__argument_id++, pspec ); \
vips_argument_get_id(), pspec ); \
vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
}
@ -225,7 +223,7 @@ extern int _vips__argument_id;
(VALUE), \
(GParamFlags) (G_PARAM_READWRITE) ); \
g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \
_vips__argument_id++, pspec ); \
vips_argument_get_id(), pspec ); \
vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
}
@ -236,7 +234,7 @@ extern int _vips__argument_id;
pspec = g_param_spec_pointer( (NAME), (LONG), (DESC), \
(GParamFlags) (G_PARAM_READWRITE) ); \
g_object_class_install_property( gobject_class, \
_vips__argument_id++, pspec ); \
vips_argument_get_id(), pspec ); \
vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \
pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \
}
@ -296,6 +294,7 @@ typedef struct _VipsArgumentInstance {
*/
typedef GHashTable VipsArgumentTable;
int vips_argument_get_id( void );
void vips__object_set_member( VipsObject *object, GParamSpec *pspec,
GObject **member, GObject *argument );
typedef void *(*VipsArgumentMapFn)( VipsObject *object, GParamSpec *pspec,

View File

@ -188,6 +188,10 @@ int vips_region_prepare_many( struct _VipsRegion **reg, const VipsRect *r );
*/
int vips__view_image( struct _VipsImage *image );
/* Pre 8.7 libvipses used this for allocating argument ids.
*/
extern int _vips__argument_id;
#ifdef __cplusplus
}
#endif /*__cplusplus*/

View File

@ -1,6 +1,9 @@
/* abstract base class for all vips objects
*
* Edited from nip's base class, 15/10/08
*
* 29/5/18
* - added vips_argument_get_id()
*/
/*
@ -209,6 +212,8 @@ static GMutex *vips__object_all_lock = NULL;
static guint vips_object_signals[SIG_LAST] = { 0 };
/* This has to be externally visible for compatibility with older libvipses.
*/
int _vips__argument_id = 1;
/* Keep a cache of nickname -> GType lookups.
@ -217,6 +222,26 @@ static GHashTable *vips__object_nickname_table = NULL;
G_DEFINE_ABSTRACT_TYPE( VipsObject, vips_object, G_TYPE_OBJECT );
/**
* vips_argument_get_id: (skip)
*
* Allocate a new property id. See g_object_class_install_property().
*
* Returns: a new property id > 0
*/
int
vips_argument_get_id( void )
{
int id;
/* We probably don't need to lock: glib seems to single-thread class
* creation.
*/
id = _vips__argument_id++;
return( id );
}
/* Don't call this directly, see vips_object_build().
*/
static int