Re: Gtk::Widget::destory() ?



So, assume the following scenario.  I send the delete signal to the window by clicking on the X.
By default, this should get the window destroyed, correct?  If the way I initially allocated the window
was by using the 'new' operator, would "destroy", in this particular context mean that the C++
pointer has been invalidated, as well, just like the underlying GTK+ instance?

If yes, how is that achieved?  If no, what is the most appropriate place to call delete on the C++
pointer, given that the user rather than the programmer controls when the window is to be
destroyed.  What we need here is another callback that gets invoked immediately after the particular
object (window, in this example) has been finalized.  Is there such a callback, indeed?

Sorry, I'm probably missing something very simple.  It's the last discussion that brought these
questions up in me.


Best regards,

Nickolai



On 10/6/06, Jonathon Jongsma <jonathon jongsma gmail com> wrote:
On 10/6/06, Murray Cumming <murrayc murrayc com> wrote:
> On Fri, 2006-10-06 at 16:50 +0200, Maik Beckmann wrote:
> > > > vbox->remove( *pbar ) ;
> > > >
> > > > At this point it should be destroyed automatically.
> > >
> > > No, child widgets are not destroyed when you remove them (well, since we
> > > fixed that bug, in 2.6 or 2.8). That would be quite random.
> > >
> > > They _are_ destroyed, if they are managed, when the parent container is
> > > destroyed, if the child is _still_ a child of that parent.
> > >
> > > --
> > > Murray Cumming
> >
> > So calling gtk_widget_destroy is a good way to prevent an unnecessary memory consuption, if a huge number of Widgets is created on the fly ?
>
> No, calling gtk_widget_destroy() will probably always lead to disaster.
>
> If you want to delete your widgets, or any other object, then use the C
> ++ keyword "delete".
>

...which means that the documentation that Maik brought up at the
beginning of this thread should really be changed so that it doesn't
mention anything about Gtk::Widget::Destroy() (which doesn't exist)
but instead tell people to 'delete' the widget in the normal C++ way.

--
jonner
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list



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