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 637738 - object_interface_check_properties never actually executes
object_interface_check_properties never actually executes
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gobject
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-12-21 11:43 UTC by Stephen Kennedy
Modified: 2011-04-06 13:58 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Stephen Kennedy 2010-12-21 11:43:08 UTC
I have been using the g_object_interface_install_property function to install properties on a GInterface, and the docs say that GObject should check that an object implementing the interface has properties that conform to the interface's properties.

However, my tests have shown that creating an GObject that has missing properties does not give any sort of warning.

After poking around in the source code I found the object_interface_check_properties function in gobject.c. This function was being called, but the g_type_class_peek call was always returning NULL, so the checks were bypassed.

So as far as I can tell from trawling the source code:

- object_interface_check_properties is a GTypeInterfaceCheckFunc (registered via g_type_add_interface_check)
- a class is initialised in type_class_init_Wm (in gtype.c)
- within here, type_iface_vtable_iface_init_Wm is called for each interface to initialise its implementation in the class
- within here, the GTypeInterfaceCheckFunc functions are called

Going back to type_class_init_Wm, I notice that *after* the calls to type_iface_vtable_iface_init_Wm we have:

g_atomic_int_set (&node->data->class.init_state, INITIALIZED);

So, from that, I infer that the class is not set to the INITIALIZED state until *after* the check functions are called.

This explains the wrong behaviour in object_interface_check_properties, because if the class is not in INITIALIZED state, g_type_class_peek will return NULL.

A simple fix for this is replacing g_type_class_peek with g_type_class_ref.
Comment 1 Matthias Clasen 2010-12-28 04:42:30 UTC
Thanks for the detective work.

Fixed, and added a testcase.
Comment 2 Garrett Regier 2011-01-01 22:34:25 UTC
The patch committed breaks dynamic types that implement interfaces.

Now a critical warning is emitted for all properties of the interface even though they are overridden.

This can be tested using libpeas and running the demo.
Comment 3 Matthias Clasen 2011-02-19 04:45:50 UTC
Hmm, I don't see any warnings from the peas demo, and I don't see any warnings either in the testcase I've added to gobject/tests/dynamictests.c
Comment 4 Stefan Sauer (gstreamer, gtkdoc dev) 2011-03-26 12:48:20 UTC
Garrett, could you please retest this and let us know, so that if you don't see any regression the bug an be closed.