refptr and this
- From: Jonathon Jongsma <jonathon quotidian org>
- To: gtkmm list <gtkmm-list gnome org>
- Subject: refptr and this
- Date: Fri, 15 Feb 2008 23:36:01 -0600
I've run into an issue while playing around with goocanvasmm trying to
implement custom items and I'm wondering if anybody has run into this
before. The issue is as follows:
- To create a 'group' item, you need to implement the add_child virtual
function
- within the add_child virtual function, it appears that you are
supposed to call set_parent on the new child and set its parent to
yourself. In other words, something like:
add_child_vfunc(Glib::RefPtr<Item> child, int position) {
// add child to an array of items
child->set_parent(this);
}
The problem is, the set_parent() function takes a Glib::RefPtr<>, so I
would need to do something like
child->set_parent(Glib::RefPtr<Item>(this));
Except this seems to cause refcounting problems and the program crashes.
I can obviously revert to the C API and do something like:
goo_canvas_item_set_parent (child->gobj (), GOO_CANVAS_ITEM(gobj ()));
But it would be nice not to have to do that. Any ideas?
For reference, the C function goo_canvas_item_set_parent() does not take
a reference on the parent object...
--
Jonner
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]