Re: GooCanvas Reference Counting woes.

This just in... I'm a moron.

Changing the _CONVERSION macro's fixed the problem. All that was required was to link against the right version of the library.


On 10/1/06, Paul Davis <pjdavis engineering uiowa edu> wrote:

I'm going through trying to finish these wrappers for GooCanvas and I'm having a heck of a time trying to get reference counting done correctly.

The most obvious case to point out is in the signal handlers.

From the reading I've been doing, it appears that when the signal is called, the Glib::RefPtr is done using ::wrap() which doesn't appear to increment the reference count.  But then at the end of the signal handler, when the RefPtr goes out of scope, the reference count is decremented, thus causing the object to be deleted.

The signal handler method looks like this:

SimpleWindow::on_rect_button_press( const Glib::RefPtr<GooCanvas::ItemView>& item, GdkEventButton* event )
    std::cout << "You clicked the rectangle!" << std::endl ;
    item->reference() ;
    return true ;

By calling item->reference(), all problems are solved.

I tried changing the convert m4 macro to this:

_CONVERSION(`GooCanvasItemView*',`const Glib::RefPtr<ItemView>&',`Glib::wrap($3,true)')

So that the reference count would be updated, but it doesn't seem to affect anything.

Anyway, the current version in SVN has all this if anyone would like to take a look.

svn url:


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