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

Re: Freeing a widget from memory...



On Monday, July 16, 2001, at 11:38  PM, Janus N. Tøndering wrote:

> I am rather new to the GTK+ toolkit and I am working on my first project
> using it. The GTK+ reference does not describe the gtk_widget_unref and
> destroy functions. Which one should I use to free a widget from memory?
> I have tried both and unref gives me a runtime warning. destroy _seems_
> to be working fine.
>
> Which should I use?

A call to gtk_object_destroy is usually the right thing. For a top level 
widget, destroy makes it "self-destruct" and it ends up unref'ing itself 
too. For other widgets, destroy typically causes its container to unref it.

Since you aren't holding a ref to the widget, you can't unref it. And if 
you were holding a ref to it, unref'ing it wouldn't make it go away since 
its container (or itself if it's a top-level widget) is still holding a 
ref.

     -- Darin




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