GNOME Bugzilla – Bug 108971
Deriving from Glib::Object produces debug spew
Last modified: 2004-12-22 21:47:04 UTC
I'm trying to derive from Glib::Object, but in object.cc we find: Object::Object() { // This constructor is ONLY for derived classes that are NOT wrappers of // derived C objects. For instance, Gtk::Object should NOT use this // constructor. TODO: Remove the g_warning() g_warning("Object::Object(): Did you really mean to call this?"); ... Which makes my program produce tons of unnecessary (and not really accurate) debug output. Just making sure the TODO doesn't get forgotten :-)
OK. By the way, why did you want to derive from Glib::Object?
I'm trying to integrate my code with an existing C API (actually, my own, which I'm planning to gradually convert to C++) that takes a GObject.
If you really need to implement a new GType then it might be worth looking at examples of custom TreeModels (one of the Dnd examples, I think) and CellRenderers (the customcellrenderer example). But it's probably best not to depend on GTypes if you can help it.
I think we need to find an example of when this is actually a good idea before we remove that g_warning. I suspect that Daniel has an opinion about this.
At the least we should put a bit more information in that warning, such as "You probably have no reason to derive directly from Glib::Object."
This has been fixed as part of bug #124297. The Glib::Object default constructor is now known to be useful for implementing custom TreeModels, because they need a GType.