Re: [gtk-list] Deleting GTK objects?? (Gtk--)

Robert Knop <> writes:
> I'm doing this in C++ with Gtk--.  So far, I've tried a few things, all of
> which cause a "** ERROR **: sigsegv caught".  What I have is a class which
> is derived from (among other things) Gtk_Window.  In this window are two
> containers, a clist, and five buttons.  There is associated data.  I need
> to close the window and get rid of all the Gtk objects.  This should be
> done (at least) a as a callback from a press on one of the buttons.  What
> is the right way to go about doing this?

I added a section to the faq about this.

> I've tried calling an external function which executes the object's
> destructor, to no avail.

void deletion_function(Gtk_Widget *w) {
  delete w;
connect_to_function(Gtk_Main::idle(), &deletion_function, this);

However, this will restrict how you can use the widget - can only
allocate it with new... - most cases I want to place the widgets inside
another widget and let C++'s scoping handle it.

(there was talk about this in gtkmm list and guess to next release there
will be convinience function to do this..) (in addition to this, it would be
nice if "delete this" would work, but... we'll see if someone figures out why
it doesnt :)

> This certainly doesn't seem to be documented with Gtk--, and I also can't
> find any straight Gtk+ documentation on this.  Most of the examples tend
> to just open a single window, which gets naturally cleaned up when the
> program exits.

Now it is documented in faq.

-- Tero Pulkkinen -- --

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