Re: Gobject constructor question




On Tue, 2007-09-04 at 20:34 +0800, Binary Chen wrote:


I have a doubt of GObject's constructor machnism, do i need to
explicit
to invoke the parent's constructor in a chiild constructor?

Yes, call that first, something along these lines:

  /* chain up to constructor of parent class */
  object = G_OBJECT_CLASS (myobject_parent_class)->
    constructor (type, n_construct_properties, construct_params);
  myobject = MYOBJECT (object);


The variable saving the parent class is at the toplevel of the file:

static GObjectClass *myobject_parent_class = NULL;


And you'll have saved the parent class in the class init function:

  myobject_parent_class = g_type_class_peek_parent (klass);


-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]