GNOME Bugzilla – Bug 476703
lookup_type_vfunc called in constructor
Last modified: 2011-01-16 23:33:37 UTC
The Glade::Xml class has a lookup_type_vfunc that allows derived classes to override the GType to create for a certain type name. This is, however, called from glade_xml_construct, in turn called by the Glade::Xml constructor. If a derived class overrides the virtual method, if will not be called, because the constructor of the derived class has not yet run. This makes it impossible to override lookup_type_vfunc in C++.
Created attachment 95546 [details] [review] Proposed patch The patch adds a default constructor and a new static init() function that does the actual initialization via glade_xml_construct. A derived classes create functions should then do this: return init(new DerivedXml, filename, root, domain); The current constructors are kept for compatibility reasons.
Well spotted. Does anyone actually need to ovveride this vfunc?
I am using it in the glom maemo port to create a HildonWindow instead of a GtkWindow for the main window.
That seems like an unpleasant hack. I would prefer an alternative in Glom, such as removing the widget from the GtkWindow and inserting it in the HildonWindow.
It looked like the most straight-forward way doing it to me. However, I just tried out, and reparenting seems to work equally well. Should this problem in libglademm still be fixed, or should we just hide the vfunc from the public (which would probably mean making it a private member, to not break ABI)?
I'm not sure. Let's keep this bug open for now.
This really doesn't seem very useful. Closing.