From: VMware, Inc <> Date: Wed, 26 Jan 2011 01:50:02 +0000 (-0800) Subject: Override regular gobject constructor (instead of "constructed" callback). X-Git-Tag: 2011.01.24-354108~21 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=edec2ed2da223651b4ed4eb7171816f11e1779ab;p=thirdparty%2Fopen-vm-tools.git Override regular gobject constructor (instead of "constructed" callback). It seems some older gobject libraries don't have the "constructed" callback. So override the regular gobject constructor instead. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/services/vmtoolsd/serviceObj.c b/open-vm-tools/services/vmtoolsd/serviceObj.c index ff945e0c0..55dc5e0f2 100644 --- a/open-vm-tools/services/vmtoolsd/serviceObj.c +++ b/open-vm-tools/services/vmtoolsd/serviceObj.c @@ -33,6 +33,7 @@ typedef struct ServiceProperty { gpointer value; } ServiceProperty; +static gpointer gToolsCoreServiceParentClass; /** * Accumulator function for the "set option" signal. If a handler returns @@ -237,17 +238,32 @@ ToolsCoreServiceSetProperty(GObject *object, * * Object constructor. Initialize internal state. * - * @param object Instance being initialized. + * @param[in] type Object type. + * @param[in] nparams Param count. + * @param[in] params Construction parameters. + * + * @return A new instance. * ******************************************************************************* */ -static void -ToolsCoreServiceCtor(GObject *object) +static GObject * +ToolsCoreServiceCtor(GType type, + guint nparams, + GObjectConstructParam *params) { - ToolsCoreService *self = (ToolsCoreService *) object; + GObject *object; + ToolsCoreService *self; + + object = G_OBJECT_CLASS(gToolsCoreServiceParentClass)->constructor(type, + nparams, + params); + + self = TOOLSCORE_SERVICE(object); self->lock = g_mutex_new(); self->props = g_array_new(FALSE, FALSE, sizeof (ServiceProperty)); + + return object; } @@ -296,6 +312,9 @@ ToolsCore_Service_class_init(gpointer _klass, gpointer klassData) { ToolsCoreServiceClass *klass = _klass; + + gToolsCoreServiceParentClass = g_type_class_peek_parent(_klass); + g_signal_new(TOOLS_CORE_SIG_CAPABILITIES, G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_LAST, @@ -376,7 +395,7 @@ ToolsCore_Service_class_init(gpointer _klass, G_TYPE_POINTER); #endif - G_OBJECT_CLASS(klass)->constructed = ToolsCoreServiceCtor; + G_OBJECT_CLASS(klass)->constructor = ToolsCoreServiceCtor; G_OBJECT_CLASS(klass)->finalize = ToolsCoreServiceDtor; G_OBJECT_CLASS(klass)->set_property = ToolsCoreServiceSetProperty; G_OBJECT_CLASS(klass)->get_property = ToolsCoreServiceGetProperty; diff --git a/open-vm-tools/services/vmtoolsd/serviceObj.h b/open-vm-tools/services/vmtoolsd/serviceObj.h index bf9989321..5172db3cb 100644 --- a/open-vm-tools/services/vmtoolsd/serviceObj.h +++ b/open-vm-tools/services/vmtoolsd/serviceObj.h @@ -33,6 +33,9 @@ #define TOOLSCORE_TYPE_SERVICE ToolsCore_Service_get_type() #define TOOLSCORESERVICE_GET_CLASS(object) \ (G_TYPE_INSTANCE_GET_CLASS((object), TOOLSCORE_TYPE_SERVICE, ToolsCoreServiceClass)) +#define TOOLSCORE_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \ + TOOLSCORE_TYPE_SERVICE, \ + ToolsCoreService)) typedef struct ToolsCoreService { GObject parent;