diff options
author | Murray Cumming <murrayc@usa.net> | 2004-01-12 21:59:30 +0000 |
---|---|---|
committer | Murray Cumming <murrayc@src.gnome.org> | 2004-01-12 21:59:30 +0000 |
commit | 81e4f81cd28846446e3bad8b6fc8de31cd75f344 (patch) | |
tree | 1aa7854720e80c5f69f6b03beedfe10799337355 /glib/glibmm/object.cc | |
parent | bc479fe4b026502a3b002c224147044af2fae0bc (diff) | |
download | glibmm-81e4f81cd28846446e3bad8b6fc8de31cd75f344.tar.gz |
Object::Object() default constructor. Remove the warning because we really
2004-01-12 Murray Cumming <murrayc@usa.net>
* glib/glibmm/object.cc: Object::Object() default constructor.
Remove the warning because we really need this to implement a custom
TreeModel. Derive a new GType, as in the
Object::Object(ConstructParams) constructor. Like that constructor,
the default one also assumes that you have called a suitable
ObjectBase constructor, such as ObejctBase(typeid(MyCustomClass)).
Diffstat (limited to 'glib/glibmm/object.cc')
-rw-r--r-- | glib/glibmm/object.cc | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/glib/glibmm/object.cc b/glib/glibmm/object.cc index 518ffaad..7155942d 100644 --- a/glib/glibmm/object.cc +++ b/glib/glibmm/object.cc @@ -169,10 +169,32 @@ 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?"); + // constructor. + + //g_warning("Object::Object(): Did you really mean to call this?"); + + // If Glib::ObjectBase has been constructed with a custom typeid, we derive + // a new GType on the fly. This works because ObjectBase is a virtual base + // class, therefore its constructor is always executed first. + + GType object_type = 0; + if(custom_type_name_ && !is_anonymous_custom_()) + { + object_class_.init(); + object_type = object_class_.clone_custom_type(custom_type_name_); //A type that is derived from GObject. + } + else + object_type = G_TYPE_OBJECT; //The default. Not very useful. + + // Create a new GObject with the specified array of construct properties. + // This works with custom types too, since those inherit the properties of + // their base class. + + void *const new_object = g_object_newv(object_type, 0, 0); + + // Connect the GObject and Glib::Object instances. + ObjectBase::initialize(static_cast<GObject*>(new_object)); - ObjectBase::initialize(static_cast<GObject*>(g_object_newv(G_TYPE_OBJECT, 0, 0))); } Object::Object(const Glib::ConstructParams& construct_params) |