Re: Cancel construction of GObject
- From: jcupitt gmail com
- To: Jaroslav ÅmÃd <jardasmid gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Cancel construction of GObject
- Date: Sat, 27 Nov 2010 11:30:47 +0000
On 27 November 2010 11:14, Jaroslav ÅmÃd <jardasmid gmail com> wrote:
Is it possible to "cancel" construction in gobject-derived class?
I don't think so. Lots of code (including code inside gobject) assumes
that g_object_new() always returns a valid pointer.
I handle this by having a more complicated init system. I have
g_object_new() just doing basic mem alloc and setting up a start
state, then I let parameters be set, then I have a virtual function
called build(), which can fail, which constructs the full object.
So make a subclass of GObject for your application (MyObject?) with a
can-fail init system and make all your classes derive from that.
My code is here, if you're curious:
http://vips.svn.sourceforge.net/viewvc/vips/vips7/trunk/libvips/iofuncs/object.c?view=markup
http://vips.svn.sourceforge.net/viewvc/vips/vips7/trunk/libvips/include/vips/object.h?view=markup
John
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]