Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
GInterface implementation in managed land is broken with bleeding edge glib or gobject.
The WARNING thrown is:
GLib-GObject-WARNING **: attempting to add an interface (Foo) to class
(__gtksharp_91_Namespace_SomeClass_+2c+20Assembly+2c+20Version+3d2_6_0_0+2c+20Culture+3dneutral+2c+20PublicKeyToken+3dnull+5d+5d) after class_init
Couple of real examples:
GLib-GObject-WARNING **: attempting to add an interface (AtkTable) to class (__gtksharp_91_Hyena_Data_Gui_Accessibility_ListViewAccessible+601+5b+5bBanshee_Collection_TrackInfo+2c+20Banshee_Core+2c+20Version+3d2_6_0_0+2c+20Culture+3dneutral+2c+20PublicKeyToken+3dnull+5d+5d) after class_init
GLib-GObject-WARNING **: attempting to add an interface (GtkScrollable) to class (__gtksharp_56_Hyena_Data_Gui_ListView+601+5b+5bBanshee_Collection_ArtistInfo+2c+20Banshee_Core+2c+20Version+3d2_6_0_0+2c+20Culture+3dneutral+2c+20PublicKeyToken+3dnull+5d+5d) after class_init
Upstream motivation: https://bugzilla.gnome.org/show_bug.cgi?id=687659
There's a problem with the above pull request, therefore I'm going to close it.
The problem is the following:
1) The patch replaces the use of gtype.GetClassPtr() with gtype.Val, because the former causes class_init to be called.
2) By passing gtype.Val instead of gtype.GetClassPtr(), the initialization of properties is broken.
In regards to (1), FWIW this is what GetClassPtr does:
public IntPtr GetClassPtr ()
IntPtr klass = g_type_class_peek (val);
if (klass == IntPtr.Zero)
klass = g_type_class_ref (val);
I'm still not sure about the reason for (2), but my guess is because g_object_class_override_property  receives a GObjectClass  ptr as a parameter, not a GType .
Now, if the use of g_type_add_interface_static  is properly supposed to call the interface_init function of GInterfaceInfo , which in turn should initialize (override) properties with g_object_class_override_property (otherwise g_type_add_interface_static throws a CRITICAL), then potentially there's only possibility to fix this: to call GetClassPtr in the interface_init function of GInterfaceInfo, but would that really meet the requirements of not calling class_init before adding interfaces? And most importantly: if we have more than one interface, the class would be initted after adding the first one, so this is not possible solution.
This seems to be a chicken&egg problem which I'll discuss with glib devs.
Created attachment 3761 [details]
proof of concept patch
After some more feedback from Ryan in the upstream bug, this is a patch based on his suggestions. Still doesn't work though, but I'll leave it here for reference and further discussion.
Finally a patch that seems to work for both treemodeldemo and custom-scrollable: https://github.com/mono/gtk-sharp/pull/61
Bertrand has just merged this, so I'm marking it as FIXED.