Re: How to delete object?!



"Dmitry Ponomaryov" <eagleowl comail ru> writes:
Hi to All!

I need _true_ delete function for GTK widget (i.e. GtkWidget* pr_dialog; an
so on).
If I call "gtk_widget_destroy" memory belongs to object is't become free -
only object's ref count is decremented.
So I try this:

      while( !GTK_OBJECT_DESTROYED( GTK_OBJECT(pr_dialog) ) )
              gtk_object_unref( GTK_OBJECT(pr_dialog) );

or this:

      while ( pr_dialog != NULL )
              gtk_widget_unref( pr_dialog );


These are broken; the problem is that some code is holding a reference
to the widget. You need _that code_ to remove its reference, or you
will get crashes.

while (object_is_alive)
  unref (object);

is always, always, always broken code. You should know how many
references you own and remove that many.

Havoc




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