GNOME Bugzilla – Bug 721116
Example cellrenderertoggle.cc needs update to avoid warnings
Last modified: 2014-06-09 14:42:59 UTC
I'm not sure how to properly add a new Glib::Property to custom cell renderers with the recent glib changes to class initialization. https://git.gnome.org/browse/gtkmm-documentation/tree/examples/others/cellrenderercustom/cellrenderertoggle.cc gives these runtime warnings that imitate what I'm trying to do: (a.out:1199): GLib-GObject-WARNING **: Attempt to add property gtkmm__CustomObject_N12_GLOBAL__N_120MyCellRendererToggleE::activatable after class was initialised (a.out:1199): GLib-GObject-WARNING **: Attempt to add property gtkmm__CustomObject_N12_GLOBAL__N_120MyCellRendererToggleE::active after class was initialised (a.out:1199): GLib-GObject-WARNING **: Attempt to add property gtkmm__CustomObject_N12_GLOBAL__N_120MyCellRendererToggleE::radio after class was initialised It would be helpful if this example could be updated. Thanks!
At present there is no proper way of adding custom properties in a gtkmm application. It's not just a matter of updating the example in the gtkmm tutorial. This problem requires changes in glibmm. I've thought a bit about the problem, but I haven't found a reasonable solution. There is some related information in glibmm bug 697229 comment 27 and in glib bug 698614 comment 18.
I began to suspect that and ended up implementing my cell renderer in C. It seems like Glib::Property will need to be depreciated (if depreciation is even the word for "Doesn't work anymore") since its constructor does the property installation and there's no way to call its constructor after ObjectBase() but before Object(). Would it be possible to replace the functionality by adding a Glib::ObjectBase constructor method that takes an additional argument, something like a std::list of type/name pairs?
The glib developers have decided to continue allowing installation of properties after class_init. Fine! See https://git.gnome.org/browse/glib/commit/?id=85e9455f68c6cc6093a1ede1c5f15587bba08b51 Such properties may not be completely thread-safe, though. See https://git.gnome.org/browse/glib/commit/?id=f2f66bfe45f41d18e7437341e5ebf4c70d815958 With the latest glib version from the git master branch the cellrenderertoggle example does not complain about adding properties after class_init. The glib bug 698614 has been closed and marked FIXED, although I would say WONTFIX is the right resolution code. With that fix in glib, I consider this gtkmm bug obsolete.