Re: understanding gtype and gobject

On 20/04/11 12:12, Milan Bouchet-Valat wrote:
> But I'd like to understand why the table on the page shows constructor
> before instance_init, while the former is actually called *after* the
> latter...

That page of the documentation addresses that question:

“Readers should feel concerned about one little twist in the order in
which functions are invoked: while, technically, the class' constructor
method is called before the GType's instance_init function (since
g_type_create_instance which calls instance_init is called by
g_object_constructor which is the top-level class constructor method and
to which users are expected to chain to), the user's code which runs in
a user-provided constructor will always run after GType's instance_init
function since the user-provided constructor must (you've been warned)
chain up before doing anything useful.”

Someone with a spare hour or two might want to refresh that
documentation in light of the existence of 'constructed', which (IME) is
more convenient than overriding the constructor for everything except
making singletons.


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