Re: refptr and this



Jonathon Jongsma wrote:
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'm experiencing similar refcounting problems in gstreamermm and up until now, am still thinking about what a good solution would be (I even got into a bit of trouble by asking around in the gstreamer list :-( Murray had mentioned possibly using a boolean in RefPtr but I'm focusing on other things while the solution sort of "bakes".

-Jose


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]