Re: when should I create child objects?



On Fri, 2010-04-16 at 10:22 +0200, Emmanuel Rodriguez wrote:

What I do is that I provide my own new and call the parent's new
first. I then build my properties there.

sub new {
  my $class = shift;
  my $self = $class->SUPER::new(@_);
  $self->set_XXX($xxx);
  return $self;
}

I'm wondering if there's a better way too.

GObject provides the "constructed" virtual function, which is called
after the object instance has been fully constructed - that is after the
instance has been initialized and the constructor properties have been
applied.

this is currently missing from Glib::Object, but I guess a patch would
be welcome.

ciao,
 Emmanuele.

-- 
W: http://www.emmanuelebassi.name
B: http://blogs.gnome.org/ebassi




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