After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 425324 - add GObjectClass->constructed()
add GObjectClass->constructed()
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gobject
unspecified
Other All
: Normal enhancement
: ---
Assigned To: Tim Janik
gtkdev
Depends on:
Blocks:
 
 
Reported: 2007-04-02 00:59 UTC by Tim Janik
Modified: 2007-04-03 10:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
implement constructed vcall (2.46 KB, patch)
2007-04-02 22:57 UTC, Allison Karlitskaya (desrt)
none Details | Review

Description Tim Janik 2007-04-02 00:59:01 UTC
many GObject implementations with construction properties need to execute some code after all CONSTRUCT and CONSTRUCT_ONLY properties have been set but before the object is regularly utilized by the g_object_new caller. the currently possible ways to implement such behavior are:

- count the CONSTRUCT properties that have been set already in set_property() and execute extra code if the last CONSTRUCT propety is set.

- override the special GObjectClass->constructor function pointer for every class that needs extra post-CONSTRUCT code and chain back to the original constructor of the class.

both ways are very cumbersome to implement and can hardly be recommended as good coding practice for object implementations. a much nicer way to hook up the required functionality would be the addition of a constructed() vmethod to GObjectClass which is called after the call to GObjectClass.constructor() is completed, but before g_object_new() returns.
Comment 1 Allison Karlitskaya (desrt) 2007-04-02 22:57:42 UTC
Created attachment 85729 [details] [review]
implement constructed vcall

i hope this bug is as simple as it seems.....
Comment 2 Tim Janik 2007-04-03 10:50:48 UTC
thanks, the patch needed some slight modifications as mentioned in the ChangeLog, and i had to split up your ChangeLog entry because we have different logs for the docs, glib and gobject.

Tue Apr  3 12:34:14 2007  Tim Janik  <timj@gtk.org>

        * gobject.[hc]: invoke GObjectClass.constructed() only for newly
        constructed objects, and invoke it while the notify queue is
        still being frozen, after all CONSTRUCT* properties have been
        set and before random other properties are being set.

        * applied modified patch from Ryan Lortie to implement
        GObjectClass.constructed() to fix #425324.