diff --git a/ChangeLog b/ChangeLog index 31c2bc57..f142bcb0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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Ć ] diff --git a/libvips/include/vips/object.h b/libvips/include/vips/object.h index 1da024fd..3041ea0e 100644 --- a/libvips/include/vips/object.h +++ b/libvips/include/vips/object.h @@ -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, diff --git a/libvips/include/vips/private.h b/libvips/include/vips/private.h index a1be3c42..e28735fc 100644 --- a/libvips/include/vips/private.h +++ b/libvips/include/vips/private.h @@ -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*/ diff --git a/libvips/iofuncs/object.c b/libvips/iofuncs/object.c index 83341daa..911aa7a6 100644 --- a/libvips/iofuncs/object.c +++ b/libvips/iofuncs/object.c @@ -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